Skip to content

Commit

Permalink
Merge branch 'automate-logout-tests-using-mockapi-droid-590'
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-mullvad committed Dec 29, 2023
2 parents 2e540a6 + 0e061a3 commit 6d9b4b1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class AppInteractor(private val device: UiDevice, private val targetContext: Con
device.findObjectWithTimeout(By.res(SETTINGS_COG_ID)).click()
}

fun clickAccountCog() {
device.findObjectWithTimeout(By.res("top_bar_account_button")).click()
}

fun clickListItemByText(text: String) {
device.findObjectWithTimeout(By.text(text)).click()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package net.mullvad.mullvadvpn.test.mockapi

import androidx.test.runner.AndroidJUnit4
import androidx.test.uiautomator.By
import junit.framework.TestCase.assertNotNull
import net.mullvad.mullvadvpn.test.common.extension.clickAgreeOnPrivacyDisclaimer
import net.mullvad.mullvadvpn.test.common.extension.clickAllowOnNotificationPermissionPromptIfApiLevel33AndAbove
import net.mullvad.mullvadvpn.test.common.extension.dismissChangelogDialogIfShown
import net.mullvad.mullvadvpn.test.common.extension.findObjectWithTimeout
import net.mullvad.mullvadvpn.test.mockapi.util.currentUtcTimeWithOffsetZero
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class LogoutMockApiTest : MockApiTest() {

@Test
fun testLoginWithValidCredentialsToUnexpiredAccountAndLogout() {
// Arrange
val validAccountToken = "1234123412341234"
apiDispatcher.apply {
expectedAccountToken = validAccountToken
accountExpiry = currentUtcTimeWithOffsetZero().plusMonths(1)
}

// Act
app.launch(endpoint)
device.clickAgreeOnPrivacyDisclaimer()
device.clickAllowOnNotificationPermissionPromptIfApiLevel33AndAbove()
device.dismissChangelogDialogIfShown()
app.waitForLoginPrompt()
app.attemptLogin(validAccountToken)
device.findObjectWithTimeout(By.text("UNSECURED CONNECTION"))
app.clickAccountCog()
app.clickActionButtonByText("Log out")

// Assert
assertNotNull(device.findObjectWithTimeout(By.text("Login")))
}
}

0 comments on commit 6d9b4b1

Please sign in to comment.