Add missing tests on TroubleshootTestSuite
This commit is contained in:
parent
054e0564f8
commit
41ef36c1ae
1 changed files with 75 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ import io.element.android.libraries.troubleshoot.api.test.NotificationTroublesho
|
||||||
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTestState
|
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTestState
|
||||||
import io.element.android.services.analytics.test.FakeAnalyticsService
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
import io.element.android.tests.testutils.lambda.lambdaError
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.test
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
|
|
@ -76,6 +77,80 @@ class TroubleshootNotificationsPresenterTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - critical failed test`() {
|
||||||
|
`present - check main state`(
|
||||||
|
tests = setOf(
|
||||||
|
FakeNotificationTroubleshootTest(
|
||||||
|
firstStatus = NotificationTroubleshootTestState.Status.Failure(isCritical = true)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
expectedIsCritical = true,
|
||||||
|
expectedMainState = AsyncAction.Failure::class.java,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - success and critical failed test`() {
|
||||||
|
`present - check main state`(
|
||||||
|
tests = setOf(
|
||||||
|
FakeNotificationTroubleshootTest(
|
||||||
|
firstStatus = NotificationTroubleshootTestState.Status.Success
|
||||||
|
),
|
||||||
|
FakeNotificationTroubleshootTest(
|
||||||
|
firstStatus = NotificationTroubleshootTestState.Status.Failure(isCritical = true)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
expectedIsCritical = true,
|
||||||
|
expectedMainState = AsyncAction.Failure::class.java,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - non critical failed test`() {
|
||||||
|
`present - check main state`(
|
||||||
|
tests = setOf(
|
||||||
|
FakeNotificationTroubleshootTest(
|
||||||
|
firstStatus = NotificationTroubleshootTestState.Status.Failure(isCritical = false)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
expectedIsCritical = false,
|
||||||
|
expectedMainState = AsyncAction.Success::class.java,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - waiting for user`() {
|
||||||
|
`present - check main state`(
|
||||||
|
tests = setOf(
|
||||||
|
FakeNotificationTroubleshootTest(
|
||||||
|
firstStatus = NotificationTroubleshootTestState.Status.WaitingForUser
|
||||||
|
)
|
||||||
|
),
|
||||||
|
expectedIsCritical = false,
|
||||||
|
expectedMainState = AsyncAction.ConfirmingNoParams::class.java,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun `present - check main state`(
|
||||||
|
tests: Set<NotificationTroubleshootTest>,
|
||||||
|
expectedIsCritical: Boolean,
|
||||||
|
expectedMainState: Class<out AsyncAction<*>>,
|
||||||
|
) = runTest {
|
||||||
|
val troubleshootTestSuite = createTroubleshootTestSuite(
|
||||||
|
tests = tests
|
||||||
|
)
|
||||||
|
val presenter = createTroubleshootNotificationsPresenter(
|
||||||
|
troubleshootTestSuite = troubleshootTestSuite,
|
||||||
|
)
|
||||||
|
presenter.test {
|
||||||
|
skipItems(1)
|
||||||
|
val initialState = awaitItem()
|
||||||
|
assertThat(initialState.hasFailedTests).isEqualTo(expectedIsCritical)
|
||||||
|
assertThat(initialState.testSuiteState.mainState).isInstanceOf(expectedMainState)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - quick fix test`() = runTest {
|
fun `present - quick fix test`() = runTest {
|
||||||
val troubleshootTestSuite = createTroubleshootTestSuite(
|
val troubleshootTestSuite = createTroubleshootTestSuite(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue