chore(test): use STATUS_RUNTIME_USE_MOCKED_KEYCARD env var for

displaying mocked keycard controller window
This commit is contained in:
Ivan Belyakov 2024-07-11 18:54:01 +02:00 committed by IvanBelyakoff
parent c7a4419a76
commit baa65de1ae
5 changed files with 17 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -99,7 +99,7 @@ StatusWindow {
property var mockedKeycardControllerWindow
function runMockedKeycardControllerWindow() {
if (localAppSettings.testEnvironment) {
if (localAppSettings.displayMockedKeycardWindow()) {
if (!!d.mockedKeycardControllerWindow) {
d.mockedKeycardControllerWindow.close()
}