test: custom ordering of assets added

This commit is contained in:
Valentina Novgorodtceva 2024-05-13 14:09:56 +07:00 committed by Valentina1133
parent 4cf0626a25
commit 5b4a4e31e9
5 changed files with 150 additions and 2 deletions

View File

@ -88,6 +88,8 @@ wallet_account = namedtuple('PrivateKeyAddressPair', ['private_key', 'wallet_add
private_key_address_pair_1 = wallet_account('2daa36a3abe381a9c01610bf10fda272fbc1b8a22179a39f782c512346e3e470',
'0xd89b48cbcb4244f84a4fb5d3369c120e8f8aa74e')
token_list_item = namedtuple('TokenListItem', ['title', 'object'])
ens_user_name = ''.join(
random.choices(string.digits + string.ascii_lowercase, k=8))

View File

@ -1,5 +1,6 @@
import allure
import configs
from gui.elements.button import Button
from gui.elements.object import QObject
from gui.objects_map import names, communities_names
@ -31,3 +32,26 @@ class PermissionsChangesDetectedToastMessage(QObject):
def update_permission(self):
self._update_permission_button.click()
self.wait_until_hidden()
class CustomSortOrderChangesDetectedToastMessage(ChangesDetectedToastMessage):
def __init__(self):
super(CustomSortOrderChangesDetectedToastMessage, self).__init__()
self._save_button = Button(names.mainWindow_Save_StatusFlatButton)
self._save_and_apply_button = Button(names.mainWindow_Save_and_apply_StatusButton)
@allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
self._save_and_apply_button.wait_until_appears(timeout_msec)
return self
@allure.step('Save and apply changes')
def save_and_apply_changes(self):
self._save_and_apply_button.click()
self.wait_until_hidden()
@allure.step('Save changes')
def save_changes(self):
self._save_button.click()
self.wait_until_hidden()

View File

@ -792,6 +792,7 @@ mainWindow_Send_Button = {"container": statusDesktop_mainWindow, "objectName": "
mainWindow_RightTabView = {"container": mainWindow_StatusWindow, "type": "RightTabView", "unnamed": 1, "visible": True}
filterButton_StatusFlatButton = {"checkable": True, "container": mainWindow_RightTabView, "objectName": "filterButton", "type": "StatusFlatButton", "visible": True}
cmbTokenOrder_SortOrderComboBox = {"container": mainWindow_RightTabView, "objectName": "cmbTokenOrder", "type": "SortOrderComboBox", "visible": True}
collectibles_cmbTokenOrder_SortOrderComboBox = {"container": mainWindow_RightTabView, "id": "cmbTokenOrder", "type": "SortOrderComboBox", "unnamed": 1, "visible": True}
rightSideWalletTabBar_StatusTabBar = {"container": mainWindow_RightTabView, "objectName": "rightSideWalletTabBar", "type": "StatusTabBar", "visible": True}
rightSideWalletTabBar_Assets_StatusTabButton = {"checkable": True, "container": rightSideWalletTabBar_StatusTabBar, "objectName": "assetsTabButton", "text": "Assets", "type": "StatusTabButton", "visible": True}
rightSideWalletTabBar_Collectibles_StatusTabButton = {"checkable": True, "container": rightSideWalletTabBar_StatusTabBar, "objectName": "collectiblesTabButton", "text": "Collectibles", "type": "StatusTabButton", "visible": True}
@ -800,6 +801,13 @@ o_AssetsView = {"container": mainWindow_RightTabView, "type": "AssetsView", "unn
itemDelegate = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "menuDelegate", "type": "ItemDelegate", "unnamed": 1, "visible": True}
assetView_TokenListItem_TokenDelegate = {"container": mainWindow_RightTabView, "objectName": RegularExpression("AssetView_TokenListItem_*"), "type": "TokenDelegate", "visible": True}
arrow_icon_StatusIcon = {"container": statusDesktop_mainWindow_overlay, "objectName": "arrow-up-icon", "type": "StatusIcon", "visible": True}
collectible_item = {"container": mainWindow_RightTabView, "type": "CollectibleView", "unnamed": 1, "visible": True}
mainWindow_settingsContentBaseScrollView_StatusScrollView_general = {"container": statusDesktop_mainWindow, "objectName": "settingsContentBaseScrollView", "type": "StatusScrollView", "visible": True}
settingsContentBaseScrollView_manageTokensDelegate_ManageTokensDelegate = {"container": mainWindow_settingsContentBaseScrollView_StatusScrollView_general, "objectName": RegularExpression("manageTokensDelegate-*"), "type": "ManageTokensDelegate", "visible": True}
settingsContentBaseScrollView_manageTokensView_ManageTokensView = {"container": mainWindow_settingsContentBaseScrollView_StatusScrollView_general, "id": "manageTokensView", "type": "ManageTokensView", "unnamed": 1, "visible": True}
mainWindow_Save_and_apply_StatusButton = {"checkable": False, "container": mainWindow_StatusWindow, "objectName": "settingsDirtyToastMessageSaveButton", "text": "Save and apply", "type": "StatusButton", "visible": True}
mainWindow_Save_StatusFlatButton = {"checkable": False, "container": mainWindow_StatusWindow, "id": "saveForLaterButton", "text": "Save", "type": "StatusFlatButton", "unnamed": 1, "visible": True}
# MOCKED KEYCARD CONTROLLER NAMES

View File

@ -6,6 +6,7 @@ import allure
import configs
import constants.user
import driver
from driver import objects_access
from driver.objects_access import walk_children
from gui.components.base_popup import BasePopup
from gui.components.context_menu import ContextMenu
@ -104,7 +105,6 @@ class LeftPanel(QObject):
self._open_context_menu_for_account(account_name).select_edit_account_from_context_menu()
return AccountPopup().verify_edit_account_popup_present()
@allure.step('Open account popup')
def open_add_account_popup(self, attempt: int = 2):
self._add_account_button.click()
@ -190,6 +190,33 @@ class SavedAddressesView(QObject):
return ContextMenu().wait_until_appears()
class ManageTokensView(QObject):
def __init__(self):
super(ManageTokensView, self).__init__(names.settingsContentBaseScrollView_manageTokensView_ManageTokensView)
self._window_item = QObject(names.statusDesktop_mainWindow)
self._token_item = QObject(names.settingsContentBaseScrollView_manageTokensDelegate_ManageTokensDelegate)
@property
@allure.step('Get tokens')
def tokens(self) -> typing.List[constants.token_list_item]:
_tokens = []
for token_item in driver.findAllObjects(self._token_item.real_name):
element = QObject(real_name=driver.objectMap.realName(token_item))
name = str(token_item.title)
_tokens.append(constants.token_list_item(name, element))
return sorted(_tokens, key=lambda token: token.object.y)
@allure.step('Drag token to change the order')
def drag_token(self, name: str, index: int):
assert driver.waitFor(lambda: len([token for token in self.tokens if token.title == name]) == 1), \
'Token not found or found more then one'
bounds = [token for token in self.tokens if token.title == name][0].object.bounds
d_bounds = self.tokens[index].object.bounds
driver.mouse.press_and_move(self._window_item.object, bounds.x, bounds.y, d_bounds.x, d_bounds.y + 1)
class WalletAccountView(QObject):
def __init__(self):
@ -271,3 +298,12 @@ class WalletAccountView(QObject):
token_list_items.append(item)
sorted(token_list_items, key=lambda item: item.y)
return token_list_items
@allure.step('Get list of collectibles')
def get_list_of_collectibles(self) -> typing.List:
time.sleep(1)
token_list_items = []
for item in driver.findAllObjects(self._collectible_item.real_name):
token_list_items.append(item)
sorted(token_list_items, key=lambda item: item.x)
return token_list_items

View File

@ -3,7 +3,8 @@ import pytest
from allure_commons._allure import step
import driver
from gui.screens.wallet import WalletAccountView
from gui.components.changes_detected_popup import CustomSortOrderChangesDetectedToastMessage
from gui.screens.wallet import WalletAccountView, ManageTokensView
from tests.wallet_main_screen import marks
from gui.components.signing_phrase_popup import SigningPhrasePopup
@ -132,3 +133,80 @@ def test_wallet_sort_assets(main_screen: MainWindow, address, name, dai, weenus,
assert driver.waitFor(lambda: assets_order[1].title == stt, 6000)
assert driver.waitFor(lambda: assets_order[2].title == eth, 6000)
assert driver.waitFor(lambda: assets_order[3].title == dai, 6000)
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704709',
'Create custom order')
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704731',
'Select custom order')
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704732',
'Edit custom order')
@pytest.mark.case(704709, 704731, 704732)
@pytest.mark.parametrize('address, name, dai, weenus, stt, eth', [
pytest.param('0xFf58d746A67C2E42bCC07d6B3F58406E8837E883', 'AssetsCollectibles', 'Dai Stablecoin', 'WEENUS Token',
'Status Test Token', 'Ether')
])
def test_custom_ordering(main_screen: MainWindow, address, name, dai, weenus, stt, eth):
with step('Turn on Testnet mode'):
networks = main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_networks()
networks.switch_testnet_mode_toggle().turn_on_testnet_mode_in_testnet_modal()
with step('Add watched address with plus action button'):
wallet = main_screen.left_panel.open_wallet()
SigningPhrasePopup().wait_until_appears().confirm_phrase()
account_popup = wallet.left_panel.open_add_account_popup()
account_popup.set_name(name).set_origin_watched_address(address).save()
account_popup.wait_until_hidden()
with step(
'Choose Create custom order in sorting dropdown and verify Manage tokens view appears'):
wallet_account_view = WalletAccountView()
sorting = wallet_account_view.open_assets_tab().click_filter_button()
sorting.choose_sort_by_value('Create custom order →')
manage_tokens = ManageTokensView()
assert manage_tokens.exists
with step('Drag first token to the end of the list and save changes'):
manage_tokens.drag_token(dai, 3)
CustomSortOrderChangesDetectedToastMessage().wait_until_appears().save_changes()
with step('Verify the order is correct in Manage Tokens View'):
tokens_order = manage_tokens.tokens
assert driver.waitFor(lambda: tokens_order[0].title == eth, 6000)
assert driver.waitFor(lambda: tokens_order[1].title == weenus, 6000)
assert driver.waitFor(lambda: tokens_order[2].title == stt, 6000)
assert driver.waitFor(lambda: tokens_order[3].title == dai, 6000)
with step('Go to Wallet view and choose Custom order from dropdown'):
main_screen.left_panel.open_wallet().left_panel.select_account(name)
sorting = wallet_account_view.open_assets_tab().click_filter_button()
sorting.choose_sort_by_value('Custom order')
assets_order = wallet_account_view.get_list_of_assets()
assert driver.waitFor(lambda: assets_order[0].title == eth, 6000)
assert driver.waitFor(lambda: assets_order[1].title == weenus, 6000)
assert driver.waitFor(lambda: assets_order[2].title == stt, 6000)
assert driver.waitFor(lambda: assets_order[3].title == dai, 6000)
with step('Choose Edit custom order in sorting dropdown and verify Manage tokens view appears'):
sorting.choose_sort_by_value('Edit custom order →')
manage_tokens = ManageTokensView()
assert manage_tokens.exists
with step('Drag first token to the end of the list and apply changes'):
manage_tokens.drag_token(eth, 3)
CustomSortOrderChangesDetectedToastMessage().wait_until_appears().save_and_apply_changes()
with step('Verify the order is correct in Manage Tokens View'):
tokens_order = manage_tokens.tokens
assert driver.waitFor(lambda: tokens_order[0].title == weenus, 6000)
assert driver.waitFor(lambda: tokens_order[1].title == stt, 6000)
assert driver.waitFor(lambda: tokens_order[2].title == dai, 6000)
assert driver.waitFor(lambda: tokens_order[3].title == eth, 6000)
with step('Verify the order is correct in Wallet view'):
main_screen.left_panel.open_wallet().left_panel.select_account(name)
assets_order = wallet_account_view.get_list_of_assets()
assert driver.waitFor(lambda: assets_order[0].title == weenus, 6000)
assert driver.waitFor(lambda: assets_order[1].title == stt, 6000)
assert driver.waitFor(lambda: assets_order[2].title == dai, 6000)
assert driver.waitFor(lambda: assets_order[3].title == eth, 6000)