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
This commit is contained in:
Jonathan Rainville 2023-01-26 12:14:10 -05:00
parent 03095f995e
commit 7a3a984fa4
8 changed files with 32 additions and 39 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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)

View File

@ -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)

View File

@ -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}

View File

@ -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
}
}