fix(@desktop/wallet): Fix tests for saved addresses.

Minor fixes

Updates: #8599
This commit is contained in:
Ivan Belyakov 2023-03-06 15:30:58 +03:00 committed by IvanBelyakoff
parent e27f2ec667
commit 601d3dd0f1
6 changed files with 35 additions and 17 deletions

View File

@ -43,6 +43,14 @@ def is_loaded_visible_and_enabled(objName: str, timeout: int=_MAX_WAIT_OBJ_TIMEO
except LookupError: except LookupError:
return False, obj 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: # 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. # It returns a tuple: True in case it is found. Otherwise, false. And the object itself.

View File

@ -44,6 +44,7 @@ class SavedAddressesScreen(Enum):
class AddSavedAddressPopup(Enum): class AddSavedAddressPopup(Enum):
NAME_INPUT: str = "mainWallet_Saved_Addreses_Popup_Name_Input" NAME_INPUT: str = "mainWallet_Saved_Addreses_Popup_Name_Input"
ADDRESS_INPUT: str = "mainWallet_Saved_Addreses_Popup_Address_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" ADD_BUTTON: str = "mainWallet_Saved_Addreses_Popup_Address_Add_Button"
class SendPopup(Enum): class SendPopup(Enum):
@ -218,7 +219,11 @@ class StatusWalletScreen:
click_obj_by_name(MainWalletScreen.SAVED_ADDRESSES_BUTTON.value) click_obj_by_name(MainWalletScreen.SAVED_ADDRESSES_BUTTON.value)
click_obj_by_name(SavedAddressesScreen.ADD_BUTTON.value) click_obj_by_name(SavedAddressesScreen.ADD_BUTTON.value)
type_text(AddSavedAddressPopup.NAME_INPUT.value, name) 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) click_obj_by_name(AddSavedAddressPopup.ADD_BUTTON.value)
def _get_saved_address_delegate_item(self, name: str): 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): def _find_saved_address_and_open_menu(self, name: str):
item = self._get_saved_address_delegate_item(name) item = self._get_saved_address_delegate_item(name)
obj = get_child_item_with_object_name(item, SavedAddressesScreen.DELEGATE_MENU_BUTTON_OBJECT_NAME.value) menuButton = get_child_item_with_object_name(item, f"{SavedAddressesScreen.DELEGATE_MENU_BUTTON_OBJECT_NAME.value}_{name}")
click_obj(obj) is_object_loaded_visible_and_enabled(menuButton)
click_obj(menuButton)
def edit_saved_address(self, name: str, new_name: str): def edit_saved_address(self, name: str, new_name: str):
self._find_saved_address_and_open_menu(name) self._find_saved_address_and_open_menu(name)
@ -252,17 +258,15 @@ class StatusWalletScreen:
def toggle_favourite_for_saved_address(self, name: str): def toggle_favourite_for_saved_address(self, name: str):
# Find the saved address and click favourite to toggle # Find the saved address and click favourite to toggle
item = self._get_saved_address_delegate_item(name) 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) click_obj(favouriteButton)
def check_favourite_status_for_saved_address(self, name: str, favourite: bool): def check_favourite_status_for_saved_address(self, name: str, favourite: bool):
# Find the saved address # Find the saved address
item = self._get_saved_address_delegate_item(name) 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
wait_for_prop_value(favouriteButton, "asset.name", ("star-icon" if favourite else "favourite"))
# 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 ""))
def toggle_network(self, network_name: str): def toggle_network(self, network_name: str):
is_loaded_visible_and_enabled(MainWalletScreen.NETWORK_SELECTOR_BUTTON.value, 2000) is_loaded_visible_and_enabled(MainWalletScreen.NETWORK_SELECTOR_BUTTON.value, 2000)

View File

@ -76,7 +76,8 @@ mainWallet_Saved_Addreses_More_Confirm_Delete = {"container": statusDesktop_main
# saved address add popup # saved address add popup
mainWallet_Saved_Addreses_Popup_Name_Input = {"container": statusDesktop_mainWindow, "objectName": "savedAddressNameInput", "type": "TextEdit"} 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"} mainWallet_Saved_Addreses_Popup_Address_Add_Button = {"container": statusDesktop_mainWindow, "objectName": "addSavedAddress", "type": "StatusButton"}
# Collectibles view # Collectibles view

View File

@ -72,7 +72,7 @@ StatusListItem {
onClicked: openSendModal(d.visibleAddress) onClicked: openSendModal(d.visibleAddress)
}, },
StatusRoundButton { StatusRoundButton {
objectName: "savedAddressView_Delegate_menuButton" objectName: "savedAddressView_Delegate_menuButton_" + root.name
visible: !!root.name visible: !!root.name
icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1 icon.color: root.showButtons ? Theme.palette.directColor1 : Theme.palette.baseColor1
type: StatusRoundButton.Type.Quinary type: StatusRoundButton.Type.Quinary

View File

@ -105,7 +105,6 @@ StatusDialog {
] ]
input.clearable: true input.clearable: true
input.rightPadding: 16 input.rightPadding: 16
charLimit: 40
validationMode: d.validationMode validationMode: d.validationMode
} }
@ -113,8 +112,9 @@ StatusDialog {
id: addressInput id: addressInput
implicitWidth: parent.width implicitWidth: parent.width
label: qsTr("Address") label: qsTr("Address")
input.edit.objectName: "savedAddressAddressInput" objectName: "savedAddressAddressInput"
placeholderText: qsTr("Ethereum Address") input.edit.objectName: "savedAddressAddressInputEdit"
placeholderText: qsTr("Ethereum address")
maximumHeight: 66 maximumHeight: 66
input.implicitHeight: Math.min(Math.max(input.edit.contentHeight + topPadding + bottomPadding, minimumHeight), maximumHeight) // setting height instead does not work input.implicitHeight: Math.min(Math.max(input.edit.contentHeight + topPadding + bottomPadding, minimumHeight), maximumHeight) // setting height instead does not work
enabled: !(root.edit || root.addAddress) enabled: !(root.edit || root.addAddress)

View File

@ -114,10 +114,15 @@ Popup {
asset.name: Style.svg(model.iconUrl) asset.name: Style.svg(model.iconUrl)
onClicked: { onClicked: {
if(root.multiSelection) if(root.multiSelection)
checkBox.toggled() toggleModelIsActive()
else else
radioButton.toggle() radioButton.toggle()
} }
function toggleModelIsActive() {
model.isActive = !model.isActive
}
components: [ components: [
StatusCheckBox { StatusCheckBox {
id: checkBox id: checkBox
@ -125,7 +130,7 @@ Popup {
checked: root.useNetworksExtraStoreProxy ? model.isActive : model.isEnabled checked: root.useNetworksExtraStoreProxy ? model.isActive : model.isEnabled
onToggled: { onToggled: {
if (root.useNetworksExtraStoreProxy) { if (root.useNetworksExtraStoreProxy) {
model.isActive = !model.isActive toggleModelIsActive()
} else { } else {
root.toggleNetwork(model) root.toggleNetwork(model)
} }