Skip to content

Commit 80c5f55

Browse files
committedJul 25, 2024
Fix tests
1 parent 261b639 commit 80c5f55

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed
 

‎android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt

+9-14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import net.mullvad.mullvadvpn.compose.test.CIRCULAR_PROGRESS_INDICATOR
1818
import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_CUSTOM_LIST_BOTTOM_SHEET_TEST_TAG
1919
import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_CUSTOM_LIST_HEADER_TEST_TAG
2020
import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_LOCATION_BOTTOM_SHEET_TEST_TAG
21+
import net.mullvad.mullvadvpn.lib.model.CustomListId
22+
import net.mullvad.mullvadvpn.lib.model.CustomListName
23+
import net.mullvad.mullvadvpn.lib.model.GeoLocationId
2124
import net.mullvad.mullvadvpn.lib.model.RelayItem
2225
import net.mullvad.mullvadvpn.performLongClick
2326
import org.junit.jupiter.api.BeforeEach
@@ -61,7 +64,6 @@ class SelectLocationScreenTest {
6164
DUMMY_RELAY_COUNTRIES.map {
6265
RelayListItem.GeoLocationItem(item = it)
6366
},
64-
customLists = emptyList(),
6567
),
6668
)
6769
}
@@ -87,7 +89,6 @@ class SelectLocationScreenTest {
8789
searchTerm = "",
8890
filterChips = emptyList(),
8991
relayListItems = emptyList(),
90-
customLists = emptyList()
9192
),
9293
onSearchTermInput = mockedSearchTermInput
9394
)
@@ -115,7 +116,6 @@ class SelectLocationScreenTest {
115116
filterChips = emptyList(),
116117
relayListItems =
117118
listOf(RelayListItem.LocationsEmptyText(mockSearchString)),
118-
customLists = emptyList(),
119119
),
120120
onSearchTermInput = mockedSearchTermInput
121121
)
@@ -138,7 +138,6 @@ class SelectLocationScreenTest {
138138
searchTerm = mockSearchString,
139139
filterChips = emptyList(),
140140
relayListItems = listOf(RelayListItem.CustomListFooter(false)),
141-
customLists = emptyList(),
142141
),
143142
)
144143
}
@@ -159,7 +158,6 @@ class SelectLocationScreenTest {
159158
searchTerm = mockSearchString,
160159
filterChips = emptyList(),
161160
relayListItems = emptyList(),
162-
customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS,
163161
),
164162
)
165163
}
@@ -182,7 +180,6 @@ class SelectLocationScreenTest {
182180
searchTerm = "",
183181
filterChips = emptyList(),
184182
relayListItems = listOf(RelayListItem.CustomListItem(customList)),
185-
customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS
186183
),
187184
onSelectRelay = mockedOnSelectRelay
188185
)
@@ -200,7 +197,7 @@ class SelectLocationScreenTest {
200197
composeExtension.use {
201198
// Arrange
202199
val customList = DUMMY_RELAY_ITEM_CUSTOM_LISTS[0]
203-
val mockedOnSelectRelay: (RelayItem) -> Unit = mockk(relaxed = true)
200+
val mockedOnSelectRelay: (CustomListId, CustomListName) -> Unit = mockk(relaxed = true)
204201
setContentWithTheme {
205202
SelectLocationScreen(
206203
state =
@@ -209,43 +206,41 @@ class SelectLocationScreenTest {
209206
filterChips = emptyList(),
210207
relayListItems =
211208
listOf(RelayListItem.CustomListItem(item = customList)),
212-
customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS
213209
),
214-
onSelectRelay = mockedOnSelectRelay
210+
showEditCustomListBottomSheet = mockedOnSelectRelay
215211
)
216212
}
217213

218214
// Act
219215
onNodeWithText(customList.name).performLongClick()
220216

221217
// Assert
222-
onNodeWithTag(SELECT_LOCATION_CUSTOM_LIST_BOTTOM_SHEET_TEST_TAG)
218+
verify { mockedOnSelectRelay(customList.id, customList.customList.name) }
223219
}
224220

225221
@Test
226222
fun whenLocationIsLongClickedShouldShowBottomSheet() =
227223
composeExtension.use {
228224
// Arrange
229225
val relayItem = DUMMY_RELAY_COUNTRIES[0]
230-
val mockedOnSelectRelay: (RelayItem) -> Unit = mockk(relaxed = true)
226+
val mockedOnSelectRelay: (String, GeoLocationId) -> Unit = mockk(relaxed = true)
231227
setContentWithTheme {
232228
SelectLocationScreen(
233229
state =
234230
SelectLocationUiState.Content(
235231
searchTerm = "",
236232
filterChips = emptyList(),
237233
relayListItems = listOf(RelayListItem.GeoLocationItem(relayItem)),
238-
customLists = emptyList(),
239234
),
240-
onSelectRelay = mockedOnSelectRelay
235+
showLocationBottomSheet = mockedOnSelectRelay
241236
)
242237
}
243238

244239
// Act
245240
onNodeWithText(relayItem.name).performLongClick()
246241

247242
// Assert
248-
onNodeWithTag(SELECT_LOCATION_LOCATION_BOTTOM_SHEET_TEST_TAG)
243+
verify { mockedOnSelectRelay(relayItem.name, relayItem.id) }
249244
}
250245

251246
companion object {

‎android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeDestinationsTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ class ComposeDestinationsTest {
2323
Konsist.scopeFromProduction("app").functions().withAllAnnotationsOf(Destination::class)
2424

2525
companion object {
26-
private val DESTINATION_SUFFIXES = listOf("Screen", "Dialog")
26+
private val DESTINATION_SUFFIXES = listOf("Screen", "Dialog", "Sheet")
2727
}
2828
}

0 commit comments

Comments
 (0)