From 7a3a984fa4090e0431502727dd27ef3ba2fa1b6d Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 26 Jan 2023 12:14:10 -0500 Subject: [PATCH] test(env-var): add TEST_ENVIRONMENT env var for test specific changes Fixes #9210 Adds the `TEST_ENVIRONMENT` that stops banners from showing and touch id to be activated (needs to be tested by someone on Mac). Also improves the waiting time on verifying screens. Will undo that change if it becomes flaky. To make sure your local tests still work well and hide the banner as well, make sure to put `TEST_ENVIRONMENT=1` in the suite settings' env vars --- ci/Jenkinsfile.e2e | 1 + src/app/global/local_account_settings.nim | 2 +- src/app/global/local_app_settings.nim | 7 ++++ src/constants.nim | 3 ++ .../src/drivers/SquishDriverVerification.py | 2 +- test/ui-test/src/screens/StatusMainScreen.py | 32 ++----------------- .../global_shared/scripts/global_names.py | 4 --- ui/imports/shared/panels/ModuleWarning.qml | 20 ++++++++++-- 8 files changed, 32 insertions(+), 39 deletions(-) diff --git a/ci/Jenkinsfile.e2e b/ci/Jenkinsfile.e2e index e49d453cfa..494d073dca 100644 --- a/ci/Jenkinsfile.e2e +++ b/ci/Jenkinsfile.e2e @@ -58,6 +58,7 @@ pipeline { /* Ganache config */ GANACHE_RPC_PORT = "${9545 + env.EXECUTOR_NUMBER.toInteger()}" GANACHE_MNEMONIC = 'pelican chief sudden oval media rare swamp elephant lawsuit wheat knife initial' + TEST_ENVIRONMENT = '1' } stages { diff --git a/src/app/global/local_account_settings.nim b/src/app/global/local_account_settings.nim index 38d3e141a0..6a6598ccf0 100644 --- a/src/app/global/local_account_settings.nim +++ b/src/app/global/local_account_settings.nim @@ -46,7 +46,7 @@ QtObject: self.storeToKeychainValueChanged() proc getStoreToKeychainValue*(self: LocalAccountSettings): string {.slot.} = - if(self.settings.isNil): + if(self.settings.isNil or existsEnv(TEST_ENVIRONMENT_VAR)): return DEFAULT_STORE_TO_KEYCHAIN self.settings.value(LS_KEY_STORE_TO_KEYCHAIN).stringVal diff --git a/src/app/global/local_app_settings.nim b/src/app/global/local_app_settings.nim index 1c74b7ae10..1b3342836d 100644 --- a/src/app/global/local_app_settings.nim +++ b/src/app/global/local_app_settings.nim @@ -93,3 +93,10 @@ QtObject: of LAS_KEY_THEME: self.themeChanged() of LAS_KEY_GEOMETRY: self.geometryChanged() of LAS_KEY_VISIBILITY: self.visibilityChanged() + + + proc getTestEnvironment*(self: LocalAppSettings): bool {.slot.} = + return existsEnv(TEST_ENVIRONMENT_VAR) + + QtProperty[bool] testEnvironment: + read = getTestEnvironment \ No newline at end of file diff --git a/src/constants.nim b/src/constants.nim index 908215dd28..c5437567e7 100644 --- a/src/constants.nim +++ b/src/constants.nim @@ -74,3 +74,6 @@ proc ensureDirectories*(dataDir, tmpDir, logDir: string) = const DESKTOP_VERSION* {.strdefine.} = "0.0.0" # This is changed during compilation by executing git command const GIT_COMMIT* {.strdefine.} = "" + +# Name of the test environment var to check for +const TEST_ENVIRONMENT_VAR* = "TEST_ENVIRONMENT" \ No newline at end of file diff --git a/test/ui-test/src/drivers/SquishDriverVerification.py b/test/ui-test/src/drivers/SquishDriverVerification.py index d15e4f63d7..bfd9342ba3 100644 --- a/test/ui-test/src/drivers/SquishDriverVerification.py +++ b/test/ui-test/src/drivers/SquishDriverVerification.py @@ -14,7 +14,7 @@ _MIN_WAIT_OBJ_TIMEOUT = 500 # The default maximum timeout to wait for close the app in seconds _MAX_WAIT_CLOSE_APP_TIMEOUT = 20 -def verify_screen(objName: str, timeout: int=_MAX_WAIT_OBJ_TIMEOUT): +def verify_screen(objName: str, timeout: int=1000): result = is_loaded_visible_and_enabled(objName, timeout) test.verify(result, True) diff --git a/test/ui-test/src/screens/StatusMainScreen.py b/test/ui-test/src/screens/StatusMainScreen.py index 65c93aaa87..d3f92b6594 100644 --- a/test/ui-test/src/screens/StatusMainScreen.py +++ b/test/ui-test/src/screens/StatusMainScreen.py @@ -29,10 +29,6 @@ class MainScreenComponents(Enum): CHAT_LIST = "chatList" MARK_AS_READ_BUTTON = "mark_as_Read_StatusMenuItem" COMMUNITY_NAVBAR_BUTTONS = "navBarListView_All_Community_Buttons" - SECURE_SEEDPHRASE_BANNER = "secureSeedPhrase_Banner" - CONNECTION_INFO_BANNER = "connectionInfo_Banner" - UPDATE_APP_BANNER = "appVersionUpdate_Banner" - TESTNET_INFO_BANNER = "testnetInfo_Banner" PROFILE_SETTINGS_VIEW = "mainWindow_ProfileSettingsView" PROFILE_NAVBAR_BUTTON = "mainWindow_ProfileNavBarButton" USERSTATUSMENU_ALWAYS_ACTIVE_ACTION = "userContextmenu_AlwaysActiveButton" @@ -60,10 +56,9 @@ class StatusMainScreen: def __init__(self): verify_screen(MainScreenComponents.CONTACTS_COLUMN_MESSAGES_HEADLINE.value) - # Main screen is ready to interact with it (Splash screen animation not present and no banners on top of the screen) + # Main screen is ready to interact with it (Splash screen animation not present) def is_ready(self): self.wait_for_splash_animation_ends() - self.close_banners() verify(is_displayed(MainScreenComponents.CONTACTS_COLUMN_MESSAGES_HEADLINE.value), "Verifying if the Messages headline is displayed") def wait_for_splash_animation_ends(self, timeoutMSec: int = 10000): @@ -71,32 +66,9 @@ class StatusMainScreen: [loaded, obj] = is_loaded_visible_and_enabled(MainScreenComponents.SPLASH_SCREEN.value) while loaded and (start + timeoutMSec / 1000 > time.time()): log("Splash screen animation present!") - [loaded, obj] = is_loaded_visible_and_enabled(MainScreenComponents.SPLASH_SCREEN.value) + [loaded, obj] = is_loaded_visible_and_enabled(MainScreenComponents.SPLASH_SCREEN.value, 1000) sleep_test(0.5) verify_equal(loaded, False, "Checking splash screen animation has ended.") - - # It closes all existing banner and waits them to disappear: - def close_banners(self): - self.wait_for_banner_to_disappear(MainScreenComponents.CONNECTION_INFO_BANNER.value) - self.wait_for_banner_to_disappear(MainScreenComponents.UPDATE_APP_BANNER.value) - self.wait_for_banner_to_disappear(MainScreenComponents.SECURE_SEEDPHRASE_BANNER.value) - - # Close banner and wait to disappear otherwise the click might land badly - def wait_for_banner_to_disappear(self, banner_type: str, timeoutMSec: int = 3000): - start = time.time() - while(start + timeoutMSec / 1000 > time.time()): - try: - obj = get_obj(banner_type) - if not obj.visible: - log("Banner object not visible") - return - obj.close() - log("Closed banner: " + banner_type) - except: - log("Banner object not found") - return - sleep_test(0.5) - verify_failure(f"Banner is still visible after {timeoutMSec}ms") def open_chat_section(self): click_obj_by_name(MainScreenComponents.CHAT_NAVBAR_ICON.value) diff --git a/test/ui-test/testSuites/global_shared/scripts/global_names.py b/test/ui-test/testSuites/global_shared/scripts/global_names.py index 982d7cb469..f1bb7719a5 100644 --- a/test/ui-test/testSuites/global_shared/scripts/global_names.py +++ b/test/ui-test/testSuites/global_shared/scripts/global_names.py @@ -4,10 +4,6 @@ statusDesktop_mainWindow_overlay = {"container": statusDesktop_mainWindow, "type mainWindow_navBarListView_ListView = {"container": statusDesktop_mainWindow, "objectName": "statusMainNavBarListView", "type": "ListView", "visible": True} mainWindow_communityNavBarListView_ListView = {"container": statusDesktop_mainWindow, "objectName": "statusCommunityMainNavBarListView", "type": "ListView", "visible": True} chatView_log = {"container": statusDesktop_mainWindow, "objectName": "chatLogView", "type": "StatusListView", "visible": True} -secureSeedPhrase_Banner = {"container": statusDesktop_mainWindow, "objectName": "secureYourSeedPhraseBanner", "type": "ModuleWarning"} -connectionInfo_Banner = {"container": statusDesktop_mainWindow, "objectName": "connectionInfoBanner", "type": "ModuleWarning"} -appVersionUpdate_Banner = {"container": statusDesktop_mainWindow, "objectName": "appVersionUpdateBanner", "type": "ModuleWarning"} -testnetInfo_Banner = {"container": statusDesktop_mainWindow, "objectName": "testnetBanner", "type": "ModuleWarning"} statusDesktop_mainWindow_AppMain_EmojiPopup_SearchTextInput = {"container": statusDesktop_mainWindow_overlay, "objectName": "StatusEmojiPopup_searchBox", "type": "TextEdit", "visible": True} mainWindow_ScrollView = {"container": statusDesktop_mainWindow, "type": "StatusScrollView", "unnamed": 1, "visible": True} mainWindow_ScrollView_2 = {"container": statusDesktop_mainWindow, "occurrence": 2, "type": "StatusScrollView", "unnamed": 1, "visible": True} diff --git a/ui/imports/shared/panels/ModuleWarning.qml b/ui/imports/shared/panels/ModuleWarning.qml index 858a8565cb..37df010684 100644 --- a/ui/imports/shared/panels/ModuleWarning.qml +++ b/ui/imports/shared/panels/ModuleWarning.qml @@ -30,9 +30,18 @@ Item { signal hideStarted() signal hideFinished() + QtObject { + id: d + property bool active: false + } + function show() { + if (localAppSettings.testEnvironment) { + // Never show the banner while in a test enviornment + return + } hideTimer.stop() - active = true; + d.active = true; } function showFor(duration = 5000) { @@ -51,10 +60,15 @@ Item { signal linkActivated(string link) - implicitHeight: root.active ? content.implicitHeight : 0 + implicitHeight: d.active ? content.implicitHeight : 0 visible: implicitHeight > 0 onActiveChanged: { + if (localAppSettings.testEnvironment) { + // Never show the banner while in a test enviornment + return + } + d.active = active active ? showAnimation.start() : hideAnimation.start() } @@ -95,7 +109,7 @@ Item { repeat: false running: false onTriggered: { - root.active = false + d.active = false } }