From 3284c696f25b2ecd199ea6e971ea77962dfd256b 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 fixes #7983 --- test/ui-test/src/screens/SettingsScreen.py | 2 + .../ui-test/src/screens/StatusWalletScreen.py | 45 ++++++++++++------- .../global_shared/scripts/settings_names.py | 2 +- .../shared/scripts/wallet_names.py | 3 +- .../testSuites/suite_wallet/suite.conf | 2 + .../suite_wallet/tst_transaction/bdd_hooks.py | 3 +- .../suite_wallet/tst_transaction/test.feature | 17 ++++--- .../AppLayouts/Wallet/views/LeftTabView.qml | 1 + ui/app/mainui/AppMain.qml | 1 + ui/imports/shared/popups/SendModal.qml | 15 ++++--- 10 files changed, 56 insertions(+), 35 deletions(-) diff --git a/test/ui-test/src/screens/SettingsScreen.py b/test/ui-test/src/screens/SettingsScreen.py index 0cabbb7e5ee..daf7170b4d7 100644 --- a/test/ui-test/src/screens/SettingsScreen.py +++ b/test/ui-test/src/screens/SettingsScreen.py @@ -169,6 +169,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 77b309da03d..77aa4fa3015 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_RETRY: str = "mailserver_retry" FIRST_ACCOUNT_ITEM: str = "firstWalletAccount_Item" + 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" @@ -184,11 +184,12 @@ def verify_account_name_is_present(self, account_name: str): click_obj_by_name(AddAccountPopup.ADD_ACCOUNT_BUTTON.value) 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) + list = get_obj(AssetView.LIST.value) + squish.waitFor("list.count > 0", 60*1000*2) + squish.waitFor("float(str(list.itemAtIndex(0).balance)) > 0", 60*1000*2) + self._click_repeater(SendPopup.HEADER_ACCOUNTS_LIST.value, account_name) time.sleep(1) type(SendPopup.AMOUNT_INPUT.value, amount) @@ -207,22 +208,27 @@ def send_transaction(self, account_name, amount, token, chain_name, password): accounts = get_obj(SendPopup.MY_ACCOUNTS_LIST.value) for index in range(accounts.count): if(accounts.itemAtIndex(index).objectName == account_name): + print("WE FOUND THE ACCOUNT") click_obj(accounts.itemAtIndex(index)) break - + time.sleep(5) + scroll_obj_by_name(SendPopup.SCROLL_BAR.value) - time.sleep(1) + time.sleep(5) + o = get_obj(SendPopup.SEND_BUTTON.value) + print("TESTING") + print(o.objectName) + print(o.visible) - 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) - + o = get_obj(SendPopup.SEND_BUTTON.value) + print(o.objectName) + print(o.visible) + + 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): @@ -350,7 +356,12 @@ 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) + print("HELLO WORLD") + print(ephemeral_notification_list.itemAtIndex(0).objectName) + print(ephemeral_notification_list.itemAtIndex(0).primaryText) + 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 c78721c2afd..fa5bca09f1c 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"} @@ -25,6 +26,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"} @@ -33,7 +35,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/suite.conf b/test/ui-test/testSuites/suite_wallet/suite.conf index 0e0d08193b0..8cdb247b067 100644 --- a/test/ui-test/testSuites/suite_wallet/suite.conf +++ b/test/ui-test/testSuites/suite_wallet/suite.conf @@ -1,5 +1,7 @@ AUT=nim_status_client ENVVARS=envvars +HOOK_SUB_PROCESSES=false +IMPLICITAUTSTART=0 LANGUAGE=Python OBJECTMAPSTYLE=script TEST_CASES=tst_wallet tst_transaction diff --git a/test/ui-test/testSuites/suite_wallet/tst_transaction/bdd_hooks.py b/test/ui-test/testSuites/suite_wallet/tst_transaction/bdd_hooks.py index 224293fbced..4228b5d7736 100644 --- a/test/ui-test/testSuites/suite_wallet/tst_transaction/bdd_hooks.py +++ b/test/ui-test/testSuites/suite_wallet/tst_transaction/bdd_hooks.py @@ -16,8 +16,7 @@ def hook(context): common_init_steps.context_init(context) common_init_steps.signs_up_with_seed_phrase_process_steps(context, _seed_phrase, _user, _password) - wallet_init_steps.enable_wallet_section() - wallet_init_steps.toggle_test_networks() + wallet_init_steps.activate_and_open_wallet() @OnFeatureEnd def hook(context): 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 ab626bdffb5..e345920939a 100644 --- a/test/ui-test/testSuites/suite_wallet/tst_transaction/test.feature +++ b/test/ui-test/testSuites/suite_wallet/tst_transaction/test.feature @@ -16,22 +16,21 @@ Feature: Status Desktop Transaction ** and the user opens wallet screen ** and the user accepts the signing phrase - Background: Navigation to main wallet screen +# Background: Navigation to main wallet screen +# Given the user opens wallet screen +# And the user clicks on the first account - Given the user opens wallet screen - And the user clicks on the first account - - @mayfail Scenario Outline: The user sends a transaction + Then the user has a positive balance of "ETH" When the user sends a transaction to himself from account "Status account" of "" "" on "" with password "qqqqqqqqqq" Then the transaction is in progress Examples: | amount | token | chain_name | - | 1 | ETH | Goerli | - | 0 | ETH | Goerli | - | 1 | STT | Goerli | - | 0 | STT | Goerli | + | 0.1 | ETH | Goerli | + #| 0 | ETH | Goerli | + #| 1 | STT | Goerli | + #| 0 | STT | Goerli | @mayfail Scenario: The user registers an ENS name diff --git a/ui/app/AppLayouts/Wallet/views/LeftTabView.qml b/ui/app/AppLayouts/Wallet/views/LeftTabView.qml index 4835dc35330..53b70df9081 100644 --- a/ui/app/AppLayouts/Wallet/views/LeftTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/LeftTabView.qml @@ -79,6 +79,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 5136404dc68..6cf6da5981b 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1209,6 +1209,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 9b9dac4aa12..389192a9eec 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 @@ -517,7 +522,7 @@ StatusDialog { footer: SendModalFooter { maxFiatFees: popup.isLoading ? "..." : gasSelector.selectedGasFiatValue selectedTimeEstimate: popup.isLoading? "..." : gasSelector.selectedTimeEstimate - pending: d.isPendingTx + pending: d.isPendingTx || popup.isLoading visible: d.isReady && !isNaN(amountToSendInput.text) && gasValidator.isValid && !d.errorMode onNextButtonClicked: popup.sendTransaction() }