Skip to content

Commit

Permalink
Merge branch 'custom-list-added-animation-causes-custom-list-descript…
Browse files Browse the repository at this point in the history
…ion-droid-901'
  • Loading branch information
Rawa committed Jul 25, 2024
2 parents 5c24fc3 + 087b5f0 commit 90877d3
Show file tree
Hide file tree
Showing 31 changed files with 1,206 additions and 939 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,25 @@ private val DUMMY_RELAY_2 =
private val DUMMY_RELAY_CITY_1 =
RelayItem.Location.City(
name = "Relay City 1",
id = GeoLocationId.City(countryCode = GeoLocationId.Country("RCo1"), cityCode = "RCi1"),
id = GeoLocationId.City(country = GeoLocationId.Country("RCo1"), code = "RCi1"),
relays = listOf(DUMMY_RELAY_1),
expanded = false
)
private val DUMMY_RELAY_CITY_2 =
RelayItem.Location.City(
name = "Relay City 2",
id = GeoLocationId.City(countryCode = GeoLocationId.Country("RCo2"), cityCode = "RCi2"),
id = GeoLocationId.City(country = GeoLocationId.Country("RCo2"), code = "RCi2"),
relays = listOf(DUMMY_RELAY_2),
expanded = false
)
private val DUMMY_RELAY_COUNTRY_1 =
RelayItem.Location.Country(
name = "Relay Country 1",
id = GeoLocationId.Country("RCo1"),
expanded = false,
cities = listOf(DUMMY_RELAY_CITY_1)
)
private val DUMMY_RELAY_COUNTRY_2 =
RelayItem.Location.Country(
name = "Relay Country 2",
id = GeoLocationId.Country("RCo2"),
expanded = false,
cities = listOf(DUMMY_RELAY_CITY_2)
)

Expand All @@ -80,15 +76,21 @@ val DUMMY_RELAY_LIST =
val DUMMY_RELAY_ITEM_CUSTOM_LISTS =
listOf(
RelayItem.CustomList(
customListName = CustomListName.fromString("First list"),
expanded = false,
id = CustomListId("1"),
customList =
CustomList(
name = CustomListName.fromString("First list"),
id = CustomListId("1"),
locations = emptyList()
),
locations = DUMMY_RELAY_COUNTRIES
),
RelayItem.CustomList(
customListName = CustomListName.fromString("Empty list"),
expanded = false,
id = CustomListId("2"),
customList =
CustomList(
name = CustomListName.fromString("Empty list"),
id = CustomListId("2"),
locations = emptyList()
),
locations = emptyList()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,20 +81,22 @@ 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 = ""
),
)
}

// 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
Expand All @@ -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
)
Expand All @@ -131,7 +134,7 @@ class CustomListLocationsScreenTest {
state =
CustomListLocationsUiState.Content.Data(
newList = false,
availableLocations = DUMMY_RELAY_COUNTRIES,
locations = emptyList(),
),
onSearchTermInput = mockedSearchTermInput
)
Expand Down Expand Up @@ -197,7 +200,7 @@ class CustomListLocationsScreenTest {
state =
CustomListLocationsUiState.Content.Data(
newList = false,
availableLocations = DUMMY_RELAY_COUNTRIES,
locations = emptyList(),
saveEnabled = true,
),
onSaveClick = mockOnSaveClick
Expand All @@ -221,7 +224,7 @@ class CustomListLocationsScreenTest {
state =
CustomListLocationsUiState.Content.Data(
newList = false,
availableLocations = DUMMY_RELAY_COUNTRIES,
locations = emptyList(),
saveEnabled = false,
),
onSaveClick = mockOnSaveClick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = ""
),
)
}
Expand All @@ -74,45 +75,6 @@ class SelectLocationScreenTest {
onNodeWithText("Relay host 2").assertDoesNotExist()
}

@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 {
Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -170,21 +127,18 @@ class SelectLocationScreenTest {
}

@Test
fun givenNoCustomListsAndSearchIsTermIsEmptyShouldShowCustomListsEmptyText() =
fun customListFooterShouldShowEmptyTextWhenNoCustomList() =
composeExtension.use {
// Arrange
val mockSearchString = ""
setContentWithTheme {
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
),
)
}
Expand All @@ -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
),
)
}
Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -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
)
Expand Down
Loading

0 comments on commit 90877d3

Please sign in to comment.