From 53591c2e795f30039628c45710772f6abe27c6f4 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 30 Sep 2024 14:09:55 +0300 Subject: [PATCH 1/2] fix: rework the cancel and confirm transaction function --- .../wallets/src/metamask/metamask.page.ts | 14 +-------- .../metamask/pages/walletOperations.page.ts | 31 ++++++++----------- packages/wallets/src/wallet.page.ts | 4 --- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index 2d6f1a40..2e5678e0 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -218,21 +218,9 @@ export class MetamaskPage implements WalletPage { }); } - async signTx(page: Page) { - await test.step('Sign TX', async () => { - await new WalletOperationPage(page).signTransaction(); - }); - } - - async cancelSignTx(page: Page) { - await test.step('Cancel Sign TX', async () => { - await new WalletOperationPage(page).cancelSignTransaction(); - }); - } - async rejectTx(page: Page) { await test.step('Reject TX', async () => { - await new WalletOperationPage(page).rejectTransaction(); + await new WalletOperationPage(page).cancelTransaction(); }); } diff --git a/packages/wallets/src/metamask/pages/walletOperations.page.ts b/packages/wallets/src/metamask/pages/walletOperations.page.ts index dbd60b1c..d61edbba 100644 --- a/packages/wallets/src/metamask/pages/walletOperations.page.ts +++ b/packages/wallets/src/metamask/pages/walletOperations.page.ts @@ -4,7 +4,7 @@ export class WalletOperationPage { page: Page; nextButton: Locator; confirmButton: Locator; - rejectButton: Locator; + approvalRejectButton: Locator; cancelButton: Locator; addTokenButton: Locator; editGasFeeButton: Locator; @@ -22,7 +22,9 @@ export class WalletOperationPage { this.page = page; this.nextButton = this.page.getByTestId('page-container-footer-next'); this.confirmButton = this.page.getByTestId('confirm-footer-button'); - this.rejectButton = this.page.getByTestId('page-container-footer-cancel'); + this.approvalRejectButton = this.page.getByTestId( + 'page-container-footer-cancel', + ); this.cancelButton = this.page.getByTestId('confirm-footer-cancel-button'); this.addTokenButton = this.page.locator('button:has-text("Add token")'); this.editGasFeeButton = this.page.getByTestId('edit-gas-fee-icon'); @@ -30,9 +32,7 @@ export class WalletOperationPage { this.scrollRequestSignatureBlockButton = this.page.getByTestId( 'signature-request-scroll-button', ); - this.rejectAllTxsButton = this.page.locator( - 'div[class="page-container__footer-secondary"]', - ); + this.rejectAllTxsButton = this.page.getByTestId('confirm-nav__reject-all'); this.confirmRejectAllTxsButton = this.page.locator( 'button:has-text("Reject all")', ); @@ -50,7 +50,7 @@ export class WalletOperationPage { async rejectAllTxInQueue() { //Is there is any tx in queue. try { - await this.rejectButton.waitFor({ + await this.cancelButton.waitFor({ state: 'visible', timeout: 1000, }); @@ -60,22 +60,17 @@ export class WalletOperationPage { if (await this.rejectAllTxsButton.isVisible()) { await this.rejectAllTxsButton.click(); - await this.confirmRejectAllTxsButton.click(); } else { - await this.rejectButton.click(); + await this.cancelButton.click(); } } - async rejectTransaction() { - await this.rejectButton.click(); - } - - async cancelSignTransaction() { - await this.cancelButton.click(); - } - - async signTransaction() { - await this.confirmButton.click(); + async cancelTransaction() { + try { + await this.cancelButton.click(); + } catch { + await this.approvalRejectButton.click(); + } } async confirmTransactionOfTokenApproval() { diff --git a/packages/wallets/src/wallet.page.ts b/packages/wallets/src/wallet.page.ts index b42478ad..d4c81191 100644 --- a/packages/wallets/src/wallet.page.ts +++ b/packages/wallets/src/wallet.page.ts @@ -15,12 +15,8 @@ export interface WalletPage { confirmTx(page: Page, setAggressiveGas?: boolean): Promise; - signTx(page: Page): Promise; - rejectTx?(page: Page): Promise; - cancelSignTx?(page: Page): Promise; - approveTokenTx?(page: Page): Promise; openLastTxInEthplorer?(txIndex?: number): Promise; From 5a3e6cc43e5166eb793f404e24da805baf4526e3 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 30 Sep 2024 15:24:13 +0300 Subject: [PATCH 2/2] chore: rename the button name from reject to cancel --- packages/wallets/src/metamask/metamask.page.ts | 6 +++--- .../src/metamask/pages/walletOperations.page.ts | 16 ++++++++-------- packages/wallets/src/wallet.page.ts | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index 2e5678e0..26e4af72 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -58,7 +58,7 @@ export class MetamaskPage implements WalletPage { await this.loginPage.unlock(); if (await this.header.networkListButton.isVisible()) { await this.popoverElements.closePopover(); - await this.walletOperation.rejectAllTxInQueue(); // reject all tx in queue if exist + await this.walletOperation.cancelAllTxInQueue(); // reject all tx in queue if exist } }); } @@ -70,7 +70,7 @@ export class MetamaskPage implements WalletPage { if (!(await this.header.networkListButton.isVisible())) { await this.onboardingPage.firstTimeSetup(); await this.popoverElements.closePopover(); - await this.walletOperation.rejectAllTxInQueue(); // reject all tx in queue if exist + await this.walletOperation.cancelAllTxInQueue(); // reject all tx in queue if exist await this.settingsPage.setupNetworkChangingSetting(); // need to make it possible to change the wallet network } }); @@ -218,7 +218,7 @@ export class MetamaskPage implements WalletPage { }); } - async rejectTx(page: Page) { + async cancelTx(page: Page) { await test.step('Reject TX', async () => { await new WalletOperationPage(page).cancelTransaction(); }); diff --git a/packages/wallets/src/metamask/pages/walletOperations.page.ts b/packages/wallets/src/metamask/pages/walletOperations.page.ts index d61edbba..e37641bb 100644 --- a/packages/wallets/src/metamask/pages/walletOperations.page.ts +++ b/packages/wallets/src/metamask/pages/walletOperations.page.ts @@ -4,13 +4,13 @@ export class WalletOperationPage { page: Page; nextButton: Locator; confirmButton: Locator; - approvalRejectButton: Locator; + approvalCancelButton: Locator; cancelButton: Locator; addTokenButton: Locator; editGasFeeButton: Locator; setHighGasFeeButton: Locator; scrollRequestSignatureBlockButton: Locator; - rejectAllTxsButton: Locator; + cancelAllTxsButton: Locator; confirmRejectAllTxsButton: Locator; recipientButton: Locator; recipientAddress: Locator; @@ -22,7 +22,7 @@ export class WalletOperationPage { this.page = page; this.nextButton = this.page.getByTestId('page-container-footer-next'); this.confirmButton = this.page.getByTestId('confirm-footer-button'); - this.approvalRejectButton = this.page.getByTestId( + this.approvalCancelButton = this.page.getByTestId( 'page-container-footer-cancel', ); this.cancelButton = this.page.getByTestId('confirm-footer-cancel-button'); @@ -32,7 +32,7 @@ export class WalletOperationPage { this.scrollRequestSignatureBlockButton = this.page.getByTestId( 'signature-request-scroll-button', ); - this.rejectAllTxsButton = this.page.getByTestId('confirm-nav__reject-all'); + this.cancelAllTxsButton = this.page.getByTestId('confirm-nav__reject-all'); this.confirmRejectAllTxsButton = this.page.locator( 'button:has-text("Reject all")', ); @@ -47,7 +47,7 @@ export class WalletOperationPage { ); } - async rejectAllTxInQueue() { + async cancelAllTxInQueue() { //Is there is any tx in queue. try { await this.cancelButton.waitFor({ @@ -58,8 +58,8 @@ export class WalletOperationPage { return; } - if (await this.rejectAllTxsButton.isVisible()) { - await this.rejectAllTxsButton.click(); + if (await this.cancelAllTxsButton.isVisible()) { + await this.cancelAllTxsButton.click(); } else { await this.cancelButton.click(); } @@ -69,7 +69,7 @@ export class WalletOperationPage { try { await this.cancelButton.click(); } catch { - await this.approvalRejectButton.click(); + await this.approvalCancelButton.click(); } } diff --git a/packages/wallets/src/wallet.page.ts b/packages/wallets/src/wallet.page.ts index d4c81191..0b74165f 100644 --- a/packages/wallets/src/wallet.page.ts +++ b/packages/wallets/src/wallet.page.ts @@ -15,7 +15,7 @@ export interface WalletPage { confirmTx(page: Page, setAggressiveGas?: boolean): Promise; - rejectTx?(page: Page): Promise; + cancelTx?(page: Page): Promise; approveTokenTx?(page: Page): Promise;