Skip to content

Commit

Permalink
test(env-var): add TEST_ENVIRONMENT env var for test specific changes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jrainville committed Jan 27, 2023
1 parent 03095f9 commit 7a3a984
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 39 deletions.
1 change: 1 addition & 0 deletions ci/Jenkinsfile.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/app/global/local_account_settings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/app/global/local_app_settings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion test/ui-test/src/drivers/SquishDriverVerification.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# 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)

Expand Down
32 changes: 2 additions & 30 deletions test/ui-test/src/screens/StatusMainScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -60,43 +56,19 @@ 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):
start = time.time()
[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)
Expand Down
4 changes: 0 additions & 4 deletions test/ui-test/testSuites/global_shared/scripts/global_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
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}
Expand Down
20 changes: 17 additions & 3 deletions ui/imports/shared/panels/ModuleWarning.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()
}

Expand Down Expand Up @@ -95,7 +109,7 @@ Item {
repeat: false
running: false
onTriggered: {
root.active = false
d.active = false
}
}

Expand Down

0 comments on commit 7a3a984

Please # to comment.