Skip to content

Commit

Permalink
Add ui test for disconnect button
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Jun 18, 2024
1 parent 3fe6361 commit c5b8824
Showing 1 changed file with 51 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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.AccountNumber
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
Expand Down Expand Up @@ -44,7 +45,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand All @@ -66,7 +68,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand Down Expand Up @@ -94,7 +97,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand All @@ -116,7 +120,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand All @@ -141,7 +146,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand All @@ -165,7 +171,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand Down Expand Up @@ -193,7 +200,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand Down Expand Up @@ -222,7 +230,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand Down Expand Up @@ -252,7 +261,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToVerificationPendingDialog = mockShowPendingInfo,
navigateToDeviceInfoDialog = {}
navigateToDeviceInfoDialog = {},
onDisconnectClick = {}
)
}

Expand Down Expand Up @@ -284,7 +294,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = { _ -> },
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand Down Expand Up @@ -314,7 +325,8 @@ class WelcomeScreenTest {
onAccountClick = {},
onPurchaseBillingProductClick = clickHandler,
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {}
navigateToVerificationPendingDialog = {},
onDisconnectClick = {}
)
}

Expand All @@ -324,4 +336,32 @@ class WelcomeScreenTest {
// Assert
verify { clickHandler(ProductId("PRODUCT_ID")) }
}

@Test
fun testOnDisconnectClick() =
composeExtension.use {
// Arrange
val clickHandler: () -> Unit = mockk(relaxed = true)
val tunnelState: TunnelState = mockk(relaxed = true)
every { tunnelState.showDisconnectButton() } returns true
setContentWithTheme {
WelcomeScreen(
state = WelcomeUiState(tunnelState = tunnelState),
onSitePaymentClick = {},
onRedeemVoucherClick = {},
onSettingsClick = {},
onAccountClick = {},
onPurchaseBillingProductClick = {},
navigateToDeviceInfoDialog = {},
navigateToVerificationPendingDialog = {},
onDisconnectClick = clickHandler
)
}

// Act
onNodeWithText("Disconnect").performClick()

// Assert
verify { clickHandler() }
}
}

0 comments on commit c5b8824

Please sign in to comment.