From 528c5a3671ffd1cf3fab5806f709f9819d5f5719 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 8 Nov 2021 17:08:53 +0000 Subject: [PATCH] adding warning when the signout flow is unexpected --- .../java/im/vector/app/ui/UiAllScreensSanityTest.kt | 4 ++-- .../java/im/vector/app/ui/robot/ElementRobot.kt | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) 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"