Add test on DefaultEntryPoints

This commit is contained in:
Benoit Marty 2025-09-12 21:32:24 +02:00
parent a575019760
commit a1aeb24f23
93 changed files with 2426 additions and 418 deletions

View file

@ -225,15 +225,15 @@ class BugReportPresenterTest {
assertThat(awaitItem().sending).isEqualTo(AsyncAction.Uninitialized)
}
}
private fun TestScope.createPresenter(
bugReporter: BugReporter = FakeBugReporter(),
crashDataStore: CrashDataStore = FakeCrashDataStore(),
screenshotHolder: ScreenshotHolder = FakeScreenshotHolder(),
) = BugReportPresenter(
bugReporter = bugReporter,
crashDataStore = crashDataStore,
screenshotHolder = screenshotHolder,
appCoroutineScope = this,
)
}
internal fun TestScope.createPresenter(
bugReporter: BugReporter = FakeBugReporter(),
crashDataStore: CrashDataStore = FakeCrashDataStore(),
screenshotHolder: ScreenshotHolder = FakeScreenshotHolder(),
) = BugReportPresenter(
bugReporter = bugReporter,
crashDataStore = crashDataStore,
screenshotHolder = screenshotHolder,
appCoroutineScope = this,
)

View file

@ -0,0 +1,43 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.features.rageshake.impl.bugreport
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.bumble.appyx.core.modality.BuildContext
import com.google.common.truth.Truth.assertThat
import io.element.android.features.rageshake.api.bugreport.BugReportEntryPoint
import io.element.android.tests.testutils.lambda.lambdaError
import io.element.android.tests.testutils.node.TestParentNode
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class DefaultBugReportEntryPointTest {
@Test
fun `test node builder`() = runTest {
val entryPoint = DefaultBugReportEntryPoint()
val parentNode = TestParentNode.create { buildContext, plugins ->
BugReportNode(
buildContext = buildContext,
plugins = plugins,
presenter = createPresenter(),
bugReporter = FakeBugReporter(),
)
}
val callback = object : BugReportEntryPoint.Callback {
override fun onBugReportSent() = lambdaError()
override fun onViewLogs(basePath: String) = lambdaError()
}
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
.callback(callback)
.build()
assertThat(result).isInstanceOf(BugReportNode::class.java)
assertThat(result.plugins).contains(callback)
}
}