diff options
| author | David Göransson <david.goransson@mullvad.net> | 2024-05-29 17:18:29 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2024-05-29 17:18:29 +0200 |
| commit | ad90145a5d86d8c1e6e70f2238f11edf5e50f8d8 (patch) | |
| tree | 9d085bc81caed9409e3a4360490c06c2da4fbba8 /android/app/src/androidTest | |
| parent | 8e14a8d4287af66a57a98db79d3ac320c2dad4a1 (diff) | |
| parent | 767b97eda756f4ec4e67fb5fa2ae664277291e8f (diff) | |
| download | mullvadvpn-ad90145a5d86d8c1e6e70f2238f11edf5e50f8d8.tar.xz mullvadvpn-ad90145a5d86d8c1e6e70f2238f11edf5e50f8d8.zip | |
Merge branch 'android-grpc'
Diffstat (limited to 'android/app/src/androidTest')
16 files changed, 288 insertions, 268 deletions
diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/data/DummyRelayItems.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/data/DummyRelayItems.kt index 2adfa22220..0218e06afd 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/data/DummyRelayItems.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/data/DummyRelayItems.kt @@ -1,61 +1,108 @@ package net.mullvad.mullvadvpn.compose.data -import net.mullvad.mullvadvpn.model.CustomListName -import net.mullvad.mullvadvpn.model.PortRange -import net.mullvad.mullvadvpn.model.RelayEndpointData -import net.mullvad.mullvadvpn.model.RelayList -import net.mullvad.mullvadvpn.model.RelayListCity -import net.mullvad.mullvadvpn.model.RelayListCountry -import net.mullvad.mullvadvpn.model.WireguardEndpointData -import net.mullvad.mullvadvpn.model.WireguardRelayEndpointData -import net.mullvad.mullvadvpn.relaylist.RelayItem -import net.mullvad.mullvadvpn.relaylist.toRelayCountries +import net.mullvad.mullvadvpn.lib.model.CustomList +import net.mullvad.mullvadvpn.lib.model.CustomListId +import net.mullvad.mullvadvpn.lib.model.CustomListName +import net.mullvad.mullvadvpn.lib.model.GeoLocationId +import net.mullvad.mullvadvpn.lib.model.Ownership +import net.mullvad.mullvadvpn.lib.model.PortRange +import net.mullvad.mullvadvpn.lib.model.Provider +import net.mullvad.mullvadvpn.lib.model.ProviderId +import net.mullvad.mullvadvpn.lib.model.RelayItem +import net.mullvad.mullvadvpn.lib.model.RelayList +import net.mullvad.mullvadvpn.lib.model.WireguardEndpointData private val DUMMY_RELAY_1 = - net.mullvad.mullvadvpn.model.Relay( - hostname = "Relay host 1", + RelayItem.Location.Relay( + id = + GeoLocationId.Hostname( + city = GeoLocationId.City(GeoLocationId.Country("RCo1"), "Relay City 1"), + "Relay host 1" + ), active = true, - endpointData = RelayEndpointData.Wireguard(WireguardRelayEndpointData), - owned = true, - provider = "PROVIDER" + provider = + Provider( + providerId = ProviderId("PROVIDER RENTED"), + ownership = Ownership.Rented, + ) ) private val DUMMY_RELAY_2 = - net.mullvad.mullvadvpn.model.Relay( - hostname = "Relay host 2", + RelayItem.Location.Relay( + id = + GeoLocationId.Hostname( + city = GeoLocationId.City(GeoLocationId.Country("RCo2"), "Relay City 2"), + "Relay host 2" + ), active = true, - endpointData = RelayEndpointData.Wireguard(WireguardRelayEndpointData), - owned = true, - provider = "PROVIDER" + provider = + Provider(providerId = ProviderId("PROVIDER OWNED"), ownership = Ownership.MullvadOwned) + ) +private val DUMMY_RELAY_CITY_1 = + RelayItem.Location.City( + name = "Relay City 1", + id = GeoLocationId.City(countryCode = GeoLocationId.Country("RCo1"), cityCode = "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"), + relays = listOf(DUMMY_RELAY_2), + expanded = false ) -private val DUMMY_RELAY_CITY_1 = RelayListCity("Relay City 1", "RCi1", arrayListOf(DUMMY_RELAY_1)) -private val DUMMY_RELAY_CITY_2 = RelayListCity("Relay City 2", "RCi2", arrayListOf(DUMMY_RELAY_2)) private val DUMMY_RELAY_COUNTRY_1 = - RelayListCountry("Relay Country 1", "RCo1", arrayListOf(DUMMY_RELAY_CITY_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 = - RelayListCountry("Relay Country 2", "RCo2", arrayListOf(DUMMY_RELAY_CITY_2)) + RelayItem.Location.Country( + name = "Relay Country 2", + id = GeoLocationId.Country("RCo2"), + expanded = false, + cities = listOf(DUMMY_RELAY_CITY_2) + ) private val DUMMY_WIREGUARD_PORT_RANGES = ArrayList<PortRange>() private val DUMMY_WIREGUARD_ENDPOINT_DATA = WireguardEndpointData(DUMMY_WIREGUARD_PORT_RANGES) -val DUMMY_RELAY_COUNTRIES = +val DUMMY_RELAY_COUNTRIES = listOf(DUMMY_RELAY_COUNTRY_1, DUMMY_RELAY_COUNTRY_2) + +val DUMMY_RELAY_LIST = RelayList( - arrayListOf(DUMMY_RELAY_COUNTRY_1, DUMMY_RELAY_COUNTRY_2), - DUMMY_WIREGUARD_ENDPOINT_DATA, - ) - .toRelayCountries() + DUMMY_RELAY_COUNTRIES, + DUMMY_WIREGUARD_ENDPOINT_DATA, + ) -val DUMMY_CUSTOM_LISTS = +val DUMMY_RELAY_ITEM_CUSTOM_LISTS = listOf( RelayItem.CustomList( - CustomListName.fromString("First list"), - false, - "1", + customListName = CustomListName.fromString("First list"), + expanded = false, + id = CustomListId("1"), locations = DUMMY_RELAY_COUNTRIES ), RelayItem.CustomList( - CustomListName.fromString("Empty list"), + customListName = CustomListName.fromString("Empty list"), expanded = false, - "2", + id = CustomListId("2"), + locations = emptyList() + ) + ) + +val DUMMY_CUSTOM_LISTS = + listOf( + CustomList( + name = CustomListName.fromString("First list"), + id = CustomListId("1"), + locations = DUMMY_RELAY_COUNTRIES.map { it.id } + ), + CustomList( + name = CustomListName.fromString("Empty list"), + id = CustomListId("2"), locations = emptyList() ) ) diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialogTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialogTest.kt index baeb5902d7..915db82438 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialogTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialogTest.kt @@ -12,7 +12,9 @@ import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension import net.mullvad.mullvadvpn.compose.setContentWithTheme import net.mullvad.mullvadvpn.compose.state.CreateCustomListUiState import net.mullvad.mullvadvpn.compose.test.CREATE_CUSTOM_LIST_DIALOG_INPUT_TEST_TAG -import net.mullvad.mullvadvpn.model.CustomListsError +import net.mullvad.mullvadvpn.lib.model.CustomListAlreadyExists +import net.mullvad.mullvadvpn.lib.model.UnknownCustomListError +import net.mullvad.mullvadvpn.usecase.customlists.CreateWithLocationsError import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -44,7 +46,10 @@ class CreateCustomListDialogTest { fun givenCustomListExistsShouldShowCustomListExitsErrorText() = composeExtension.use { // Arrange - val state = CreateCustomListUiState(error = CustomListsError.CustomListExists) + val state = + CreateCustomListUiState( + error = CreateWithLocationsError.Create(CustomListAlreadyExists) + ) setContentWithTheme { CreateCustomListDialog(state = state) } // Assert @@ -56,7 +61,10 @@ class CreateCustomListDialogTest { fun givenOtherCustomListErrorShouldShowAnErrorOccurredErrorText() = composeExtension.use { // Arrange - val state = CreateCustomListUiState(error = CustomListsError.OtherError) + val state = + CreateCustomListUiState( + error = CreateWithLocationsError.Create(UnknownCustomListError(Throwable())) + ) setContentWithTheme { CreateCustomListDialog(state = state) } // Assert diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialogTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialogTest.kt index f9c7ec2143..bcb3908fae 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialogTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialogTest.kt @@ -9,7 +9,8 @@ import io.mockk.MockKAnnotations import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension import net.mullvad.mullvadvpn.compose.setContentWithTheme import net.mullvad.mullvadvpn.compose.test.CUSTOM_PORT_DIALOG_INPUT_TEST_TAG -import net.mullvad.mullvadvpn.model.PortRange +import net.mullvad.mullvadvpn.lib.model.Port +import net.mullvad.mullvadvpn.lib.model.PortRange import net.mullvad.mullvadvpn.onNodeWithTagAndText import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -29,9 +30,9 @@ class CustomPortDialogTest { @SuppressLint("ComposableNaming") @Composable private fun testWireguardCustomPortDialog( - initialPort: Int? = null, + initialPort: Port? = null, allowedPortRanges: List<PortRange> = emptyList(), - onSave: (Int?) -> Unit = { _ -> }, + onSave: (Port?) -> Unit = { _ -> }, onDismiss: () -> Unit = {}, ) { @@ -47,21 +48,20 @@ class CustomPortDialogTest { fun testShowWireguardCustomPortDialogInvalidInt() = composeExtension.use { // Input a number to make sure that a too long number does not show and it does not - // crash - // the app + // crash the app // Arrange setContentWithTheme { testWireguardCustomPortDialog() } // Act - onNodeWithTag(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG).performTextInput(invalidCustomPort) + onNodeWithTag(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG).performTextInput(INVALID_CUSTOM_PORT) // Assert - onNodeWithTagAndText(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG, invalidCustomPort) + onNodeWithTagAndText(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG, INVALID_CUSTOM_PORT) .assertDoesNotExist() } companion object { - const val invalidCustomPort = "21474836471" + const val INVALID_CUSTOM_PORT = "21474836471" } } diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeleteCustomListConfirmationDialogTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeleteCustomListConfirmationDialogTest.kt index e79c5a2fe7..ee347c246a 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeleteCustomListConfirmationDialogTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeleteCustomListConfirmationDialogTest.kt @@ -8,6 +8,8 @@ import io.mockk.mockk import io.mockk.verify import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension import net.mullvad.mullvadvpn.compose.setContentWithTheme +import net.mullvad.mullvadvpn.compose.state.DeleteCustomListUiState +import net.mullvad.mullvadvpn.lib.model.CustomListName import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -27,8 +29,13 @@ class DeleteCustomListConfirmationDialogTest { fun givenNameShouldShowDeleteNameTitle() = composeExtension.use { // Arrange - val name = "List should be deleted" - setContentWithTheme { DeleteCustomListConfirmationDialog(name = name) } + val name = CustomListName.fromString("List should be deleted") + setContentWithTheme { + DeleteCustomListConfirmationDialog( + name = name, + state = DeleteCustomListUiState(null) + ) + } // Assert onNodeWithText(DELETE_TITLE.format(name)).assertExists() @@ -38,10 +45,14 @@ class DeleteCustomListConfirmationDialogTest { fun whenDeleteIsClickedShouldCallOnDelete() = composeExtension.use { // Arrange - val name = "List should be deleted" + val name = CustomListName.fromString("List should be deleted") val mockedOnDelete: () -> Unit = mockk(relaxed = true) setContentWithTheme { - DeleteCustomListConfirmationDialog(name = name, onDelete = mockedOnDelete) + DeleteCustomListConfirmationDialog( + name = name, + state = DeleteCustomListUiState(null), + onDelete = mockedOnDelete + ) } // Act @@ -55,10 +66,14 @@ class DeleteCustomListConfirmationDialogTest { fun whenCancelIsClickedShouldCallOnBack() = composeExtension.use { // Arrange - val name = "List should be deleted" + val name = CustomListName.fromString("List should be deleted") val mockedOnBack: () -> Unit = mockk(relaxed = true) setContentWithTheme { - DeleteCustomListConfirmationDialog(name = name, onBack = mockedOnBack) + DeleteCustomListConfirmationDialog( + name = name, + state = DeleteCustomListUiState(null), + onBack = mockedOnBack + ) } // Act diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialogTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialogTest.kt index cbd6ae09d7..3128bbc508 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialogTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialogTest.kt @@ -10,9 +10,11 @@ import io.mockk.mockk import io.mockk.verify import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension import net.mullvad.mullvadvpn.compose.setContentWithTheme -import net.mullvad.mullvadvpn.compose.state.UpdateCustomListUiState +import net.mullvad.mullvadvpn.compose.state.EditCustomListNameUiState import net.mullvad.mullvadvpn.compose.test.EDIT_CUSTOM_LIST_DIALOG_INPUT_TEST_TAG -import net.mullvad.mullvadvpn.model.CustomListsError +import net.mullvad.mullvadvpn.lib.model.NameAlreadyExists +import net.mullvad.mullvadvpn.lib.model.UnknownCustomListError +import net.mullvad.mullvadvpn.usecase.customlists.RenameError import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -32,7 +34,7 @@ class EditCustomListNameDialogTest { fun givenNoErrorShouldShowNoErrorMessage() = composeExtension.use { // Arrange - val state = UpdateCustomListUiState(error = null) + val state = EditCustomListNameUiState(error = null) setContentWithTheme { EditCustomListNameDialog(state = state) } // Assert @@ -44,7 +46,7 @@ class EditCustomListNameDialogTest { fun givenCustomListExistsShouldShowCustomListExitsErrorText() = composeExtension.use { // Arrange - val state = UpdateCustomListUiState(error = CustomListsError.CustomListExists) + val state = EditCustomListNameUiState(error = RenameError(NameAlreadyExists("name"))) setContentWithTheme { EditCustomListNameDialog(state = state) } // Assert @@ -56,7 +58,10 @@ class EditCustomListNameDialogTest { fun givenOtherCustomListErrorShouldShowAnErrorOccurredErrorText() = composeExtension.use { // Arrange - val state = UpdateCustomListUiState(error = CustomListsError.OtherError) + val state = + EditCustomListNameUiState( + error = RenameError(UnknownCustomListError(RuntimeException(""))) + ) setContentWithTheme { EditCustomListNameDialog(state = state) } // Assert @@ -69,7 +74,7 @@ class EditCustomListNameDialogTest { composeExtension.use { // Arrange val mockedOnDismiss: () -> Unit = mockk(relaxed = true) - val state = UpdateCustomListUiState() + val state = EditCustomListNameUiState() setContentWithTheme { EditCustomListNameDialog(state = state, onDismiss = mockedOnDismiss) } @@ -86,7 +91,7 @@ class EditCustomListNameDialogTest { composeExtension.use { // Arrange val mockedUpdateName: (String) -> Unit = mockk(relaxed = true) - val state = UpdateCustomListUiState() + val state = EditCustomListNameUiState() setContentWithTheme { EditCustomListNameDialog(state = state, updateName = mockedUpdateName) } @@ -104,7 +109,7 @@ class EditCustomListNameDialogTest { // Arrange val mockedUpdateName: (String) -> Unit = mockk(relaxed = true) val inputText = "NEW NAME" - val state = UpdateCustomListUiState() + val state = EditCustomListNameUiState() setContentWithTheme { EditCustomListNameDialog(state = state, updateName = mockedUpdateName) } @@ -123,7 +128,7 @@ class EditCustomListNameDialogTest { // Arrange val mockedOnInputChanged: () -> Unit = mockk(relaxed = true) val inputText = "NEW NAME" - val state = UpdateCustomListUiState() + val state = EditCustomListNameUiState() setContentWithTheme { EditCustomListNameDialog(state = state, onInputChanged = mockedOnInputChanged) } diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt index 0641998f9b..5fe812cd44 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt @@ -7,12 +7,12 @@ import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick -import androidx.compose.ui.test.performTextInput import io.mockk.MockKAnnotations import io.mockk.mockk import io.mockk.verify import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension import net.mullvad.mullvadvpn.compose.setContentWithTheme +import net.mullvad.mullvadvpn.viewmodel.MtuDialogUiState import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -31,13 +31,17 @@ class MtuDialogTest { @SuppressLint("ComposableNaming") @Composable private fun testMtuDialog( - mtuInitial: Int? = null, - onSaveMtu: (Int) -> Unit = { _ -> }, + mtuInput: String = "", + isValidInput: Boolean = true, + showResetButton: Boolean = true, + onInputChanged: (String) -> Unit = { _ -> }, + onSaveMtu: (String) -> Unit = { _ -> }, onResetMtu: () -> Unit = {}, onDismiss: () -> Unit = {}, ) { MtuDialog( - mtuInitial = mtuInitial, + MtuDialogUiState(mtuInput, isValidInput, showResetButton), + onInputChanged = onInputChanged, onSaveMtu = onSaveMtu, onResetMtu = onResetMtu, onDismiss = onDismiss @@ -60,36 +64,19 @@ class MtuDialogTest { // Arrange setContentWithTheme { testMtuDialog( - mtuInitial = VALID_DUMMY_MTU_VALUE, + mtuInput = VALID_DUMMY_MTU_VALUE, ) } // Assert - onNodeWithText(VALID_DUMMY_MTU_VALUE.toString()).assertExists() - } - - @Test - fun testMtuDialogTextInput() = - composeExtension.use { - // Arrange - setContentWithTheme { - testMtuDialog( - null, - ) - } - - // Act - onNodeWithText(EMPTY_STRING).performTextInput(VALID_DUMMY_MTU_VALUE.toString()) - - // Assert - onNodeWithText(VALID_DUMMY_MTU_VALUE.toString()).assertExists() + onNodeWithText(VALID_DUMMY_MTU_VALUE).assertExists() } @Test fun testMtuDialogSubmitOfValidValue() = composeExtension.use { // Arrange - val mockedSubmitHandler: (Int) -> Unit = mockk(relaxed = true) + val mockedSubmitHandler: (String) -> Unit = mockk(relaxed = true) setContentWithTheme { testMtuDialog( VALID_DUMMY_MTU_VALUE, @@ -108,11 +95,7 @@ class MtuDialogTest { fun testMtuDialogSubmitButtonDisabledWhenInvalidInput() = composeExtension.use { // Arrange - setContentWithTheme { - testMtuDialog( - INVALID_DUMMY_MTU_VALUE, - ) - } + setContentWithTheme { testMtuDialog(INVALID_DUMMY_MTU_VALUE, false) } // Assert onNodeWithText("Submit").assertIsNotEnabled() @@ -125,7 +108,7 @@ class MtuDialogTest { val mockedClickHandler: () -> Unit = mockk(relaxed = true) setContentWithTheme { testMtuDialog( - mtuInitial = VALID_DUMMY_MTU_VALUE, + mtuInput = VALID_DUMMY_MTU_VALUE, onResetMtu = mockedClickHandler, ) } @@ -157,7 +140,7 @@ class MtuDialogTest { companion object { private const val EMPTY_STRING = "" - private const val VALID_DUMMY_MTU_VALUE = 1337 - private const val INVALID_DUMMY_MTU_VALUE = 1111 + private const val VALID_DUMMY_MTU_VALUE = "1337" + private const val INVALID_DUMMY_MTU_VALUE = "1111" } } diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreenTest.kt index 851866818b..98c87114fb 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreenTest.kt @@ -20,16 +20,15 @@ import net.mullvad.mullvadvpn.compose.test.RECONNECT_BUTTON_TEST_TAG import net.mullvad.mullvadvpn.compose.test.SCROLLABLE_COLUMN_TEST_TAG import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_BUTTON_TEST_TAG import net.mullvad.mullvadvpn.compose.test.TOP_BAR_ACCOUNT_BUTTON -import net.mullvad.mullvadvpn.model.GeoIpLocation -import net.mullvad.mullvadvpn.model.TunnelState -import net.mullvad.mullvadvpn.relaylist.RelayItem +import net.mullvad.mullvadvpn.lib.model.ActionAfterDisconnect +import net.mullvad.mullvadvpn.lib.model.ErrorState +import net.mullvad.mullvadvpn.lib.model.ErrorStateCause +import net.mullvad.mullvadvpn.lib.model.GeoIpLocation +import net.mullvad.mullvadvpn.lib.model.TransportProtocol +import net.mullvad.mullvadvpn.lib.model.TunnelEndpoint +import net.mullvad.mullvadvpn.lib.model.TunnelState import net.mullvad.mullvadvpn.repository.InAppNotification import net.mullvad.mullvadvpn.ui.VersionInfo -import net.mullvad.talpid.net.TransportProtocol -import net.mullvad.talpid.net.TunnelEndpoint -import net.mullvad.talpid.tunnel.ActionAfterDisconnect -import net.mullvad.talpid.tunnel.ErrorState -import net.mullvad.talpid.tunnel.ErrorStateCause import org.joda.time.DateTime import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach @@ -78,9 +77,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connecting(null, null), - tunnelRealState = TunnelState.Connecting(null, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connecting(null, null), inAddress = null, outAddress = "", showLocation = false, @@ -112,10 +110,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = - TunnelState.Connecting(endpoint = mockTunnelEndpoint, null), - tunnelRealState = + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connecting(endpoint = mockTunnelEndpoint, null), inAddress = null, outAddress = "", @@ -147,9 +143,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connected(mockTunnelEndpoint, null), - tunnelRealState = TunnelState.Connected(mockTunnelEndpoint, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connected(mockTunnelEndpoint, null), inAddress = null, outAddress = "", showLocation = false, @@ -179,9 +174,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connected(mockTunnelEndpoint, null), - tunnelRealState = TunnelState.Connected(mockTunnelEndpoint, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connected(mockTunnelEndpoint, null), inAddress = null, outAddress = "", showLocation = false, @@ -204,19 +198,14 @@ class ConnectScreenTest { fun testDisconnectingState() { composeExtension.use { // Arrange - val mockSelectedLocation: RelayItem = mockk(relaxed = true) val mockLocationName = "Home" - every { mockSelectedLocation.locationName } returns mockLocationName setContentWithTheme { ConnectScreen( state = ConnectUiState( location = null, - selectedRelayItem = mockSelectedLocation, - tunnelUiState = - TunnelState.Disconnecting(ActionAfterDisconnect.Nothing), - tunnelRealState = - TunnelState.Disconnecting(ActionAfterDisconnect.Nothing), + selectedRelayItemTitle = mockLocationName, + tunnelState = TunnelState.Disconnecting(ActionAfterDisconnect.Nothing), inAddress = null, outAddress = "", showLocation = true, @@ -239,17 +228,14 @@ class ConnectScreenTest { fun testDisconnectedState() { composeExtension.use { // Arrange - val mockSelectedLocation: RelayItem = mockk(relaxed = true) val mockLocationName = "Home" - every { mockSelectedLocation.locationName } returns mockLocationName setContentWithTheme { ConnectScreen( state = ConnectUiState( location = null, - selectedRelayItem = mockSelectedLocation, - tunnelUiState = TunnelState.Disconnected(), - tunnelRealState = TunnelState.Disconnected(), + selectedRelayItemTitle = mockLocationName, + tunnelState = TunnelState.Disconnected(), inAddress = null, outAddress = "", showLocation = true, @@ -272,20 +258,14 @@ class ConnectScreenTest { fun testErrorStateBlocked() { composeExtension.use { // Arrange - val mockSelectedLocation: RelayItem = mockk(relaxed = true) val mockLocationName = "Home" - every { mockSelectedLocation.locationName } returns mockLocationName setContentWithTheme { ConnectScreen( state = ConnectUiState( location = null, - selectedRelayItem = mockSelectedLocation, - tunnelUiState = - TunnelState.Error( - ErrorState(ErrorStateCause.StartTunnelError, true) - ), - tunnelRealState = + selectedRelayItemTitle = mockLocationName, + tunnelState = TunnelState.Error( ErrorState(ErrorStateCause.StartTunnelError, true) ), @@ -315,20 +295,14 @@ class ConnectScreenTest { fun testErrorStateNotBlocked() { composeExtension.use { // Arrange - val mockSelectedLocation: RelayItem = mockk(relaxed = true) val mockLocationName = "Home" - every { mockSelectedLocation.locationName } returns mockLocationName setContentWithTheme { ConnectScreen( state = ConnectUiState( location = null, - selectedRelayItem = mockSelectedLocation, - tunnelUiState = - TunnelState.Error( - ErrorState(ErrorStateCause.StartTunnelError, false) - ), - tunnelRealState = + selectedRelayItemTitle = mockLocationName, + tunnelState = TunnelState.Error( ErrorState(ErrorStateCause.StartTunnelError, false) ), @@ -364,10 +338,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = - TunnelState.Disconnecting(ActionAfterDisconnect.Reconnect), - tunnelRealState = + selectedRelayItemTitle = null, + tunnelState = TunnelState.Disconnecting(ActionAfterDisconnect.Reconnect), inAddress = null, outAddress = "", @@ -393,18 +365,14 @@ class ConnectScreenTest { fun testDisconnectingBlockState() { composeExtension.use { // Arrange - val mockSelectedLocation: RelayItem = mockk(relaxed = true) val mockLocationName = "Home" - every { mockSelectedLocation.locationName } returns mockLocationName setContentWithTheme { ConnectScreen( state = ConnectUiState( location = null, - selectedRelayItem = mockSelectedLocation, - tunnelUiState = TunnelState.Disconnecting(ActionAfterDisconnect.Block), - tunnelRealState = - TunnelState.Disconnecting(ActionAfterDisconnect.Block), + selectedRelayItemTitle = mockLocationName, + tunnelState = TunnelState.Disconnecting(ActionAfterDisconnect.Block), inAddress = null, outAddress = "", showLocation = true, @@ -428,18 +396,15 @@ class ConnectScreenTest { fun testClickSelectLocationButton() { composeExtension.use { // Arrange - val mockSelectedLocation: RelayItem = mockk(relaxed = true) val mockLocationName = "Home" - every { mockSelectedLocation.name } returns mockLocationName val mockedClickHandler: () -> Unit = mockk(relaxed = true) setContentWithTheme { ConnectScreen( state = ConnectUiState( location = null, - selectedRelayItem = mockSelectedLocation, - tunnelUiState = TunnelState.Disconnected(), - tunnelRealState = TunnelState.Disconnected(), + selectedRelayItemTitle = mockLocationName, + tunnelState = TunnelState.Disconnected(), inAddress = null, outAddress = "", showLocation = false, @@ -471,9 +436,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connected(mockTunnelEndpoint, null), - tunnelRealState = TunnelState.Connected(mockTunnelEndpoint, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connected(mockTunnelEndpoint, null), inAddress = null, outAddress = "", showLocation = false, @@ -505,9 +469,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connected(mockTunnelEndpoint, null), - tunnelRealState = TunnelState.Connected(mockTunnelEndpoint, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connected(mockTunnelEndpoint, null), inAddress = null, outAddress = "", showLocation = false, @@ -538,9 +501,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Disconnected(), - tunnelRealState = TunnelState.Disconnected(), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Disconnected(), inAddress = null, outAddress = "", showLocation = false, @@ -571,9 +533,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connecting(null, null), - tunnelRealState = TunnelState.Connecting(null, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connecting(null, null), inAddress = null, outAddress = "", showLocation = false, @@ -612,9 +573,8 @@ class ConnectScreenTest { state = ConnectUiState( location = mockLocation, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connected(mockTunnelEndpoint, null), - tunnelRealState = TunnelState.Connected(mockTunnelEndpoint, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connected(mockTunnelEndpoint, null), inAddress = mockInAddress, outAddress = mockOutAddress, showLocation = false, @@ -644,18 +604,16 @@ class ConnectScreenTest { val versionInfo = VersionInfo( currentVersion = "1.0", - upgradeVersion = "1.1", - isOutdated = true, - isSupported = true + isSupported = true, + suggestedUpgradeVersion = "1.1" ) setContentWithTheme { ConnectScreen( state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connecting(null, null), - tunnelRealState = TunnelState.Connecting(null, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connecting(null, null), inAddress = null, outAddress = "", showLocation = false, @@ -680,18 +638,16 @@ class ConnectScreenTest { val versionInfo = VersionInfo( currentVersion = "1.0", - upgradeVersion = "1.1", - isOutdated = true, - isSupported = false + isSupported = false, + suggestedUpgradeVersion = "1.1" ) setContentWithTheme { ConnectScreen( state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connecting(null, null), - tunnelRealState = TunnelState.Connecting(null, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connecting(null, null), inAddress = null, outAddress = "", showLocation = false, @@ -722,9 +678,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connecting(null, null), - tunnelRealState = TunnelState.Connecting(null, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connecting(null, null), inAddress = null, outAddress = "", showLocation = false, @@ -749,10 +704,9 @@ class ConnectScreenTest { val mockedClickHandler: () -> Unit = mockk(relaxed = true) val versionInfo = VersionInfo( - currentVersion = "1.0", - upgradeVersion = "1.1", - isOutdated = true, - isSupported = false + isSupported = false, + currentVersion = "", + suggestedUpgradeVersion = "1.1" ) setContentWithTheme { ConnectScreen( @@ -760,9 +714,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connecting(null, null), - tunnelRealState = TunnelState.Connecting(null, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connecting(null, null), inAddress = null, outAddress = "", showLocation = false, @@ -794,9 +747,8 @@ class ConnectScreenTest { state = ConnectUiState( location = null, - selectedRelayItem = null, - tunnelUiState = TunnelState.Connecting(null, null), - tunnelRealState = TunnelState.Connecting(null, null), + selectedRelayItemTitle = null, + tunnelState = TunnelState.Connecting(null, null), inAddress = null, outAddress = "", showLocation = false, 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 5951550550..4f4db0a529 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 @@ -14,7 +14,7 @@ import net.mullvad.mullvadvpn.compose.setContentWithTheme import net.mullvad.mullvadvpn.compose.state.CustomListLocationsUiState import net.mullvad.mullvadvpn.compose.test.CIRCULAR_PROGRESS_INDICATOR import net.mullvad.mullvadvpn.compose.test.SAVE_BUTTON_TEST_TAG -import net.mullvad.mullvadvpn.relaylist.RelayItem +import net.mullvad.mullvadvpn.lib.model.RelayItem import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreenTest.kt index da9ed60997..bdcb796997 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreenTest.kt @@ -14,7 +14,7 @@ import net.mullvad.mullvadvpn.compose.setContentWithTheme import net.mullvad.mullvadvpn.compose.state.CustomListsUiState import net.mullvad.mullvadvpn.compose.test.CIRCULAR_PROGRESS_INDICATOR import net.mullvad.mullvadvpn.compose.test.NEW_LIST_BUTTON_TEST_TAG -import net.mullvad.mullvadvpn.relaylist.RelayItem +import net.mullvad.mullvadvpn.lib.model.CustomList import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -56,8 +56,8 @@ class CustomListsScreenTest { } // Assert - onNodeWithText(customLists[0].name).assertExists() - onNodeWithText(customLists[1].name).assertExists() + onNodeWithText(customLists[0].name.value).assertExists() + onNodeWithText(customLists[1].name.value).assertExists() } @Test @@ -87,7 +87,7 @@ class CustomListsScreenTest { // Arrange val customLists = DUMMY_CUSTOM_LISTS val clickedList = DUMMY_CUSTOM_LISTS[0] - val mockedOpenCustomList: (RelayItem.CustomList) -> Unit = mockk(relaxed = true) + val mockedOpenCustomList: (CustomList) -> Unit = mockk(relaxed = true) setContentWithTheme { CustomListsScreen( state = CustomListsUiState.Content(customLists = customLists), @@ -97,7 +97,7 @@ class CustomListsScreenTest { } // Act - onNodeWithText(clickedList.name).performClick() + onNodeWithText(clickedList.name.value).performClick() // Assert verify { mockedOpenCustomList(clickedList) } diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/EditCustomListScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/EditCustomListScreenTest.kt index f44441b536..5e57309777 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/EditCustomListScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/EditCustomListScreenTest.kt @@ -14,6 +14,8 @@ import net.mullvad.mullvadvpn.compose.state.EditCustomListState import net.mullvad.mullvadvpn.compose.test.CIRCULAR_PROGRESS_INDICATOR import net.mullvad.mullvadvpn.compose.test.DELETE_DROPDOWN_MENU_ITEM_TEST_TAG import net.mullvad.mullvadvpn.compose.test.TOP_BAR_DROPDOWN_BUTTON_TEST_TAG +import net.mullvad.mullvadvpn.lib.model.CustomListId +import net.mullvad.mullvadvpn.lib.model.CustomListName import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -64,7 +66,7 @@ class EditCustomListScreenTest { } // Assert - onNodeWithText(customList.name) + onNodeWithText(customList.name.value) } @Test @@ -91,7 +93,7 @@ class EditCustomListScreenTest { fun whenClickingOnDeleteDropdownShouldCallOnDeleteList() = composeExtension.use { // Arrange - val mockedOnDelete: (String) -> Unit = mockk(relaxed = true) + val mockedOnDelete: (CustomListName) -> Unit = mockk(relaxed = true) val customList = DUMMY_CUSTOM_LISTS[0] setContentWithTheme { EditCustomListScreen( @@ -117,7 +119,7 @@ class EditCustomListScreenTest { fun whenClickingOnNameCellShouldCallOnNameClicked() = composeExtension.use { // Arrange - val mockedOnNameClicked: (String, String) -> Unit = mockk(relaxed = true) + val mockedOnNameClicked: (CustomListId, CustomListName) -> Unit = mockk(relaxed = true) val customList = DUMMY_CUSTOM_LISTS[0] setContentWithTheme { EditCustomListScreen( @@ -132,7 +134,7 @@ class EditCustomListScreenTest { } // Act - onNodeWithText(customList.name).performClick() + onNodeWithText(customList.name.value).performClick() // Assert verify { mockedOnNameClicked(customList.id, customList.name) } @@ -142,7 +144,7 @@ class EditCustomListScreenTest { fun whenClickingOnLocationCellShouldCallOnLocationsClicked() = composeExtension.use { // Arrange - val mockedOnLocationsClicked: (String) -> Unit = mockk(relaxed = true) + val mockedOnLocationsClicked: (CustomListId) -> Unit = mockk(relaxed = true) val customList = DUMMY_CUSTOM_LISTS[0] setContentWithTheme { EditCustomListScreen( diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreenTest.kt index c57c5c3f62..b3cfd7972f 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreenTest.kt @@ -9,8 +9,9 @@ import io.mockk.verify import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension import net.mullvad.mullvadvpn.compose.setContentWithTheme import net.mullvad.mullvadvpn.compose.state.RelayFilterState -import net.mullvad.mullvadvpn.model.Ownership -import net.mullvad.mullvadvpn.relaylist.Provider +import net.mullvad.mullvadvpn.lib.model.Ownership +import net.mullvad.mullvadvpn.lib.model.Provider +import net.mullvad.mullvadvpn.lib.model.ProviderId import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -124,7 +125,8 @@ class FilterScreenTest { RelayFilterState( allProviders = listOf(), selectedOwnership = null, - selectedProviders = listOf(Provider("31173", true)) + selectedProviders = + listOf(Provider(ProviderId("31173"), Ownership.MullvadOwned)) ), onSelectedProvider = { _, _ -> }, onApplyClick = mockClickListener @@ -135,47 +137,46 @@ class FilterScreenTest { } companion object { - private val DUMMY_RELAY_ALL_PROVIDERS = listOf( - Provider("31173", true), - Provider("100TB", false), - Provider("Blix", true), - Provider("Creanova", true), - Provider("DataPacket", false), - Provider("HostRoyale", false), - Provider("hostuniversal", false), - Provider("iRegister", false), - Provider("M247", false), - Provider("Makonix", false), - Provider("PrivateLayer", false), - Provider("ptisp", false), - Provider("Qnax", false), - Provider("Quadranet", false), - Provider("techfutures", false), - Provider("Tzulo", false), - Provider("xtom", false) + Provider(ProviderId("31173"), Ownership.MullvadOwned), + Provider(ProviderId("100TB"), Ownership.Rented), + Provider(ProviderId("Blix"), Ownership.MullvadOwned), + Provider(ProviderId("Creanova"), Ownership.MullvadOwned), + Provider(ProviderId("DataPacket"), Ownership.Rented), + Provider(ProviderId("HostRoyale"), Ownership.Rented), + Provider(ProviderId("hostuniversal"), Ownership.Rented), + Provider(ProviderId("iRegister"), Ownership.Rented), + Provider(ProviderId("M247"), Ownership.Rented), + Provider(ProviderId("Makonix"), Ownership.Rented), + Provider(ProviderId("PrivateLayer"), Ownership.Rented), + Provider(ProviderId("ptisp"), Ownership.Rented), + Provider(ProviderId("Qnax"), Ownership.Rented), + Provider(ProviderId("Quadranet"), Ownership.Rented), + Provider(ProviderId("techfutures"), Ownership.Rented), + Provider(ProviderId("Tzulo"), Ownership.Rented), + Provider(ProviderId("xtom"), Ownership.Rented) ) private val DUMMY_SELECTED_PROVIDERS = listOf( - Provider("31173", true), - Provider("100TB", false), - Provider("Blix", true), - Provider("Creanova", true), - Provider("DataPacket", false), - Provider("HostRoyale", false), - Provider("hostuniversal", false), - Provider("iRegister", false), - Provider("M247", false), - Provider("Makonix", false), - Provider("PrivateLayer", false), - Provider("ptisp", false), - Provider("Qnax", false), - Provider("Quadranet", false), - Provider("techfutures", false), - Provider("Tzulo", false), - Provider("xtom", false) + Provider(ProviderId("31173"), Ownership.MullvadOwned), + Provider(ProviderId("100TB"), Ownership.Rented), + Provider(ProviderId("Blix"), Ownership.MullvadOwned), + Provider(ProviderId("Creanova"), Ownership.MullvadOwned), + Provider(ProviderId("DataPacket"), Ownership.Rented), + Provider(ProviderId("HostRoyale"), Ownership.Rented), + Provider(ProviderId("hostuniversal"), Ownership.Rented), + Provider(ProviderId("iRegister"), Ownership.Rented), + Provider(ProviderId("M247"), Ownership.Rented), + Provider(ProviderId("Makonix"), Ownership.Rented), + Provider(ProviderId("PrivateLayer"), Ownership.Rented), + Provider(ProviderId("ptisp"), Ownership.Rented), + Provider(ProviderId("Qnax"), Ownership.Rented), + Provider(ProviderId("Quadranet"), Ownership.Rented), + Provider(ProviderId("techfutures"), Ownership.Rented), + Provider(ProviderId("Tzulo"), Ownership.Rented), + Provider(ProviderId("xtom"), Ownership.Rented) ) } } diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/OutOfTimeScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/OutOfTimeScreenTest.kt index f54944356f..7dc378261d 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/OutOfTimeScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/OutOfTimeScreenTest.kt @@ -13,11 +13,11 @@ import net.mullvad.mullvadvpn.compose.setContentWithTheme import net.mullvad.mullvadvpn.compose.state.OutOfTimeUiState import net.mullvad.mullvadvpn.compose.state.PaymentState import net.mullvad.mullvadvpn.compose.test.PLAY_PAYMENT_INFO_ICON_TEST_TAG +import net.mullvad.mullvadvpn.lib.model.TunnelState import net.mullvad.mullvadvpn.lib.payment.model.PaymentProduct import net.mullvad.mullvadvpn.lib.payment.model.PaymentStatus import net.mullvad.mullvadvpn.lib.payment.model.ProductId import net.mullvad.mullvadvpn.lib.payment.model.ProductPrice -import net.mullvad.mullvadvpn.model.TunnelState import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/RedeemVoucherDialogTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/RedeemVoucherDialogTest.kt index b3ac57d95c..d8159dafd0 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/RedeemVoucherDialogTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/RedeemVoucherDialogTest.kt @@ -14,6 +14,7 @@ import net.mullvad.mullvadvpn.compose.setContentWithTheme import net.mullvad.mullvadvpn.compose.state.VoucherDialogState import net.mullvad.mullvadvpn.compose.state.VoucherDialogUiState import net.mullvad.mullvadvpn.compose.test.VOUCHER_INPUT_TEST_TAG +import net.mullvad.mullvadvpn.lib.model.RedeemVoucherError import net.mullvad.mullvadvpn.util.VoucherRegexHelper import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -133,7 +134,8 @@ class RedeemVoucherDialogTest { RedeemVoucherDialog( state = VoucherDialogUiState( - voucherState = VoucherDialogState.Error(ERROR_MESSAGE) + voucherState = + VoucherDialogState.Error(RedeemVoucherError.InvalidVoucher) ), onVoucherInputChange = {}, onRedeem = {}, @@ -142,13 +144,13 @@ class RedeemVoucherDialogTest { } // Assert - onNodeWithText(ERROR_MESSAGE).assertExists() + onNodeWithText(VOUCHER_CODE_INVALID_ERROR_MESSAGE).assertExists() } companion object { private const val CANCEL_BUTTON_TEXT = "Cancel" private const val GOT_IT_BUTTON_TEXT = "Got it!" private const val DUMMY_VOUCHER = "DUMMY____VOUCHER" - private const val ERROR_MESSAGE = "error_message" + private const val VOUCHER_CODE_INVALID_ERROR_MESSAGE = "Voucher code is invalid." } } 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 28651c3852..4fcee479d6 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 @@ -9,16 +9,16 @@ import io.mockk.MockKAnnotations import io.mockk.mockk import io.mockk.verify import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension -import net.mullvad.mullvadvpn.compose.data.DUMMY_CUSTOM_LISTS 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.SelectLocationUiState import net.mullvad.mullvadvpn.compose.test.CIRCULAR_PROGRESS_INDICATOR import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_CUSTOM_LIST_BOTTOM_SHEET_TEST_TAG import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_CUSTOM_LIST_HEADER_TEST_TAG import net.mullvad.mullvadvpn.compose.test.SELECT_LOCATION_LOCATION_BOTTOM_SHEET_TEST_TAG +import net.mullvad.mullvadvpn.lib.model.RelayItem import net.mullvad.mullvadvpn.performLongClick -import net.mullvad.mullvadvpn.relaylist.RelayItem import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -96,7 +96,7 @@ class SelectLocationScreenTest { customLists = emptyList(), filteredCustomLists = emptyList(), countries = updatedDummyList, - selectedItem = updatedDummyList[0].cities[0].relays[0], + selectedItem = updatedDummyList[0].cities[0].relays[0].id, selectedOwnership = null, selectedProvidersCount = 0, searchTerm = "" @@ -202,7 +202,7 @@ class SelectLocationScreenTest { SelectLocationScreen( state = SelectLocationUiState.Content( - customLists = DUMMY_CUSTOM_LISTS, + customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, filteredCustomLists = emptyList(), countries = emptyList(), selectedItem = null, @@ -222,14 +222,14 @@ class SelectLocationScreenTest { fun whenCustomListIsClickedShouldCallOnSelectRelay() = composeExtension.use { // Arrange - val customList = DUMMY_CUSTOM_LISTS[0] + val customList = DUMMY_RELAY_ITEM_CUSTOM_LISTS[0] val mockedOnSelectRelay: (RelayItem) -> Unit = mockk(relaxed = true) setContentWithTheme { SelectLocationScreen( state = SelectLocationUiState.Content( - customLists = DUMMY_CUSTOM_LISTS, - filteredCustomLists = DUMMY_CUSTOM_LISTS, + customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + filteredCustomLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, countries = emptyList(), selectedItem = null, selectedOwnership = null, @@ -251,14 +251,14 @@ class SelectLocationScreenTest { fun whenCustomListIsLongClickedShouldShowBottomSheet() = composeExtension.use { // Arrange - val customList = DUMMY_CUSTOM_LISTS[0] + val customList = DUMMY_RELAY_ITEM_CUSTOM_LISTS[0] val mockedOnSelectRelay: (RelayItem) -> Unit = mockk(relaxed = true) setContentWithTheme { SelectLocationScreen( state = SelectLocationUiState.Content( - customLists = DUMMY_CUSTOM_LISTS, - filteredCustomLists = DUMMY_CUSTOM_LISTS, + customLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, + filteredCustomLists = DUMMY_RELAY_ITEM_CUSTOM_LISTS, countries = emptyList(), selectedItem = null, selectedOwnership = null, diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt index 471e39c38f..ca7a01a0a9 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreenTest.kt @@ -20,10 +20,11 @@ import net.mullvad.mullvadvpn.compose.test.LAZY_LIST_TEST_TAG import net.mullvad.mullvadvpn.compose.test.LAZY_LIST_WIREGUARD_CUSTOM_PORT_NUMBER_TEST_TAG import net.mullvad.mullvadvpn.compose.test.LAZY_LIST_WIREGUARD_CUSTOM_PORT_TEXT_TEST_TAG import net.mullvad.mullvadvpn.compose.test.LAZY_LIST_WIREGUARD_PORT_ITEM_X_TEST_TAG -import net.mullvad.mullvadvpn.model.Constraint -import net.mullvad.mullvadvpn.model.Port -import net.mullvad.mullvadvpn.model.PortRange -import net.mullvad.mullvadvpn.model.QuantumResistantState +import net.mullvad.mullvadvpn.lib.model.Constraint +import net.mullvad.mullvadvpn.lib.model.Mtu +import net.mullvad.mullvadvpn.lib.model.Port +import net.mullvad.mullvadvpn.lib.model.PortRange +import net.mullvad.mullvadvpn.lib.model.QuantumResistantState import net.mullvad.mullvadvpn.onNodeWithTagAndText import net.mullvad.mullvadvpn.viewmodel.CustomDnsItem import org.junit.jupiter.api.BeforeEach @@ -49,7 +50,7 @@ class VpnSettingsScreenTest { ) } - apply { onNodeWithText("Auto-connect").assertExists() } + onNodeWithText("Auto-connect").assertExists() onNodeWithTag(LAZY_LIST_TEST_TAG) .performScrollToNode(hasTestTag(LAZY_LIST_LAST_ITEM_TEST_TAG)) @@ -67,7 +68,10 @@ class VpnSettingsScreenTest { // Arrange setContentWithTheme { VpnSettingsScreen( - state = VpnSettingsUiState.createDefault(mtu = VALID_DUMMY_MTU_VALUE), + state = + VpnSettingsUiState.createDefault( + mtu = Mtu.fromString(VALID_DUMMY_MTU_VALUE).getOrNull()!! + ), ) } @@ -360,7 +364,7 @@ class VpnSettingsScreenTest { fun testMtuClick() = composeExtension.use { // Arrange - val mockedClickHandler: (Int?) -> Unit = mockk(relaxed = true) + val mockedClickHandler: (Mtu?) -> Unit = mockk(relaxed = true) setContentWithTheme { VpnSettingsScreen( state = VpnSettingsUiState.createDefault(), diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/WelcomeScreenTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/WelcomeScreenTest.kt index d8711b4b61..d60a7b100b 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/WelcomeScreenTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/screen/WelcomeScreenTest.kt @@ -13,6 +13,7 @@ import net.mullvad.mullvadvpn.compose.setContentWithTheme import net.mullvad.mullvadvpn.compose.state.PaymentState import net.mullvad.mullvadvpn.compose.state.WelcomeUiState import net.mullvad.mullvadvpn.compose.test.PLAY_PAYMENT_INFO_ICON_TEST_TAG +import net.mullvad.mullvadvpn.lib.model.AccountToken import net.mullvad.mullvadvpn.lib.payment.model.PaymentProduct import net.mullvad.mullvadvpn.lib.payment.model.PaymentStatus import net.mullvad.mullvadvpn.lib.payment.model.ProductId @@ -82,7 +83,7 @@ class WelcomeScreenTest { fun testShowAccountNumber() = composeExtension.use { // Arrange - val rawAccountNumber = "1111222233334444" + val rawAccountNumber = AccountToken("1111222233334444") val expectedAccountNumber = "1111 2222 3333 4444" setContentWithTheme { WelcomeScreen( |
