Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/return-wallet-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
Vorobeyko committed Sep 27, 2024
2 parents ffadafe + 42a4b47 commit 1f448c4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
9 changes: 5 additions & 4 deletions packages/wallets/src/metamask/metamask.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}

Expand Down Expand Up @@ -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);
});
}
Expand Down
29 changes: 21 additions & 8 deletions packages/wallets/src/metamask/pages/walletOperations.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")');
Expand All @@ -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() {
Expand Down Expand Up @@ -69,7 +75,7 @@ export class WalletOperationPage {
}

async signTransaction() {
await this.confirmSignButton.click();
await this.confirmButton.click();
}

async confirmTransactionOfTokenApproval() {
Expand All @@ -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);
}
Expand All @@ -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;
}
}

0 comments on commit 1f448c4

Please sign in to comment.