From ac935b00d7158e428e979494395c8f388c70a97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 11 Oct 2023 19:00:30 +0200 Subject: [PATCH] chore(e2e): rename TEST_ENVIRONMENT to STATUS_RUNTIME_TEST_MODE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because the environment variable name is far too generic and barely means anything. It needs to clearly indicate that it's supposed to be used at runtime and it changes how the Status app behaves. Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.tests-e2e | 3 ++- src/app/global/local_account_settings.nim | 2 +- src/app/global/local_app_settings.nim | 5 ++--- src/constants.nim | 5 ++++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ci/Jenkinsfile.tests-e2e b/ci/Jenkinsfile.tests-e2e index 43364483ef..80ca8a27db 100644 --- a/ci/Jenkinsfile.tests-e2e +++ b/ci/Jenkinsfile.tests-e2e @@ -77,7 +77,8 @@ 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' + /* Runtime flag to make testing of the app easier. */ + STATUS_RUNTIME_TEST_MODE = '1' } stages { diff --git a/src/app/global/local_account_settings.nim b/src/app/global/local_account_settings.nim index 6a6598ccf0..794b818ab7 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 or existsEnv(TEST_ENVIRONMENT_VAR)): + if self.settings.isNil or TEST_MODE_ENABLED: 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 324724a1e4..69afb3b14c 100644 --- a/src/app/global/local_app_settings.nim +++ b/src/app/global/local_app_settings.nim @@ -17,7 +17,7 @@ const LAS_KEY_CUSTOM_MOUSE_SCROLLING_ENABLED = "global/custom_mouse_scroll_enabl const DEFAULT_CUSTOM_MOUSE_SCROLLING_ENABLED = false const DEFAULT_VISIBILITY = 2 #windowed visibility, from qml const LAS_KEY_FAKE_LOADING_SCREEN_ENABLED = "global/fake_loading_screen" -const DEFAULT_FAKE_LOADING_SCREEN_ENABLED = defined(production) and (not existsEnv(TEST_ENVIRONMENT_VAR)) #enabled in production, disabled in development and e2e tests +const DEFAULT_FAKE_LOADING_SCREEN_ENABLED = defined(production) and not TEST_MODE_ENABLED #enabled in production, disabled in development and e2e tests const LAS_KEY_SHARDED_COMMUNITIES_ENABLED = "global/sharded_communities" const DEFAULT_LAS_KEY_SHARDED_COMMUNITIES_ENABLED = false @@ -144,8 +144,7 @@ QtObject: proc getTestEnvironment*(self: LocalAppSettings): bool {.slot.} = - let value = getEnv(TEST_ENVIRONMENT_VAR) - return value.toUpperAscii() == "TRUE" or value == "1" + return TEST_MODE_ENABLED QtProperty[bool] testEnvironment: read = getTestEnvironment diff --git a/src/constants.nim b/src/constants.nim index f5db547643..91d3db16ca 100644 --- a/src/constants.nim +++ b/src/constants.nim @@ -88,4 +88,7 @@ const GIT_COMMIT* {.strdefine.} = "" const APP_VERSION* = if defined(production): DESKTOP_VERSION else: fmt("{GIT_COMMIT}") # Name of the test environment var to check for -const TEST_ENVIRONMENT_VAR* = "TEST_ENVIRONMENT" +const STATUS_RUNTIME_TEST_MODE_VAR* = "STATUS_RUNTIME_TEST_MODE" + +const TEST_MODE_ENABLED* = getEnv(STATUS_RUNTIME_TEST_MODE_VAR).toUpperAscii() == "TRUE" or + getEnv(STATUS_RUNTIME_TEST_MODE_VAR) == "1" \ No newline at end of file