From baa65de1ae5b28d68853a90b83c5d0a564220180 Mon Sep 17 00:00:00 2001 From: Ivan Belyakov Date: Thu, 11 Jul 2024 18:54:01 +0200 Subject: [PATCH] chore(test): use STATUS_RUNTIME_USE_MOCKED_KEYCARD env var for displaying mocked keycard controller window --- src/app/global/local_app_settings.nim | 5 ++++- src/app_service/service/keycard/service.nim | 12 ++++++------ src/constants.nim | 1 + src/env_cli_vars.nim | 5 +++++ ui/main.qml | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/app/global/local_app_settings.nim b/src/app/global/local_app_settings.nim index 4d01b71886..c6cb462220 100644 --- a/src/app/global/local_app_settings.nim +++ b/src/app/global/local_app_settings.nim @@ -138,6 +138,9 @@ QtObject: QtProperty[bool] testEnvironment: read = getTestEnvironment + proc displayMockedKeycardWindow*(self: LocalAppSettings): bool {.slot.} = + return DISPLAY_MOCKED_KEYCARD_WINDOW + proc fakeLoadingScreenEnabledChanged*(self: LocalAppSettings) {.signal.} proc getFakeLoadingScreenEnabled*(self: LocalAppSettings): bool {.slot.} = self.settings.value(LAS_KEY_FAKE_LOADING_SCREEN_ENABLED, newQVariant(DEFAULT_FAKE_LOADING_SCREEN_ENABLED)).boolVal @@ -225,4 +228,4 @@ QtObject: return constants.WALLET_CONNECT_PROJECT_ID QtProperty[string] walletConnectProjectID: - read = getWalletConnectProjectID \ No newline at end of file + read = getWalletConnectProjectID diff --git a/src/app_service/service/keycard/service.nim b/src/app_service/service/keycard/service.nim index 7ef10f6a2e..433cd15e83 100644 --- a/src/app_service/service/keycard/service.nim +++ b/src/app_service/service/keycard/service.nim @@ -184,7 +184,7 @@ QtObject: ## Used in test env only, for testing keycard flows proc registerMockedKeycard*(self: Service, cardIndex: int, readerState: int, keycardState: int, mockedKeycard: string, mockedKeycardHelper: string) = - if not singletonInstance.localAppSettings.getTestEnvironment(): + if not singletonInstance.localAppSettings.displayMockedKeycardWindow(): error "registerMockedKeycard can be used only in test env" return let response = keycard_go.mockedLibRegisterKeycard(cardIndex, readerState, keycardState, mockedKeycard, mockedKeycardHelper) @@ -192,7 +192,7 @@ QtObject: debug "mockedLibRegisterKeycard", kcServiceCurrFlow=($self.currentFlow), cardIndex=cardIndex, readerState=readerState, keycardState=keycardState, mockedKeycard=mockedKeycard, mockedKeycardHelper=mockedKeycardHelper, response=response proc pluginMockedReaderAction*(self: Service) = - if not singletonInstance.localAppSettings.getTestEnvironment(): + if not singletonInstance.localAppSettings.displayMockedKeycardWindow(): error "pluginMockedReaderAction can be used only in test env" return let response = keycard_go.mockedLibReaderPluggedIn() @@ -200,7 +200,7 @@ QtObject: debug "mockedLibReaderPluggedIn", kcServiceCurrFlow=($self.currentFlow), response=response proc unplugMockedReaderAction*(self: Service) = - if not singletonInstance.localAppSettings.getTestEnvironment(): + if not singletonInstance.localAppSettings.displayMockedKeycardWindow(): error "unplugMockedReaderAction can be used only in test env" return let response = keycard_go.mockedLibReaderUnplugged() @@ -208,7 +208,7 @@ QtObject: debug "mockedLibReaderUnplugged", kcServiceCurrFlow=($self.currentFlow), response=response proc insertMockedKeycardAction*(self: Service, cardIndex: int) = - if not singletonInstance.localAppSettings.getTestEnvironment(): + if not singletonInstance.localAppSettings.displayMockedKeycardWindow(): error "insertMockedKeycardAction can be used only in test env" return let response = keycard_go.mockedLibKeycardInserted(cardIndex) @@ -216,7 +216,7 @@ QtObject: debug "mockedLibKeycardInserted", kcServiceCurrFlow=($self.currentFlow), cardIndex=cardIndex, response=response proc removeMockedKeycardAction*(self: Service) = - if not singletonInstance.localAppSettings.getTestEnvironment(): + if not singletonInstance.localAppSettings.displayMockedKeycardWindow(): error "removeMockedKeycardAction can be used only in test env" return let response = keycard_go.mockedLibKeycardRemoved() @@ -489,4 +489,4 @@ QtObject: error "registerForKeycardAvailability can be called only when keycard is busy" return self.registeredCallback = p - self.runTimer(CheckKeycardAvailabilityInterval, $TimerReason.WaitForKeycardAvailability) \ No newline at end of file + self.runTimer(CheckKeycardAvailabilityInterval, $TimerReason.WaitForKeycardAvailability) diff --git a/src/constants.nim b/src/constants.nim index b6beddd9ae..df8e32f190 100644 --- a/src/constants.nim +++ b/src/constants.nim @@ -36,6 +36,7 @@ let # runtime variables TEST_MODE_ENABLED* = desktopConfig.testMode + DISPLAY_MOCKED_KEYCARD_WINDOW* = desktopConfig.displayMockedKeycardWindow WALLET_ENABLED* = desktopConfig.enableWallet TORRENT_CONFIG_PORT* = desktopConfig.defaultTorentConfigPort WAKU_V2_PORT* = desktopConfig.defaultWakuV2Port diff --git a/src/env_cli_vars.nim b/src/env_cli_vars.nim index 439e64c9d9..76de2089bd 100644 --- a/src/env_cli_vars.nim +++ b/src/env_cli_vars.nim @@ -217,6 +217,11 @@ type StatusDesktopConfig = object desc: "Determines if the fleet selection UI is enabled" name: "ENABLE_FLEET_SELECTION" abbr: "enable-fleet-selection" .}: bool + displayMockedKeycardWindow* {. + defaultValue: false + desc: "Determines if the app should use mocked keycard" + name: "USE_MOCKED_KEYCARD" + abbr: "use-mocked-keycard" .}: bool # On macOS the first time when a user gets the "App downloaded from the diff --git a/ui/main.qml b/ui/main.qml index a42e87985f..6269a4340f 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -99,7 +99,7 @@ StatusWindow { property var mockedKeycardControllerWindow function runMockedKeycardControllerWindow() { - if (localAppSettings.testEnvironment) { + if (localAppSettings.displayMockedKeycardWindow()) { if (!!d.mockedKeycardControllerWindow) { d.mockedKeycardControllerWindow.close() }