From 601d3dd0f17c605ee0332bb0e66298fb965d3475 Mon Sep 17 00:00:00 2001 From: Ivan Belyakov Date: Mon, 6 Mar 2023 15:30:58 +0300 Subject: [PATCH] fix(@desktop/wallet): Fix tests for saved addresses. Minor fixes Updates: #8599 --- test/ui-test/src/drivers/SquishDriver.py | 8 +++++++ .../ui-test/src/screens/StatusWalletScreen.py | 22 +++++++++++-------- .../shared/scripts/wallet_names.py | 3 ++- .../controls/SavedAddressesDelegate.qml | 2 +- .../popups/AddEditSavedAddressPopup.qml | 6 ++--- .../Wallet/popups/NetworkSelectPopup.qml | 11 +++++++--- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/test/ui-test/src/drivers/SquishDriver.py b/test/ui-test/src/drivers/SquishDriver.py index 2e6e0c2d1d..327efed37d 100755 --- a/test/ui-test/src/drivers/SquishDriver.py +++ b/test/ui-test/src/drivers/SquishDriver.py @@ -43,6 +43,14 @@ def is_loaded_visible_and_enabled(objName: str, timeout: int=_MAX_WAIT_OBJ_TIMEO except LookupError: return False, obj +# Waits for the given object is loaded, visible and enabled. +# It returns a tuple: True in case it is found. Otherwise, false. And the object itself. +def is_object_loaded_visible_and_enabled(obj: object, timeout: int=_MAX_WAIT_OBJ_TIMEOUT): + try: + squish.waitForObject(obj, timeout) + return True + except LookupError: + return False # Waits for the given object is loaded and might be not visible and/or not enabled: # It returns a tuple: True in case it is found. Otherwise, false. And the object itself. diff --git a/test/ui-test/src/screens/StatusWalletScreen.py b/test/ui-test/src/screens/StatusWalletScreen.py index 3d0cae8de3..a81108e0c8 100644 --- a/test/ui-test/src/screens/StatusWalletScreen.py +++ b/test/ui-test/src/screens/StatusWalletScreen.py @@ -44,6 +44,7 @@ class SavedAddressesScreen(Enum): class AddSavedAddressPopup(Enum): NAME_INPUT: str = "mainWallet_Saved_Addreses_Popup_Name_Input" ADDRESS_INPUT: str = "mainWallet_Saved_Addreses_Popup_Address_Input" + ADDRESS_INPUT_EDIT: str = "mainWallet_Saved_Addreses_Popup_Address_Input_Edit" ADD_BUTTON: str = "mainWallet_Saved_Addreses_Popup_Address_Add_Button" class SendPopup(Enum): @@ -218,7 +219,11 @@ class StatusWalletScreen: click_obj_by_name(MainWalletScreen.SAVED_ADDRESSES_BUTTON.value) click_obj_by_name(SavedAddressesScreen.ADD_BUTTON.value) type_text(AddSavedAddressPopup.NAME_INPUT.value, name) - type_text(AddSavedAddressPopup.ADDRESS_INPUT.value, address) + + type_text(AddSavedAddressPopup.ADDRESS_INPUT_EDIT.value, address) + addressInput = get_obj(AddSavedAddressPopup.ADDRESS_INPUT.value) + verify_equal(addressInput.plainText, address) + is_loaded_visible_and_enabled(AddSavedAddressPopup.ADD_BUTTON.value) click_obj_by_name(AddSavedAddressPopup.ADD_BUTTON.value) def _get_saved_address_delegate_item(self, name: str): @@ -233,8 +238,9 @@ class StatusWalletScreen: def _find_saved_address_and_open_menu(self, name: str): item = self._get_saved_address_delegate_item(name) - obj = get_child_item_with_object_name(item, SavedAddressesScreen.DELEGATE_MENU_BUTTON_OBJECT_NAME.value) - click_obj(obj) + menuButton = get_child_item_with_object_name(item, f"{SavedAddressesScreen.DELEGATE_MENU_BUTTON_OBJECT_NAME.value}_{name}") + is_object_loaded_visible_and_enabled(menuButton) + click_obj(menuButton) def edit_saved_address(self, name: str, new_name: str): self._find_saved_address_and_open_menu(name) @@ -252,17 +258,15 @@ class StatusWalletScreen: def toggle_favourite_for_saved_address(self, name: str): # Find the saved address and click favourite to toggle item = self._get_saved_address_delegate_item(name) - favouriteButton = get_child_item_with_object_name(item, SavedAddressesScreen.DELEGATE_FAVOURITE_BUTTON_OBJECT_NAME.value) + favouriteButton = item.statusListItemIcon + is_object_loaded_visible_and_enabled(favouriteButton) click_obj(favouriteButton) def check_favourite_status_for_saved_address(self, name: str, favourite: bool): # Find the saved address item = self._get_saved_address_delegate_item(name) - favouriteButton = get_child_item_with_object_name(item, SavedAddressesScreen.DELEGATE_FAVOURITE_BUTTON_OBJECT_NAME.value) - - # if favourite is true, check that the favourite shows "unfavourite" icon and vice versa - wait_for_prop_value(favouriteButton, "icon.name", ("unfavourite" if favourite else "favourite")) - wait_for_prop_value(item, "titleTextIcon", ("star-icon" if favourite else "")) + favouriteButton = item.statusListItemIcon + wait_for_prop_value(favouriteButton, "asset.name", ("star-icon" if favourite else "favourite")) def toggle_network(self, network_name: str): is_loaded_visible_and_enabled(MainWalletScreen.NETWORK_SELECTOR_BUTTON.value, 2000) diff --git a/test/ui-test/testSuites/suite_wallet/shared/scripts/wallet_names.py b/test/ui-test/testSuites/suite_wallet/shared/scripts/wallet_names.py index d83c74ff12..3e55daa551 100644 --- a/test/ui-test/testSuites/suite_wallet/shared/scripts/wallet_names.py +++ b/test/ui-test/testSuites/suite_wallet/shared/scripts/wallet_names.py @@ -76,7 +76,8 @@ mainWallet_Saved_Addreses_More_Confirm_Delete = {"container": statusDesktop_main # saved address add popup mainWallet_Saved_Addreses_Popup_Name_Input = {"container": statusDesktop_mainWindow, "objectName": "savedAddressNameInput", "type": "TextEdit"} -mainWallet_Saved_Addreses_Popup_Address_Input = {"container": statusDesktop_mainWindow, "objectName": "savedAddressAddressInput", "type": "StyledTextField"} +mainWallet_Saved_Addreses_Popup_Address_Input = {"container": statusDesktop_mainWindow, "objectName": "savedAddressAddressInput", "type": "StatusInput"} +mainWallet_Saved_Addreses_Popup_Address_Input_Edit = {"container": statusDesktop_mainWindow, "objectName": "savedAddressAddressInputEdit", "type": "TextEdit"} mainWallet_Saved_Addreses_Popup_Address_Add_Button = {"container": statusDesktop_mainWindow, "objectName": "addSavedAddress", "type": "StatusButton"} # Collectibles view diff --git a/ui/app/AppLayouts/Wallet/controls/SavedAddressesDelegate.qml b/ui/app/AppLayouts/Wallet/controls/SavedAddressesDelegate.qml index 71c1c087fc..0b4c17d48f 100644 --- a/ui/app/AppLayouts/Wallet/controls/SavedAddressesDelegate.qml +++ b/ui/app/AppLayouts/Wallet/controls/SavedAddressesDelegate.qml @@ -72,7 +72,7 @@ StatusListItem { onClicked: openSendModal(d.visibleAddress) }, StatusRoundButton { - objectName: "savedAddressView_Delegate_menuButton" + objectName: "savedAddressView_Delegate_menuButton_" + root.name visible: !!root.name icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1 type: StatusRoundButton.Type.Quinary diff --git a/ui/app/AppLayouts/Wallet/popups/AddEditSavedAddressPopup.qml b/ui/app/AppLayouts/Wallet/popups/AddEditSavedAddressPopup.qml index 621ec29130..b6d65d3792 100644 --- a/ui/app/AppLayouts/Wallet/popups/AddEditSavedAddressPopup.qml +++ b/ui/app/AppLayouts/Wallet/popups/AddEditSavedAddressPopup.qml @@ -105,7 +105,6 @@ StatusDialog { ] input.clearable: true input.rightPadding: 16 - charLimit: 40 validationMode: d.validationMode } @@ -113,8 +112,9 @@ StatusDialog { id: addressInput implicitWidth: parent.width label: qsTr("Address") - input.edit.objectName: "savedAddressAddressInput" - placeholderText: qsTr("Ethereum Address") + objectName: "savedAddressAddressInput" + input.edit.objectName: "savedAddressAddressInputEdit" + placeholderText: qsTr("Ethereum address") maximumHeight: 66 input.implicitHeight: Math.min(Math.max(input.edit.contentHeight + topPadding + bottomPadding, minimumHeight), maximumHeight) // setting height instead does not work enabled: !(root.edit || root.addAddress) diff --git a/ui/app/AppLayouts/Wallet/popups/NetworkSelectPopup.qml b/ui/app/AppLayouts/Wallet/popups/NetworkSelectPopup.qml index 7d942f2d53..e2098c91ba 100644 --- a/ui/app/AppLayouts/Wallet/popups/NetworkSelectPopup.qml +++ b/ui/app/AppLayouts/Wallet/popups/NetworkSelectPopup.qml @@ -112,12 +112,17 @@ Popup { asset.width: 24 asset.isImage: true asset.name: Style.svg(model.iconUrl) - onClicked: { + onClicked: { if(root.multiSelection) - checkBox.toggled() + toggleModelIsActive() else radioButton.toggle() } + + function toggleModelIsActive() { + model.isActive = !model.isActive + } + components: [ StatusCheckBox { id: checkBox @@ -125,7 +130,7 @@ Popup { checked: root.useNetworksExtraStoreProxy ? model.isActive : model.isEnabled onToggled: { if (root.useNetworksExtraStoreProxy) { - model.isActive = !model.isActive + toggleModelIsActive() } else { root.toggleNetwork(model) }