From ffc5da38057ca4b479fbbb302be7eb652170f949 Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Thu, 3 Oct 2024 16:13:35 +0300 Subject: [PATCH] tests: add better condition when waiting for status change --- .../wallet/wallet_account_popups.py | 4 +- test/e2e/gui/main_window.py | 2 +- test/e2e/gui/objects_map/communities_names.py | 3 +- .../gui/screens/community_settings_tokens.py | 42 +++++-------------- .../test_mint_owner_and_tokenmaster_tokens.py | 5 +-- .../views/collectibles/CollectibleView.qml | 2 + 6 files changed, 17 insertions(+), 41 deletions(-) diff --git a/test/e2e/gui/components/wallet/wallet_account_popups.py b/test/e2e/gui/components/wallet/wallet_account_popups.py index bb010e56e2..62b18bf52a 100644 --- a/test/e2e/gui/components/wallet/wallet_account_popups.py +++ b/test/e2e/gui/components/wallet/wallet_account_popups.py @@ -274,7 +274,7 @@ class AddNewAccountPopup(BasePopup): @allure.step('Click continue') def click_continue(self): - self._continue_button.click() + self._continue_button.click(timeout=10) return self @allure.step('Import new seed phrase and continue') @@ -287,7 +287,7 @@ class AddNewAccountPopup(BasePopup): @allure.step('Enter new seed phrase') def enter_new_seed_phrase(self, seed_phrase_words: list): - self._import_seed_phrase_button.click() + self._import_seed_phrase_button.click(timeout=10) if len(seed_phrase_words) == 12: self._seed_phrase_12_words_button.click() elif len(seed_phrase_words) == 18: diff --git a/test/e2e/gui/main_window.py b/test/e2e/gui/main_window.py index 495b82856f..3cea080bbe 100644 --- a/test/e2e/gui/main_window.py +++ b/test/e2e/gui/main_window.py @@ -154,7 +154,7 @@ class LeftPanel(QObject): @allure.step('Open Wallet section') def open_wallet(self, attempts: int = 3) -> WalletScreen: - self._wallet_button.click(timeout=10) + self._wallet_button.click(timeout=15) try: return WalletScreen() except Exception as ex: diff --git a/test/e2e/gui/objects_map/communities_names.py b/test/e2e/gui/objects_map/communities_names.py index 49865fcc7f..4e63f90722 100644 --- a/test/e2e/gui/objects_map/communities_names.py +++ b/test/e2e/gui/objects_map/communities_names.py @@ -141,8 +141,7 @@ editOwnerTokenView_Fees_FeesBox = {"container": mainWindow_editOwnerTokenView_Ed mainWindow_MintedTokensView = {"container": mainWindow_StatusWindow, "type": "MintedTokensView", "unnamed": 1, "visible": True} specialCollectible_PrivilegedTokenArtworkPanel = {"container": mainWindow_MintedTokensView, "id": "specialCollectible", "type": "PrivilegedTokenArtworkPanel", "unnamed": 1, "visible": True} specialCollectible_PrivilegedTokenArtworkPanel_2 = {"container": mainWindow_MintedTokensView, "id": "specialCollectible", "occurrence": 2, "type": "PrivilegedTokenArtworkPanel", "unnamed": 1, "visible": True} -o_CollectibleView_2 = {"container": mainWindow_MintedTokensView, "index": 1, "type": "CollectibleView", "unnamed": 1, "visible": True} -o_CollectibleView = {"container": mainWindow_MintedTokensView, "index": 0, "type": "CollectibleView", "unnamed": 1, "visible": True} +collectibleView_control = {"container": mainWindow_MintedTokensView, "objectName": "collectibleViewControl", "type": "CollectibleView", "visible": True} token_sale_icon_StatusIcon = {"container": mainWindow_MintedTokensView, "objectName": "token-sale-icon", "type": "StatusIcon", "visible": True} crown_icon_StatusIcon = {"container": mainWindow_MintedTokensView, "objectName": "crown-icon", "type": "StatusIcon", "visible": True} diff --git a/test/e2e/gui/screens/community_settings_tokens.py b/test/e2e/gui/screens/community_settings_tokens.py index 7c18a8ba23..05a149603f 100644 --- a/test/e2e/gui/screens/community_settings_tokens.py +++ b/test/e2e/gui/screens/community_settings_tokens.py @@ -1,3 +1,4 @@ +import time import typing import allure @@ -280,38 +281,15 @@ class EditOwnerTokenView(QObject): class MintedTokensView(QObject): def __init__(self): - super(MintedTokensView, self).__init__(communities_names.mainWindow_MintedTokensView) + super().__init__(communities_names.mainWindow_MintedTokensView) + self.minted_tokens_view = QObject(communities_names.mainWindow_MintedTokensView) self._coin_symbol = QObject(communities_names.token_sale_icon_StatusIcon) self._crown_symbol = QObject(communities_names.crown_icon_StatusIcon) - self._master_token = QObject(communities_names.o_CollectibleView) - self._owner_token = QObject(communities_names.o_CollectibleView_2) + self.collectible = QObject(communities_names.collectibleView_control) - @property - @allure.step('Check crown symbol is visible on owner token') - def does_crown_exist(self) -> bool: - return self._crown_symbol.exists - - @property - @allure.step('Check coin symbol is visible on master token') - def does_coin_exist(self) -> bool: - return self._coin_symbol.exists - - @property - @allure.step('Get title of owner token') - def get_owner_token_title(self) -> str: - return str(self._owner_token.object.title) - - @property - @allure.step('Get title of master token') - def get_master_token_title(self) -> str: - return str(self._master_token.object.title) - - @property - @allure.step('Get status of owner token') - def get_owner_token_status(self) -> str: - return str(self._owner_token.object.subTitle) - - @property - @allure.step('Get status of master token') - def get_master_token_status(self) -> str: - return str(self._master_token.object.subTitle) + def check_community_collectibles_statuses(self): + assert len(driver.findAllObjects(self.collectible.real_name)) == 2 + assert self.wait_for(({'∞', '1 of 1 (you hodl)'} == set( + [str(getattr(collectible, 'subTitle', '')) for collectible in + driver.findAllObjects(self.collectible.wait_until_appears().real_name)]), 180000)), \ + f"Token statuses were not changed within 3 minutes: {*[str(getattr(collectible, 'subTitle', '')) for collectible in driver.findAllObjects(self.collectible.real_name)],}" diff --git a/test/e2e/tests/transactions_tests/test_mint_owner_and_tokenmaster_tokens.py b/test/e2e/tests/transactions_tests/test_mint_owner_and_tokenmaster_tokens.py index 5cc4579f73..3d0efdc702 100644 --- a/test/e2e/tests/transactions_tests/test_mint_owner_and_tokenmaster_tokens.py +++ b/test/e2e/tests/transactions_tests/test_mint_owner_and_tokenmaster_tokens.py @@ -88,7 +88,4 @@ def test_mint_owner_and_tokenmaster_tokens(main_window, user_account): configs.timeouts.UI_LOAD_TIMEOUT_MSEC) with step('Verify that status of both tokens'): - assert driver.waitFor(lambda: (minted_tokens_view.get_owner_token_status == '1 of 1 (you hodl)'), 60000), \ - f'Owner token status was not updated and is {minted_tokens_view.get_owner_token_status}' - assert driver.waitFor(lambda: (minted_tokens_view.get_master_token_status == '∞'), 60000), \ - f'Token master token status was not updated and is {minted_tokens_view.get_master_token_status}' + minted_tokens_view.check_community_collectibles_statuses() diff --git a/ui/app/AppLayouts/Wallet/views/collectibles/CollectibleView.qml b/ui/app/AppLayouts/Wallet/views/collectibles/CollectibleView.qml index 22d540843a..6f737b5bf6 100644 --- a/ui/app/AppLayouts/Wallet/views/collectibles/CollectibleView.qml +++ b/ui/app/AppLayouts/Wallet/views/collectibles/CollectibleView.qml @@ -15,6 +15,8 @@ import utils 1.0 Control { id: root + objectName: "collectibleViewControl" + property string title: "" property string unknownTitle: "..." property string subTitle: ""