diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-04-22 23:28:39 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2025-05-13 13:54:20 +0200 |
| commit | 365acf9b49139cbdc2afbda524f5fc4f863a726f (patch) | |
| tree | 6c4fa73c3fd7a7be6a9202aaf2216c78fc6ae9a0 /android/app/src/androidTest | |
| parent | d36f215dd5170e50cb2c668fc9c42ae7ecaeac2c (diff) | |
| download | mullvadvpn-365acf9b49139cbdc2afbda524f5fc4f863a726f.tar.xz mullvadvpn-365acf9b49139cbdc2afbda524f5fc4f863a726f.zip | |
Remove the 2 character limit in search locations
Also fixes back behavior in custom list locations
Diffstat (limited to 'android/app/src/androidTest')
4 files changed, 182 insertions, 81 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 049ce6836c..d556fe5d10 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,11 +12,13 @@ import io.mockk.verify 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.CustomListLocationsData import net.mullvad.mullvadvpn.compose.state.CustomListLocationsUiState import net.mullvad.mullvadvpn.compose.state.RelayLocationListItem import net.mullvad.mullvadvpn.lib.model.RelayItem import net.mullvad.mullvadvpn.lib.ui.tag.CIRCULAR_PROGRESS_INDICATOR_TEST_TAG import net.mullvad.mullvadvpn.lib.ui.tag.SAVE_BUTTON_TEST_TAG +import net.mullvad.mullvadvpn.util.Lce import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -55,7 +57,9 @@ class CustomListLocationsScreenTest { fun givenLoadingStateShouldShowLoadingSpinner() = composeExtension.use { // Arrange - initScreen(state = CustomListLocationsUiState.Loading(newList = false)) + initScreen( + state = CustomListLocationsUiState(newList = false, content = Lce.Loading(Unit)) + ) // Assert onNodeWithTag(CIRCULAR_PROGRESS_INDICATOR_TEST_TAG).assertExists() @@ -66,7 +70,9 @@ class CustomListLocationsScreenTest { composeExtension.use { // Arrange val newList = true - initScreen(state = CustomListLocationsUiState.Loading(newList = newList)) + initScreen( + state = CustomListLocationsUiState(newList = newList, content = Lce.Loading(Unit)) + ) // Assert onNodeWithText(ADD_LOCATIONS_TEXT).assertExists() @@ -77,7 +83,9 @@ class CustomListLocationsScreenTest { composeExtension.use { // Arrange val newList = false - initScreen(state = CustomListLocationsUiState.Loading(newList = newList)) + initScreen( + state = CustomListLocationsUiState(newList = newList, content = Lce.Loading(Unit)) + ) // Assert onNodeWithText(EDIT_LOCATIONS_TEXT).assertExists() @@ -89,13 +97,27 @@ class CustomListLocationsScreenTest { // Arrange initScreen( state = - CustomListLocationsUiState.Content.Data( - locations = - listOf( - RelayLocationListItem(DUMMY_RELAY_COUNTRIES[0], checked = true), - RelayLocationListItem(DUMMY_RELAY_COUNTRIES[1], checked = false), + CustomListLocationsUiState( + newList = false, + content = + Lce.Content( + CustomListLocationsData( + locations = + listOf( + RelayLocationListItem( + DUMMY_RELAY_COUNTRIES[0], + checked = true, + ), + RelayLocationListItem( + DUMMY_RELAY_COUNTRIES[1], + checked = false, + ), + ), + searchTerm = "", + saveEnabled = false, + hasUnsavedChanges = false, + ) ), - searchTerm = "", ) ) @@ -112,9 +134,20 @@ class CustomListLocationsScreenTest { val mockedOnRelaySelectionClicked: (RelayItem, Boolean) -> Unit = mockk(relaxed = true) initScreen( state = - CustomListLocationsUiState.Content.Data( + CustomListLocationsUiState( newList = false, - locations = listOf(RelayLocationListItem(selectedCountry, checked = true)), + content = + Lce.Content( + CustomListLocationsData( + locations = + listOf( + RelayLocationListItem(selectedCountry, checked = true) + ), + searchTerm = "", + saveEnabled = false, + hasUnsavedChanges = false, + ) + ), ), onRelaySelectionClick = mockedOnRelaySelectionClicked, ) @@ -133,9 +166,17 @@ class CustomListLocationsScreenTest { val mockedSearchTermInput: (String) -> Unit = mockk(relaxed = true) initScreen( state = - CustomListLocationsUiState.Content.Data( + CustomListLocationsUiState( newList = false, - locations = emptyList(), + content = + Lce.Content( + CustomListLocationsData( + locations = emptyList(), + searchTerm = "", + saveEnabled = false, + hasUnsavedChanges = false, + ) + ), ), onSearchTermInput = mockedSearchTermInput, ) @@ -156,9 +197,17 @@ class CustomListLocationsScreenTest { val mockSearchString = "SEARCH" initScreen( state = - CustomListLocationsUiState.Content.Empty( + CustomListLocationsUiState( newList = false, - searchTerm = mockSearchString, + content = + Lce.Content( + CustomListLocationsData( + searchTerm = mockSearchString, + saveEnabled = false, + hasUnsavedChanges = false, + locations = emptyList(), + ) + ), ), onSearchTermInput = mockedSearchTermInput, ) @@ -171,13 +220,8 @@ class CustomListLocationsScreenTest { fun whenRelayListIsEmptyShouldShowNoRelaysText() = composeExtension.use { // Arrange - val emptySearchString = "" initScreen( - state = - CustomListLocationsUiState.Content.Empty( - newList = false, - searchTerm = emptySearchString, - ) + state = CustomListLocationsUiState(newList = false, content = Lce.Error(Unit)) ) // Assert @@ -191,10 +235,17 @@ class CustomListLocationsScreenTest { val mockOnSaveClick: () -> Unit = mockk(relaxed = true) initScreen( state = - CustomListLocationsUiState.Content.Data( + CustomListLocationsUiState( newList = false, - locations = emptyList(), - saveEnabled = true, + content = + Lce.Content( + CustomListLocationsData( + locations = emptyList(), + saveEnabled = true, + hasUnsavedChanges = true, + searchTerm = "", + ) + ), ), onSaveClick = mockOnSaveClick, ) @@ -213,10 +264,17 @@ class CustomListLocationsScreenTest { val mockOnSaveClick: () -> Unit = mockk(relaxed = true) initScreen( state = - CustomListLocationsUiState.Content.Data( + CustomListLocationsUiState( newList = false, - locations = emptyList(), - saveEnabled = false, + content = + Lce.Content( + CustomListLocationsData( + locations = emptyList(), + saveEnabled = false, + hasUnsavedChanges = false, + searchTerm = "", + ) + ), ), onSaveClick = mockOnSaveClick, ) diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ManageDevicesScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ManageDevicesScreenTest.kt index 7059243d81..6fc1ffd5ab 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ManageDevicesScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ManageDevicesScreenTest.kt @@ -37,7 +37,7 @@ class ManageDevicesScreenTest { } private fun ComposeContext.initScreen( - state: Lce<ManageDevicesUiState, GetDeviceListError>, + state: Lce<Unit, ManageDevicesUiState, GetDeviceListError>, snackbarHostState: SnackbarHostState = SnackbarHostState(), onBackClick: () -> Unit = {}, onTryAgainClicked: () -> Unit = {}, @@ -58,7 +58,7 @@ class ManageDevicesScreenTest { fun loadingStateShowsProgressIndicator() { composeExtension.use { // Arrange - initScreen(state = Lce.Loading) + initScreen(state = Lce.Loading(Unit)) // Assert onNodeWithTag(CIRCULAR_PROGRESS_INDICATOR_TEST_TAG).assertIsDisplayed() diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreenTest.kt index 805324a74f..32a91fa61b 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SearchLocationScreenTest.kt @@ -18,6 +18,7 @@ import net.mullvad.mullvadvpn.lib.model.CustomListId import net.mullvad.mullvadvpn.lib.model.RelayItem import net.mullvad.mullvadvpn.lib.model.RelayItemId import net.mullvad.mullvadvpn.lib.ui.tag.SELECT_LOCATION_CUSTOM_LIST_HEADER_TEST_TAG +import net.mullvad.mullvadvpn.util.Lce import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -38,7 +39,7 @@ class SearchLocationScreenTest { } private fun ComposeContext.initScreen( - state: SearchLocationUiState, + state: Lce<Unit, SearchLocationUiState, Unit>, onSelectRelay: (RelayItem) -> Unit = {}, onToggleExpand: (RelayItemId, CustomListId?, Boolean) -> Unit = { _, _, _ -> }, onSearchInputChanged: (String) -> Unit = {}, @@ -85,7 +86,15 @@ class SearchLocationScreenTest { // Arrange val mockedSearchTermInput: (String) -> Unit = mockk(relaxed = true) initScreen( - state = SearchLocationUiState.NoQuery(searchTerm = "", filterChips = emptyList()), + state = + Lce.Content( + SearchLocationUiState( + searchTerm = "", + filterChips = emptyList(), + relayListItems = emptyList(), + emptyList(), + ) + ), onSearchInputChanged = mockedSearchTermInput, ) val mockSearchString = "SEARCH" @@ -104,11 +113,14 @@ class SearchLocationScreenTest { val mockSearchString = "SEARCH" initScreen( state = - SearchLocationUiState.Content( - searchTerm = mockSearchString, - filterChips = emptyList(), - relayListItems = listOf(RelayListItem.LocationsEmptyText(mockSearchString)), - customLists = emptyList(), + Lce.Content( + SearchLocationUiState( + searchTerm = mockSearchString, + filterChips = emptyList(), + relayListItems = + listOf(RelayListItem.LocationsEmptyText(mockSearchString)), + customLists = emptyList(), + ) ) ) @@ -124,11 +136,13 @@ class SearchLocationScreenTest { val mockSearchString = "SEARCH" initScreen( state = - SearchLocationUiState.Content( - searchTerm = mockSearchString, - filterChips = emptyList(), - relayListItems = emptyList(), - customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + Lce.Content( + SearchLocationUiState( + searchTerm = mockSearchString, + filterChips = emptyList(), + relayListItems = emptyList(), + customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + ) ) ) diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt index 81fa866825..3b259154a4 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreenTest.kt @@ -24,6 +24,8 @@ import net.mullvad.mullvadvpn.lib.model.RelayItem import net.mullvad.mullvadvpn.lib.ui.tag.SELECT_LOCATION_CUSTOM_LIST_BOTTOM_SHEET_TEST_TAG import net.mullvad.mullvadvpn.lib.ui.tag.SELECT_LOCATION_LOCATION_BOTTOM_SHEET_TEST_TAG import net.mullvad.mullvadvpn.performLongClick +import net.mullvad.mullvadvpn.util.Lc +import net.mullvad.mullvadvpn.util.Lce import net.mullvad.mullvadvpn.viewmodel.location.SelectLocationListViewModel import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach @@ -43,7 +45,7 @@ class SelectLocationScreenTest { fun setup() { MockKAnnotations.init(this) loadKoinModules(module { viewModel { listViewModel } }) - every { listViewModel.uiState } returns MutableStateFlow(SelectLocationListUiState.Loading) + every { listViewModel.uiState } returns MutableStateFlow(Lce.Loading(Unit)) } @AfterEach @@ -52,7 +54,7 @@ class SelectLocationScreenTest { } private fun ComposeContext.initScreen( - state: SelectLocationUiState = SelectLocationUiState.Loading, + state: Lc<Unit, SelectLocationUiState> = Lc.Loading(Unit), onSelectRelay: (item: RelayItem) -> Unit = {}, onSearchClick: (RelayListType) -> Unit = {}, onBackClick: () -> Unit = {}, @@ -104,19 +106,25 @@ class SelectLocationScreenTest { // Arrange every { listViewModel.uiState } returns MutableStateFlow( - SelectLocationListUiState.Content( - relayListItems = - DUMMY_RELAY_COUNTRIES.map { RelayListItem.GeoLocationItem(item = it) }, - customLists = emptyList(), + Lce.Content( + SelectLocationListUiState( + relayListItems = + DUMMY_RELAY_COUNTRIES.map { + RelayListItem.GeoLocationItem(item = it) + }, + customLists = emptyList(), + ) ) ) initScreen( state = - SelectLocationUiState.Data( - // searchTerm = "", - filterChips = emptyList(), - multihopEnabled = false, - relayListType = RelayListType.EXIT, + Lc.Content( + SelectLocationUiState( + filterChips = emptyList(), + multihopEnabled = false, + relayListType = RelayListType.EXIT, + isTopBarActionsEnabled = true, + ) ) ) @@ -135,17 +143,22 @@ class SelectLocationScreenTest { // Arrange every { listViewModel.uiState } returns MutableStateFlow( - SelectLocationListUiState.Content( - relayListItems = listOf(RelayListItem.CustomListFooter(false)), - customLists = emptyList(), + Lce.Content( + SelectLocationListUiState( + relayListItems = listOf(RelayListItem.CustomListFooter(false)), + customLists = emptyList(), + ) ) ) initScreen( state = - SelectLocationUiState.Data( - filterChips = emptyList(), - multihopEnabled = false, - relayListType = RelayListType.EXIT, + Lc.Content( + SelectLocationUiState( + filterChips = emptyList(), + multihopEnabled = false, + relayListType = RelayListType.EXIT, + isTopBarActionsEnabled = true, + ) ) ) @@ -160,18 +173,23 @@ class SelectLocationScreenTest { val customList = DUMMY_RELAY_ITEM_CUSTOM_LISTS[0] every { listViewModel.uiState } returns MutableStateFlow( - SelectLocationListUiState.Content( - relayListItems = listOf(RelayListItem.CustomListItem(customList)), - customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + Lce.Content( + SelectLocationListUiState( + relayListItems = listOf(RelayListItem.CustomListItem(customList)), + customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + ) ) ) val mockedOnSelectRelay: (RelayItem) -> Unit = mockk(relaxed = true) initScreen( state = - SelectLocationUiState.Data( - filterChips = emptyList(), - multihopEnabled = false, - relayListType = RelayListType.EXIT, + Lc.Content( + SelectLocationUiState( + filterChips = emptyList(), + multihopEnabled = false, + relayListType = RelayListType.EXIT, + isTopBarActionsEnabled = true, + ) ), onSelectRelay = mockedOnSelectRelay, ) @@ -190,19 +208,25 @@ class SelectLocationScreenTest { val customList = DUMMY_RELAY_ITEM_CUSTOM_LISTS[0] every { listViewModel.uiState } returns MutableStateFlow( - SelectLocationListUiState.Content( - relayListItems = listOf(RelayListItem.CustomListItem(item = customList)), - customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + Lce.Content( + SelectLocationListUiState( + relayListItems = + listOf(RelayListItem.CustomListItem(item = customList)), + customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + ) ) ) val mockedOnSelectRelay: (RelayItem) -> Unit = mockk(relaxed = true) initScreen( state = - SelectLocationUiState.Data( - // searchTerm = "", - filterChips = emptyList(), - multihopEnabled = false, - relayListType = RelayListType.EXIT, + Lc.Content( + SelectLocationUiState( + // searchTerm = "", + filterChips = emptyList(), + multihopEnabled = false, + relayListType = RelayListType.EXIT, + isTopBarActionsEnabled = true, + ) ), onSelectRelay = mockedOnSelectRelay, ) @@ -221,18 +245,23 @@ class SelectLocationScreenTest { val relayItem = DUMMY_RELAY_COUNTRIES[0] every { listViewModel.uiState } returns MutableStateFlow( - SelectLocationListUiState.Content( - relayListItems = listOf(RelayListItem.GeoLocationItem(relayItem)), - customLists = emptyList(), + Lce.Content( + SelectLocationListUiState( + relayListItems = listOf(RelayListItem.GeoLocationItem(relayItem)), + customLists = emptyList(), + ) ) ) val mockedOnSelectRelay: (RelayItem) -> Unit = mockk(relaxed = true) initScreen( state = - SelectLocationUiState.Data( - filterChips = emptyList(), - multihopEnabled = false, - relayListType = RelayListType.EXIT, + Lc.Content( + SelectLocationUiState( + filterChips = emptyList(), + multihopEnabled = false, + relayListType = RelayListType.EXIT, + isTopBarActionsEnabled = true, + ) ), onSelectRelay = mockedOnSelectRelay, ) |
