diff --git a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt index c9c41776c5..d80f11e975 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt @@ -80,12 +80,12 @@ class UiAllScreensSanityTest { verifyCreatedRoom() } - elementRobot.signout() + elementRobot.signout(expectSignOutWarning = true) // Login again on the same account elementRobot.login(userId) elementRobot.dismissVerificationIfPresent() // TODO Deactivate account instead of logout? - elementRobot.signout() + elementRobot.signout(expectSignOutWarning = false) } } diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index 9fc87a4e9e..e904ce1c80 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -95,15 +95,19 @@ class ElementRobot { waitUntilViewVisible(withId(R.id.bottomNavigationView)) } - fun signout() { + fun signout(expectSignOutWarning: Boolean) { clickOn(R.id.groupToolbarAvatarImageView) clickOn(R.id.homeDrawerHeaderSignoutView) - val hasSentMessages = kotlin.runCatching { + val isShowingSignOutWarning = kotlin.runCatching { waitUntilViewVisible(withId(R.id.exitAnywayButton)) }.isSuccess - if (hasSentMessages) { + if (expectSignOutWarning != isShowingSignOutWarning) { + Timber.w("Unexpected sign out flow, expected warning to be: ${expectSignOutWarning.toWarningType()} but was ${isShowingSignOutWarning.toWarningType()}") + } + + if (isShowingSignOutWarning) { // We have sent a message in a e2e room, accept to loose it clickOn(R.id.exitAnywayButton) // Dark pattern @@ -135,3 +139,5 @@ class ElementRobot { }.onFailure { Timber.w("Verification popup missing", it) } } } + +private fun Boolean.toWarningType() = if (this) "shown" else "skipped"