diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index 735d5536..e00ea589 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -168,9 +168,10 @@ export class MetamaskPage implements WalletPage { async assertTxAmount(page: Page, expectedAmount: string) { await test.step('Assert TX Amount', async () => { - expect(await page.textContent('.currency-display-component__text')).toBe( - expectedAmount, - ); + const txAmount = await new WalletOperationPage(page).getTxAmount(); + if (txAmount) { + expect(txAmount).toBe(expectedAmount); + } }); } @@ -245,7 +246,7 @@ export class MetamaskPage implements WalletPage { await test.step('Assert receiptAddress/Contract', async () => { const recipientAddress = await new WalletOperationPage( page, - ).assertReceiptAddress(); + ).getReceiptAddress(); expect(recipientAddress).toBe(expectedAddress); }); } diff --git a/packages/wallets/src/metamask/pages/walletOperations.page.ts b/packages/wallets/src/metamask/pages/walletOperations.page.ts index 5a15cee7..dbd60b1c 100644 --- a/packages/wallets/src/metamask/pages/walletOperations.page.ts +++ b/packages/wallets/src/metamask/pages/walletOperations.page.ts @@ -3,7 +3,7 @@ import { Locator, Page, test } from '@playwright/test'; export class WalletOperationPage { page: Page; nextButton: Locator; - confirmSignButton: Locator; + confirmButton: Locator; rejectButton: Locator; cancelButton: Locator; addTokenButton: Locator; @@ -15,11 +15,13 @@ export class WalletOperationPage { recipientButton: Locator; recipientAddress: Locator; popoverCloseButton: Locator; + txDetailBlock: Locator; + txDetailAmount: Locator; constructor(page: Page) { this.page = page; this.nextButton = this.page.getByTestId('page-container-footer-next'); - this.confirmSignButton = this.page.getByTestId('confirm-footer-button'); + this.confirmButton = this.page.getByTestId('confirm-footer-button'); this.rejectButton = 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")'); @@ -34,11 +36,15 @@ export class WalletOperationPage { this.confirmRejectAllTxsButton = this.page.locator( 'button:has-text("Reject all")', ); - this.recipientButton = this.page.locator( - '.sender-to-recipient__party--recipient-with-address', - ); + this.recipientButton = this.page + .getByTestId('transaction-details-recipient-row') + .locator('.name'); this.recipientAddress = this.page.locator('input[id="address"]'); this.popoverCloseButton = this.page.locator('button[aria-label="Close"]'); + this.txDetailBlock = this.page.getByTestId('simulation-details-layout'); + this.txDetailAmount = this.txDetailBlock.getByTestId( + 'simulation-details-amount-pill', + ); } async rejectAllTxInQueue() { @@ -69,7 +75,7 @@ export class WalletOperationPage { } async signTransaction() { - await this.confirmSignButton.click(); + await this.confirmButton.click(); } async confirmTransactionOfTokenApproval() { @@ -89,10 +95,10 @@ export class WalletOperationPage { await this.page.mouse.move(1, 1); await this.setHighGasFeeButton.click(); } - await this.nextButton.click(); + await this.confirmButton.click(); } - async assertReceiptAddress() { + async getReceiptAddress() { while (!(await this.recipientButton.isEnabled())) { await this.page.waitForTimeout(100); } @@ -101,4 +107,11 @@ export class WalletOperationPage { await this.popoverCloseButton.click(); return recipientAddress; } + + async getTxAmount() { + if (await this.txDetailBlock.isVisible()) { + return await this.txDetailAmount.textContent(); + } + return null; + } }