@@ -18,6 +18,7 @@ import io.element.android.libraries.troubleshoot.api.test.NotificationTroublesho
18
18
import io.element.android.libraries.troubleshoot.api.test.NotificationTroubleshootTestState
19
19
import io.element.android.services.analytics.test.FakeAnalyticsService
20
20
import io.element.android.tests.testutils.lambda.lambdaError
21
+ import io.element.android.tests.testutils.test
21
22
import kotlinx.coroutines.test.runTest
22
23
import org.junit.Test
23
24
@@ -76,6 +77,80 @@ class TroubleshootNotificationsPresenterTest {
76
77
}
77
78
}
78
79
80
+ @Test
81
+ fun `present - critical failed test` () {
82
+ `present - check main state`(
83
+ tests = setOf (
84
+ FakeNotificationTroubleshootTest (
85
+ firstStatus = NotificationTroubleshootTestState .Status .Failure (isCritical = true )
86
+ )
87
+ ),
88
+ expectedIsCritical = true ,
89
+ expectedMainState = AsyncAction .Failure ::class .java,
90
+ )
91
+ }
92
+
93
+ @Test
94
+ fun `present - success and critical failed test` () {
95
+ `present - check main state`(
96
+ tests = setOf (
97
+ FakeNotificationTroubleshootTest (
98
+ firstStatus = NotificationTroubleshootTestState .Status .Success
99
+ ),
100
+ FakeNotificationTroubleshootTest (
101
+ firstStatus = NotificationTroubleshootTestState .Status .Failure (isCritical = true )
102
+ ),
103
+ ),
104
+ expectedIsCritical = true ,
105
+ expectedMainState = AsyncAction .Failure ::class .java,
106
+ )
107
+ }
108
+
109
+ @Test
110
+ fun `present - non critical failed test` () {
111
+ `present - check main state`(
112
+ tests = setOf (
113
+ FakeNotificationTroubleshootTest (
114
+ firstStatus = NotificationTroubleshootTestState .Status .Failure (isCritical = false )
115
+ )
116
+ ),
117
+ expectedIsCritical = false ,
118
+ expectedMainState = AsyncAction .Success ::class .java,
119
+ )
120
+ }
121
+
122
+ @Test
123
+ fun `present - waiting for user` () {
124
+ `present - check main state`(
125
+ tests = setOf (
126
+ FakeNotificationTroubleshootTest (
127
+ firstStatus = NotificationTroubleshootTestState .Status .WaitingForUser
128
+ )
129
+ ),
130
+ expectedIsCritical = false ,
131
+ expectedMainState = AsyncAction .ConfirmingNoParams ::class .java,
132
+ )
133
+ }
134
+
135
+ private fun `present - check main state` (
136
+ tests : Set <NotificationTroubleshootTest >,
137
+ expectedIsCritical : Boolean ,
138
+ expectedMainState : Class <out AsyncAction <* >>,
139
+ ) = runTest {
140
+ val troubleshootTestSuite = createTroubleshootTestSuite(
141
+ tests = tests
142
+ )
143
+ val presenter = createTroubleshootNotificationsPresenter(
144
+ troubleshootTestSuite = troubleshootTestSuite,
145
+ )
146
+ presenter.test {
147
+ skipItems(1 )
148
+ val initialState = awaitItem()
149
+ assertThat(initialState.hasFailedTests).isEqualTo(expectedIsCritical)
150
+ assertThat(initialState.testSuiteState.mainState).isInstanceOf(expectedMainState)
151
+ }
152
+ }
153
+
79
154
@Test
80
155
fun `present - quick fix test` () = runTest {
81
156
val troubleshootTestSuite = createTroubleshootTestSuite(
0 commit comments