Skip to content

Commit

Permalink
PIA-696 - Add helper to navigate back to the Main Screen (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
kp-andrei-madescu authored Oct 11, 2023
1 parent 47abbaf commit 75e958b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion app/src/androidTest/java/helpers/ActionHelpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.privateinternetaccess.android.helpers

import androidx.test.uiautomator.UiObject
import com.privateinternetaccess.android.core.BaseUiAutomatorClass.Companion.defaultTimeOut
import com.privateinternetaccess.android.screens.objects.MainScreenPageObjects
import com.privateinternetaccess.android.screens.steps.GeneralStepObjects
import com.privateinternetaccess.android.screens.steps.SideMenuStepObjects
import com.privateinternetaccess.android.screens.steps.SignInStepObjects
import com.privateinternetaccess.android.screens.steps.MainScreenStepObjects
Expand All @@ -15,7 +17,6 @@ object ActionHelpers {
}

fun <T> inputTextInField(field: UiObject, data: T? = null) {
field.clearTextField()
field.click()
field.text = data?.toString() ?: ""
}
Expand All @@ -40,4 +41,10 @@ object ActionHelpers {
MainScreenStepObjects().clickOnHamburgerMenu()
SideMenuStepObjects().clickOnLogout()
}

fun returnOnMainScreen() {
while (!MainScreenPageObjects().connectButton.exists()) {
GeneralStepObjects().clickOnBackArrow()
}
}
}
6 changes: 3 additions & 3 deletions app/src/androidTest/java/tests/SignOutTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import com.privateinternetaccess.android.core.BaseUiAutomatorClass
import com.privateinternetaccess.android.helpers.ActionHelpers.successfulLogin
import com.privateinternetaccess.android.helpers.ActionHelpers.goToSettings
import com.privateinternetaccess.android.helpers.ActionHelpers.successfulLgout
import com.privateinternetaccess.android.helpers.ActionHelpers.returnOnMainScreen
import com.privateinternetaccess.android.screens.objects.SettingsPageObjects
import com.privateinternetaccess.android.screens.steps.GeneralStepObjects
import com.privateinternetaccess.android.screens.objects.GeneralPageObjects

import org.junit.Test

class SignOutTests : BaseUiAutomatorClass() {

private val settingsPageObjects = SettingsPageObjects()
private val generalStepObjects = GeneralStepObjects()

@Test
fun validatingDefaultSettingsAfterLogout() {
successfulLogin()
goToSettings(settingsPageObjects.general)
generalStepObjects.launchOnSystemStartUp()
generalStepObjects.clickOnBackArrow()
generalStepObjects.clickOnBackArrow()
returnOnMainScreen()
successfulLgout()
successfulLogin()
goToSettings(settingsPageObjects.general)
Expand Down

0 comments on commit 75e958b

Please sign in to comment.