chore: handle keycard window

This commit is contained in:
Anastasiya Semenkevich 2024-07-10 16:07:47 +03:00
parent 27d954d63b
commit fd660a380e
4 changed files with 19 additions and 10 deletions

View File

@ -9,3 +9,5 @@ def get_platform():
DISPLAY = os.getenv('DISPLAY', ':0')
TEST_MODE = os.getenv('STATUS_RUNTIME_TEST_MODE')
CLOSE_KEYCARD_CONTROLLER = True

View File

@ -169,9 +169,8 @@ class MainWindow(Window):
super(MainWindow, self).__init__(names.statusDesktop_mainWindow)
self.left_panel = LeftPanel()
# TODO: we need to handle all the issues with keycard mock var before using keycard window in tests
def prepare(self) -> 'Window':
MockedKeycardController().wait_until_appears().hide()
MockedKeycardController.keycard_handler()
return super().prepare()
@allure.step('Sign Up user')
@ -192,6 +191,7 @@ class MainWindow(Window):
SplashScreen().wait_until_appears().wait_until_hidden()
if not configs.system.TEST_MODE:
BetaConsentPopup().confirm()
MockedKeycardController.keycard_handler()
return self
@allure.step('Log in user')
@ -200,6 +200,7 @@ class MainWindow(Window):
SplashScreen().wait_until_appears().wait_until_hidden()
if not configs.system.TEST_MODE:
BetaConsentPopup().confirm()
MockedKeycardController.keycard_handler()
return self
@allure.step('Authorize user')

View File

@ -14,6 +14,13 @@ from gui.objects_map import names
class MockedKeycardController(Window):
@staticmethod
def keycard_handler():
mocked_keycard = MockedKeycardController()
if configs.system.TEST_MODE and configs.system.CLOSE_KEYCARD_CONTROLLER:
if mocked_keycard.is_visible:
mocked_keycard.hide()
def __init__(self):
super(MockedKeycardController, self).__init__(names.QQuickApplicationWindow)
self._plugin_reader_button = Button(names.plugin_Reader_StatusButton)

View File

@ -23,20 +23,19 @@ from functools import wraps
def handle_settings_opening(view_class, menu_item):
def decorator(func):
def open_settings_decorator(func):
@wraps(func)
def wrapper(self, click_attempts=2):
if MockedKeycardController().exists:
MockedKeycardController().wait_until_appears().hide()
MockedKeycardController().keycard_handler()
self._open_settings(menu_item)
if configs.system.TEST_MODE:
if click_attempts:
time.sleep(0.5)
return func(self, click_attempts - 1)
if click_attempts:
if configs.system.TEST_MODE:
time.sleep(1)
return func(self, click_attempts - 1)
return wrapper
return decorator
return open_settings_decorator
class LeftPanel(QObject):