summaryrefslogtreecommitdiffhomepage
path: root/android/app/src/androidTest
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2024-07-25 14:35:08 +0200
committerDavid Göransson <david.goransson@mullvad.net>2024-07-25 14:40:27 +0200
commit261e320e6e8e77c443632de3afb1b8cf4076413a (patch)
treee53a662055814bac43a5a57fd72fa5d737ca047a /android/app/src/androidTest
parent18edefdd1353348873bd44f1ca558a8c448728ab (diff)
downloadmullvadvpn-261e320e6e8e77c443632de3afb1b8cf4076413a.tar.xz
mullvadvpn-261e320e6e8e77c443632de3afb1b8cf4076413a.zip
Adapt tests to flat list uiState
Diffstat (limited to 'android/app/src/androidTest')
-rw-r--r--android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreenTest.kt25
-rw-r--r--android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt125
2 files changed, 48 insertions, 102 deletions
diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreenTest.kt
index 4f4db0a529..1a8d35a5a9 100644
--- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreenTest.kt
+++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreenTest.kt
@@ -12,6 +12,7 @@ import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
import net.mullvad.mullvadvpn.compose.data.DUMMY_RELAY_COUNTRIES
import net.mullvad.mullvadvpn.compose.setContentWithTheme
import net.mullvad.mullvadvpn.compose.state.CustomListLocationsUiState
+import net.mullvad.mullvadvpn.compose.state.RelayLocationListItem
import net.mullvad.mullvadvpn.compose.test.CIRCULAR_PROGRESS_INDICATOR
import net.mullvad.mullvadvpn.compose.test.SAVE_BUTTON_TEST_TAG
import net.mullvad.mullvadvpn.lib.model.RelayItem
@@ -80,8 +81,14 @@ class CustomListLocationsScreenTest {
CustomListLocationsScreen(
state =
CustomListLocationsUiState.Content.Data(
- availableLocations = DUMMY_RELAY_COUNTRIES,
- selectedLocations = emptySet(),
+ locations =
+ listOf(
+ RelayLocationListItem(DUMMY_RELAY_COUNTRIES[0], checked = true),
+ RelayLocationListItem(
+ DUMMY_RELAY_COUNTRIES[1],
+ checked = false
+ ),
+ ),
searchTerm = ""
),
)
@@ -89,11 +96,7 @@ class CustomListLocationsScreenTest {
// Assert
onNodeWithText("Relay Country 1").assertExists()
- onNodeWithText("Relay City 1").assertDoesNotExist()
- onNodeWithText("Relay host 1").assertDoesNotExist()
onNodeWithText("Relay Country 2").assertExists()
- onNodeWithText("Relay City 2").assertDoesNotExist()
- onNodeWithText("Relay host 2").assertDoesNotExist()
}
@Test
@@ -107,8 +110,8 @@ class CustomListLocationsScreenTest {
state =
CustomListLocationsUiState.Content.Data(
newList = false,
- availableLocations = DUMMY_RELAY_COUNTRIES,
- selectedLocations = setOf(selectedCountry)
+ locations =
+ listOf(RelayLocationListItem(selectedCountry, checked = true))
),
onRelaySelectionClick = mockedOnRelaySelectionClicked
)
@@ -131,7 +134,7 @@ class CustomListLocationsScreenTest {
state =
CustomListLocationsUiState.Content.Data(
newList = false,
- availableLocations = DUMMY_RELAY_COUNTRIES,
+ locations = emptyList(),
),
onSearchTermInput = mockedSearchTermInput
)
@@ -197,7 +200,7 @@ class CustomListLocationsScreenTest {
state =
CustomListLocationsUiState.Content.Data(
newList = false,
- availableLocations = DUMMY_RELAY_COUNTRIES,
+ locations = emptyList(),
saveEnabled = true,
),
onSaveClick = mockOnSaveClick
@@ -221,7 +224,7 @@ class CustomListLocationsScreenTest {
state =
CustomListLocationsUiState.Content.Data(
newList = false,
- availableLocations = DUMMY_RELAY_COUNTRIES,
+ locations = emptyList(),
saveEnabled = false,
),
onSaveClick = mockOnSaveClick
diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt
index 4fcee479d6..4f3bac57e2 100644
--- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt
+++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreenTest.kt
@@ -12,6 +12,7 @@ import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
import net.mullvad.mullvadvpn.compose.data.DUMMY_RELAY_COUNTRIES
import net.mullvad.mullvadvpn.compose.data.DUMMY_RELAY_ITEM_CUSTOM_LISTS
import net.mullvad.mullvadvpn.compose.setContentWithTheme
+import net.mullvad.mullvadvpn.compose.state.RelayListItem
import net.mullvad.mullvadvpn.compose.state.SelectLocationUiState
import net.mullvad.mullvadvpn.compose.test.CIRCULAR_PROGRESS_INDICATOR
import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_CUSTOM_LIST_BOTTOM_SHEET_TEST_TAG
@@ -54,13 +55,13 @@ class SelectLocationScreenTest {
SelectLocationScreen(
state =
SelectLocationUiState.Content(
+ searchTerm = "",
+ filterChips = emptyList(),
+ relayListItems =
+ DUMMY_RELAY_COUNTRIES.map {
+ RelayListItem.GeoLocationItem(item = it)
+ },
customLists = emptyList(),
- filteredCustomLists = emptyList(),
- countries = DUMMY_RELAY_COUNTRIES,
- selectedItem = null,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = ""
),
)
}
@@ -75,45 +76,6 @@ class SelectLocationScreenTest {
}
@Test
- fun testShowRelayListStateSelected() =
- composeExtension.use {
- val updatedDummyList =
- DUMMY_RELAY_COUNTRIES.let {
- val cities = it[0].cities.toMutableList()
- val city = cities.removeAt(0)
- cities.add(0, city.copy(expanded = true))
-
- val mutableRelayList = it.toMutableList()
- mutableRelayList[0] = it[0].copy(expanded = true, cities = cities.toList())
- mutableRelayList
- }
-
- // Arrange
- setContentWithTheme {
- SelectLocationScreen(
- state =
- SelectLocationUiState.Content(
- customLists = emptyList(),
- filteredCustomLists = emptyList(),
- countries = updatedDummyList,
- selectedItem = updatedDummyList[0].cities[0].relays[0].id,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = ""
- ),
- )
- }
-
- // Assert
- onNodeWithText("Relay Country 1").assertExists()
- onNodeWithText("Relay City 1").assertExists()
- onNodeWithText("Relay host 1").assertExists()
- onNodeWithText("Relay Country 2").assertExists()
- onNodeWithText("Relay City 2").assertDoesNotExist()
- onNodeWithText("Relay host 2").assertDoesNotExist()
- }
-
- @Test
fun testSearchInput() =
composeExtension.use {
// Arrange
@@ -122,13 +84,10 @@ class SelectLocationScreenTest {
SelectLocationScreen(
state =
SelectLocationUiState.Content(
- customLists = emptyList(),
- filteredCustomLists = emptyList(),
- countries = emptyList(),
- selectedItem = null,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = ""
+ searchTerm = "",
+ filterChips = emptyList(),
+ relayListItems = emptyList(),
+ customLists = emptyList()
),
onSearchTermInput = mockedSearchTermInput
)
@@ -152,13 +111,11 @@ class SelectLocationScreenTest {
SelectLocationScreen(
state =
SelectLocationUiState.Content(
+ searchTerm = mockSearchString,
+ filterChips = emptyList(),
+ relayListItems =
+ listOf(RelayListItem.LocationsEmptyText(mockSearchString)),
customLists = emptyList(),
- filteredCustomLists = emptyList(),
- countries = emptyList(),
- selectedItem = null,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = mockSearchString
),
onSearchTermInput = mockedSearchTermInput
)
@@ -170,7 +127,7 @@ class SelectLocationScreenTest {
}
@Test
- fun givenNoCustomListsAndSearchIsTermIsEmptyShouldShowCustomListsEmptyText() =
+ fun customListFooterShouldShowEmptyTextWhenNoCustomList() =
composeExtension.use {
// Arrange
val mockSearchString = ""
@@ -178,13 +135,10 @@ class SelectLocationScreenTest {
SelectLocationScreen(
state =
SelectLocationUiState.Content(
+ searchTerm = mockSearchString,
+ filterChips = emptyList(),
+ relayListItems = listOf(RelayListItem.CustomListFooter(false)),
customLists = emptyList(),
- filteredCustomLists = emptyList(),
- countries = emptyList(),
- selectedItem = null,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = mockSearchString
),
)
}
@@ -202,13 +156,10 @@ class SelectLocationScreenTest {
SelectLocationScreen(
state =
SelectLocationUiState.Content(
+ searchTerm = mockSearchString,
+ filterChips = emptyList(),
+ relayListItems = emptyList(),
customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS,
- filteredCustomLists = emptyList(),
- countries = emptyList(),
- selectedItem = null,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = mockSearchString
),
)
}
@@ -228,13 +179,10 @@ class SelectLocationScreenTest {
SelectLocationScreen(
state =
SelectLocationUiState.Content(
- customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS,
- filteredCustomLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS,
- countries = emptyList(),
- selectedItem = null,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = ""
+ searchTerm = "",
+ filterChips = emptyList(),
+ relayListItems = listOf(RelayListItem.CustomListItem(customList)),
+ customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS
),
onSelectRelay = mockedOnSelectRelay
)
@@ -257,13 +205,11 @@ class SelectLocationScreenTest {
SelectLocationScreen(
state =
SelectLocationUiState.Content(
- customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS,
- filteredCustomLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS,
- countries = emptyList(),
- selectedItem = null,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = ""
+ searchTerm = "",
+ filterChips = emptyList(),
+ relayListItems =
+ listOf(RelayListItem.CustomListItem(item = customList)),
+ customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS
),
onSelectRelay = mockedOnSelectRelay
)
@@ -286,13 +232,10 @@ class SelectLocationScreenTest {
SelectLocationScreen(
state =
SelectLocationUiState.Content(
+ searchTerm = "",
+ filterChips = emptyList(),
+ relayListItems = listOf(RelayListItem.GeoLocationItem(relayItem)),
customLists = emptyList(),
- filteredCustomLists = emptyList(),
- countries = DUMMY_RELAY_COUNTRIES,
- selectedItem = null,
- selectedOwnership = null,
- selectedProvidersCount = 0,
- searchTerm = ""
),
onSelectRelay = mockedOnSelectRelay
)