@@ -12,6 +12,7 @@ import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
12
12
import net.mullvad.mullvadvpn.compose.data.DUMMY_RELAY_COUNTRIES
13
13
import net.mullvad.mullvadvpn.compose.data.DUMMY_RELAY_ITEM_CUSTOM_LISTS
14
14
import net.mullvad.mullvadvpn.compose.setContentWithTheme
15
+ import net.mullvad.mullvadvpn.compose.state.RelayListItem
15
16
import net.mullvad.mullvadvpn.compose.state.SelectLocationUiState
16
17
import net.mullvad.mullvadvpn.compose.test.CIRCULAR_PROGRESS_INDICATOR
17
18
import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_CUSTOM_LIST_BOTTOM_SHEET_TEST_TAG
@@ -54,13 +55,13 @@ class SelectLocationScreenTest {
54
55
SelectLocationScreen (
55
56
state =
56
57
SelectLocationUiState .Content (
58
+ searchTerm = " " ,
59
+ filterChips = emptyList(),
60
+ relayListItems =
61
+ DUMMY_RELAY_COUNTRIES .map {
62
+ RelayListItem .GeoLocationItem (item = it)
63
+ },
57
64
customLists = emptyList(),
58
- filteredCustomLists = emptyList(),
59
- countries = DUMMY_RELAY_COUNTRIES ,
60
- selectedItem = null ,
61
- selectedOwnership = null ,
62
- selectedProvidersCount = 0 ,
63
- searchTerm = " "
64
65
),
65
66
)
66
67
}
@@ -74,45 +75,6 @@ class SelectLocationScreenTest {
74
75
onNodeWithText(" Relay host 2" ).assertDoesNotExist()
75
76
}
76
77
77
- @Test
78
- fun testShowRelayListStateSelected () =
79
- composeExtension.use {
80
- val updatedDummyList =
81
- DUMMY_RELAY_COUNTRIES .let {
82
- val cities = it[0 ].cities.toMutableList()
83
- val city = cities.removeAt(0 )
84
- cities.add(0 , city.copy(expanded = true ))
85
-
86
- val mutableRelayList = it.toMutableList()
87
- mutableRelayList[0 ] = it[0 ].copy(expanded = true , cities = cities.toList())
88
- mutableRelayList
89
- }
90
-
91
- // Arrange
92
- setContentWithTheme {
93
- SelectLocationScreen (
94
- state =
95
- SelectLocationUiState .Content (
96
- customLists = emptyList(),
97
- filteredCustomLists = emptyList(),
98
- countries = updatedDummyList,
99
- selectedItem = updatedDummyList[0 ].cities[0 ].relays[0 ].id,
100
- selectedOwnership = null ,
101
- selectedProvidersCount = 0 ,
102
- searchTerm = " "
103
- ),
104
- )
105
- }
106
-
107
- // Assert
108
- onNodeWithText(" Relay Country 1" ).assertExists()
109
- onNodeWithText(" Relay City 1" ).assertExists()
110
- onNodeWithText(" Relay host 1" ).assertExists()
111
- onNodeWithText(" Relay Country 2" ).assertExists()
112
- onNodeWithText(" Relay City 2" ).assertDoesNotExist()
113
- onNodeWithText(" Relay host 2" ).assertDoesNotExist()
114
- }
115
-
116
78
@Test
117
79
fun testSearchInput () =
118
80
composeExtension.use {
@@ -122,13 +84,10 @@ class SelectLocationScreenTest {
122
84
SelectLocationScreen (
123
85
state =
124
86
SelectLocationUiState .Content (
125
- customLists = emptyList(),
126
- filteredCustomLists = emptyList(),
127
- countries = emptyList(),
128
- selectedItem = null ,
129
- selectedOwnership = null ,
130
- selectedProvidersCount = 0 ,
131
- searchTerm = " "
87
+ searchTerm = " " ,
88
+ filterChips = emptyList(),
89
+ relayListItems = emptyList(),
90
+ customLists = emptyList()
132
91
),
133
92
onSearchTermInput = mockedSearchTermInput
134
93
)
@@ -152,13 +111,11 @@ class SelectLocationScreenTest {
152
111
SelectLocationScreen (
153
112
state =
154
113
SelectLocationUiState .Content (
114
+ searchTerm = mockSearchString,
115
+ filterChips = emptyList(),
116
+ relayListItems =
117
+ listOf (RelayListItem .LocationsEmptyText (mockSearchString)),
155
118
customLists = emptyList(),
156
- filteredCustomLists = emptyList(),
157
- countries = emptyList(),
158
- selectedItem = null ,
159
- selectedOwnership = null ,
160
- selectedProvidersCount = 0 ,
161
- searchTerm = mockSearchString
162
119
),
163
120
onSearchTermInput = mockedSearchTermInput
164
121
)
@@ -170,21 +127,18 @@ class SelectLocationScreenTest {
170
127
}
171
128
172
129
@Test
173
- fun givenNoCustomListsAndSearchIsTermIsEmptyShouldShowCustomListsEmptyText () =
130
+ fun customListFooterShouldShowEmptyTextWhenNoCustomList () =
174
131
composeExtension.use {
175
132
// Arrange
176
133
val mockSearchString = " "
177
134
setContentWithTheme {
178
135
SelectLocationScreen (
179
136
state =
180
137
SelectLocationUiState .Content (
138
+ searchTerm = mockSearchString,
139
+ filterChips = emptyList(),
140
+ relayListItems = listOf (RelayListItem .CustomListFooter (false )),
181
141
customLists = emptyList(),
182
- filteredCustomLists = emptyList(),
183
- countries = emptyList(),
184
- selectedItem = null ,
185
- selectedOwnership = null ,
186
- selectedProvidersCount = 0 ,
187
- searchTerm = mockSearchString
188
142
),
189
143
)
190
144
}
@@ -202,13 +156,10 @@ class SelectLocationScreenTest {
202
156
SelectLocationScreen (
203
157
state =
204
158
SelectLocationUiState .Content (
159
+ searchTerm = mockSearchString,
160
+ filterChips = emptyList(),
161
+ relayListItems = emptyList(),
205
162
customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS ,
206
- filteredCustomLists = emptyList(),
207
- countries = emptyList(),
208
- selectedItem = null ,
209
- selectedOwnership = null ,
210
- selectedProvidersCount = 0 ,
211
- searchTerm = mockSearchString
212
163
),
213
164
)
214
165
}
@@ -228,13 +179,10 @@ class SelectLocationScreenTest {
228
179
SelectLocationScreen (
229
180
state =
230
181
SelectLocationUiState .Content (
231
- customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS ,
232
- filteredCustomLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS ,
233
- countries = emptyList(),
234
- selectedItem = null ,
235
- selectedOwnership = null ,
236
- selectedProvidersCount = 0 ,
237
- searchTerm = " "
182
+ searchTerm = " " ,
183
+ filterChips = emptyList(),
184
+ relayListItems = listOf (RelayListItem .CustomListItem (customList)),
185
+ customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS
238
186
),
239
187
onSelectRelay = mockedOnSelectRelay
240
188
)
@@ -257,13 +205,11 @@ class SelectLocationScreenTest {
257
205
SelectLocationScreen (
258
206
state =
259
207
SelectLocationUiState .Content (
260
- customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS ,
261
- filteredCustomLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS ,
262
- countries = emptyList(),
263
- selectedItem = null ,
264
- selectedOwnership = null ,
265
- selectedProvidersCount = 0 ,
266
- searchTerm = " "
208
+ searchTerm = " " ,
209
+ filterChips = emptyList(),
210
+ relayListItems =
211
+ listOf (RelayListItem .CustomListItem (item = customList)),
212
+ customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS
267
213
),
268
214
onSelectRelay = mockedOnSelectRelay
269
215
)
@@ -286,13 +232,10 @@ class SelectLocationScreenTest {
286
232
SelectLocationScreen (
287
233
state =
288
234
SelectLocationUiState .Content (
235
+ searchTerm = " " ,
236
+ filterChips = emptyList(),
237
+ relayListItems = listOf (RelayListItem .GeoLocationItem (relayItem)),
289
238
customLists = emptyList(),
290
- filteredCustomLists = emptyList(),
291
- countries = DUMMY_RELAY_COUNTRIES ,
292
- selectedItem = null ,
293
- selectedOwnership = null ,
294
- selectedProvidersCount = 0 ,
295
- searchTerm = " "
296
239
),
297
240
onSelectRelay = mockedOnSelectRelay
298
241
)
0 commit comments