From ee131bfd95da58b6158a9de0dd7c4afe1fb8e081 Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Thu, 20 Oct 2022 14:58:56 +0200 Subject: [PATCH] test: Renabled test case for Simple transaction --- test/ui-test/src/screens/SettingsScreen.py | 2 ++ .../ui-test/src/screens/StatusWalletScreen.py | 27 +++++++++---------- .../global_shared/scripts/settings_names.py | 2 +- .../shared/scripts/wallet_names.py | 3 ++- .../suite_wallet/tst_transaction/test.feature | 1 - .../AppLayouts/Wallet/views/LeftTabView.qml | 1 + ui/app/mainui/AppMain.qml | 1 + ui/imports/shared/popups/SendModal.qml | 13 ++++++--- 8 files changed, 28 insertions(+), 22 deletions(-) diff --git a/test/ui-test/src/screens/SettingsScreen.py b/test/ui-test/src/screens/SettingsScreen.py index c4df1d59c25..5f8db52a1d0 100644 --- a/test/ui-test/src/screens/SettingsScreen.py +++ b/test/ui-test/src/screens/SettingsScreen.py @@ -174,6 +174,8 @@ def check_tenor_gif_preview_is_enabled(self): verify(tenorSwitch.enabled, "Tenor GIFs preview is enabled") def toggle_test_networks(self): + # needed cause if we do it immmediately the toggle doesn't work + time.sleep(2) click_obj_by_name(WalletSettingsScreen.NETWORKS_ITEM.value) click_obj_by_name(WalletSettingsScreen.TESTNET_TOGGLE.value) diff --git a/test/ui-test/src/screens/StatusWalletScreen.py b/test/ui-test/src/screens/StatusWalletScreen.py index 157d251bda4..aa7fae00a2b 100644 --- a/test/ui-test/src/screens/StatusWalletScreen.py +++ b/test/ui-test/src/screens/StatusWalletScreen.py @@ -23,6 +23,8 @@ class MainWalletScreen(Enum): RIGHT_SIDE_TABBAR: str = "mainWallet_Right_Side_Tab_Bar" MAILSERVER_DIALOG: str = "mailserver_dialog" MAILSERVER_RETRY: str = "mailserver_retry" + EPHEMERAL_NOTIFICATION_LIST: str = "mainWallet_Ephemeral_Notification_List" + TOTAL_CURRENCY_BALANCE: str = "mainWallet_totalCurrencyBalance" class AssetView(Enum): LIST: str = "mainWallet_Assets_View_List" @@ -48,12 +50,10 @@ class SendPopup(Enum): SCROLL_BAR: str = "mainWallet_Send_Popup_Main" HEADER_ACCOUNTS_LIST: str = "mainWallet_Send_Popup_Header_Accounts" AMOUNT_INPUT: str = "mainWallet_Send_Popup_Amount_Input" - GAS_PRICE_INPUT: str = "mainWallet_Send_Popup_GasPrice_Input" MY_ACCOUNTS_TAB: str = "mainWallet_Send_Popup_My_Accounts_Tab" MY_ACCOUNTS_LIST: str = "mainWallet_Send_Popup_My_Accounts_List" NETWORKS_LIST: str = "mainWallet_Send_Popup_Networks_List" SEND_BUTTON: str = "mainWallet_Send_Popup_Send_Button" - PASSWORD_INPUT: str = "mainWallet_Send_Popup_Password_Input" ASSET_SELECTOR: str = "mainWallet_Send_Popup_Asset_Selector" ASSET_LIST: str = "mainWallet_Send_Popup_Asset_List" HIGH_GAS_BUTTON: str = "mainWallet_Send_Popup_GasSelector_HighGas_Button" @@ -175,11 +175,10 @@ def verify_account_name_is_present(self, account_name: str): verify_text_matching(MainWalletScreen.ACCOUNT_NAME.value, account_name) def send_transaction(self, account_name, amount, token, chain_name, password): - # TODO wait for balance to update - # Maybe needs a fix on the app itself. Make the Send modal be responsive to when the balance updates - time.sleep(2) click_obj_by_name(MainWalletScreen.SEND_BUTTON_FOOTER.value) + squish.waitFor("float(str(wait_and_get_obj(MainWalletScreen.TOTAL_CURRENCY_BALANCE.value).text).split(' ')[0]) > 0", 60*1000) + self._click_repeater(SendPopup.HEADER_ACCOUNTS_LIST.value, account_name) time.sleep(1) type(SendPopup.AMOUNT_INPUT.value, amount) @@ -204,16 +203,12 @@ def send_transaction(self, account_name, amount, token, chain_name, password): scroll_obj_by_name(SendPopup.SCROLL_BAR.value) time.sleep(1) - self._click_repeater(SendPopup.NETWORKS_LIST.value, chain_name) - - # With the simulator, the gas price estimation doesn't work - type(SendPopup.GAS_PRICE_INPUT.value, "20") - click_obj_by_name(SendPopup.SEND_BUTTON.value) - - type(SendPopup.PASSWORD_INPUT.value, password) - click_obj_by_name(SendPopup.SEND_BUTTON.value) - + + wait_for_object_and_type(SharedPopup.PASSWORD_INPUT.value, password) + + click_obj_by_name(SharedPopup.PRIMARY_BUTTON.value) + def _click_repeater(self, repeater_object_name: str, object_name: str): repeater = get_obj(repeater_object_name) for index in range(repeater.count): @@ -330,7 +325,9 @@ def verify_saved_address_doesnt_exist(self, name: str): verify_failure(f'FAIL: saved address {name} exists') def verify_transaction(self): - print("TODO: fix notification and ensure there is one") + ephemeral_notification_list = get_obj(MainWalletScreen.EPHEMERAL_NOTIFICATION_LIST.value) + squish.waitFor("ephemeral_notification_list.count > 0", 60*1000) + verify(str(ephemeral_notification_list.itemAtIndex(0).primaryText ) == "Transaction pending...", "Tx was not sent!") def verify_collectibles_exist(self, account_name: str): tabbar = get_obj(MainWalletScreen.RIGHT_SIDE_TABBAR.value) diff --git a/test/ui-test/testSuites/global_shared/scripts/settings_names.py b/test/ui-test/testSuites/global_shared/scripts/settings_names.py index 40d030101a6..a1ee3e0a2b1 100644 --- a/test/ui-test/testSuites/global_shared/scripts/settings_names.py +++ b/test/ui-test/testSuites/global_shared/scripts/settings_names.py @@ -29,7 +29,7 @@ class SettingsSubsection(Enum): # Main: navBarListView_Settings_navbar_StatusNavBarTabButton = {"checkable": True, "container": mainWindow_navBarListView_ListView, "objectName": "Settings-navbar", "type": "StatusNavBarTabButton", "visible": True} settingsSave_StatusButton = {"container": statusDesktop_mainWindow, "objectName": "settingsDirtyToastMessageSaveButton", "type": "StatusButton", "visible": True} -settings_Sidebar_ENS_Item = {"container": mainWindow_ScrollView, "objectName": "ENS usernames-MainMenu", "type": "StatusNavigationListItem"} +settings_Sidebar_ENS_Item = {"container": mainWindow_ScrollView, "objectName": SettingsSubsection.ENS_USERNAMES.value, "type": "StatusNavigationListItem"} # ENS view; settings_ENS_Start_Button = {"container": statusDesktop_mainWindow, "objectName": "ensStartButton", "type": "StatusButton"} 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 874e531efa9..c32ad693347 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 @@ -10,6 +10,7 @@ mainWallet_Saved_Addresses_Button = {"container": statusDesktop_mainWindow, "objectName": "savedAddressesBtn", "type": "StatusButton"} mainWallet_Network_Selector_Button = {"container": statusDesktop_mainWindow, "objectName": "networkSelectorButton", "type": "StatusListItem"} mainWallet_Right_Side_Tab_Bar = {"container": statusDesktop_mainWindow, "objectName": "rightSideWalletTabBar", "type": "StatusTabBar"} +mainWallet_Ephemeral_Notification_List = {"container": statusDesktop_mainWindow, "objectName": "ephemeralNotificationList", "type": "StatusListView"} mailserver_dialog = {"container": statusDesktop_mainWindow_overlay, "objectName": "mailserverConnectionDialog", "type": "StatusDialog"} mailserver_retry = {"container": mailserver_dialog, "objectName": "mailserverConnectionDialog_retryButton", "type": "StatusButton"} @@ -21,6 +22,7 @@ mainWallet_Network_Popup_Chain_Repeater_1 = {"container": statusDesktop_mainWindow, "objectName": "networkSelectPopupChainRepeaterLayer1", "type": "Repeater"} # Send popup: +mainWallet_totalCurrencyBalance = {"container": statusDesktop_mainWindow, "objectName": "walletLeftListAmountValue", "type": "StyledTextEdit"} mainWallet_Footer_Send_Button = {"container": statusDesktop_mainWindow, "objectName": "walletFooterSendButton", "type": "StatusFlatButton"} mainWallet_Send_Popup_Main = {"container": statusDesktop_mainWindow, "objectName": "sendModalScroll", "type": "StatusScrollView"} mainWallet_Send_Popup_Amount_Input = {"container": statusDesktop_mainWindow, "objectName": "amountInput", "type": "TextEdit"} @@ -29,7 +31,6 @@ mainWallet_Send_Popup_Header_Accounts = {"container": statusDesktop_mainWindow, "objectName": "accountsListFloatingHeader", "type": "Repeater"} mainWallet_Send_Popup_Networks_List = {"container": statusDesktop_mainWindow, "objectName": "networksList", "type": "Repeater"} mainWallet_Send_Popup_Send_Button = {"container": statusDesktop_mainWindow, "objectName": "sendModalFooterSendButton", "type": "StatusFlatButton"} -mainWallet_Send_Popup_Password_Input = {"container": statusDesktop_mainWindow, "objectName": "transactionSignerPasswordInput", "type": "StyledTextField"} mainWallet_Send_Popup_Asset_Selector = {"container": statusDesktop_mainWindow, "objectName": "assetSelectorButton", "type": "StatusComboBox"} mainWallet_Send_Popup_Asset_List = {"container": statusDesktop_mainWindow, "objectName": "assetSelectorList", "type": "StatusListView"} mainWallet_Send_Popup_GasPrice_Input = {"container": statusDesktop_mainWindow, "objectName": "gasPriceSelectorInput", "type": "StyledTextField"} diff --git a/test/ui-test/testSuites/suite_wallet/tst_transaction/test.feature b/test/ui-test/testSuites/suite_wallet/tst_transaction/test.feature index 2d071373a24..c15009ad81a 100644 --- a/test/ui-test/testSuites/suite_wallet/tst_transaction/test.feature +++ b/test/ui-test/testSuites/suite_wallet/tst_transaction/test.feature @@ -14,7 +14,6 @@ Feature: Status Desktop Transaction And the user opens wallet screen And the user accepts the signing phrase - @mayfail Scenario Outline: User sends a transaction When the user sends a transaction to himself from account Status account of on with password qqqqqqqqqq Then the transaction is in progress diff --git a/ui/app/AppLayouts/Wallet/views/LeftTabView.qml b/ui/app/AppLayouts/Wallet/views/LeftTabView.qml index e5f7a7f5f17..a6bd8009d94 100644 --- a/ui/app/AppLayouts/Wallet/views/LeftTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/LeftTabView.qml @@ -56,6 +56,7 @@ Rectangle { StyledTextEdit { id: walletAmountValue + objectName: "walletLeftListAmountValue" color: Style.current.textColor text: { Utils.toLocaleString(parseFloat(RootStore.totalCurrencyBalance).toFixed(2), localAppSettings.language, {"currency": true}) + " " + RootStore.currentCurrency.toUpperCase() diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 32809786aa1..ee1a1e85bd1 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1178,6 +1178,7 @@ Item { StatusListView { id: toastArea + objectName: "ephemeralNotificationList" anchors.right: parent.right anchors.rightMargin: 8 anchors.bottom: parent.bottom diff --git a/ui/imports/shared/popups/SendModal.qml b/ui/imports/shared/popups/SendModal.qml index f74dd4c1720..22057944618 100644 --- a/ui/imports/shared/popups/SendModal.qml +++ b/ui/imports/shared/popups/SendModal.qml @@ -44,6 +44,14 @@ StatusDialog { standardButtons: StandardButton.Ok } + Connections { + target: store.currentAccount.assets + onModelReset: { + popup.selectedAccount = null + popup.selectedAccount = store.currentAccount + } + } + property var sendTransaction: function() { let recipientAddress = Utils.isValidAddress(popup.addressText) ? popup.addressText : d.resolvedENSAddress d.isPendingTx = true @@ -76,10 +84,7 @@ StatusDialog { QtObject { id: d - readonly property double maxFiatBalance: { - console.error(assetSelector.selectedAsset.name," >>> recalaculayte maxFiatBalance = ", assetSelector.selectedAsset.totalBalance) - return assetSelector.selectedAsset ? assetSelector.selectedAsset.totalBalance: 0 - } + readonly property double maxFiatBalance: assetSelector.selectedAsset ? assetSelector.selectedAsset.totalBalance: 0 readonly property bool isReady: amountToSendInput.valid && !amountToSendInput.pending && recipientReady readonly property bool errorMode: (networkSelector.bestRoutes && networkSelector.bestRoutes.length <= 0) || networkSelector.errorMode || isNaN(amountToSendInput.text) readonly property bool recipientReady: (isAddressValid || isENSValid) && !recipientSelector.isPending