Skip to content

Commit

Permalink
Merge pull request #167 from lidofinance/rejectTx
Browse files Browse the repository at this point in the history
reject tx
  • Loading branch information
itaven committed Jul 4, 2024
2 parents ac72e2c + 0b4fb8e commit 53d7e44
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions packages/wallets/src/metamask/metamask.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WalletConfig } from '../wallets.constants';
import { WalletPage } from '../wallet.page';
import expect from 'expect';
import { expect } from '@playwright/test';
import { test, BrowserContext, Page, Locator } from '@playwright/test';

export class MetamaskPage implements WalletPage {
Expand Down Expand Up @@ -114,11 +114,33 @@ export class MetamaskPage implements WalletPage {
if (await this.page.getByText('Not right now').isVisible())
await this.page.click('text=Not right now');

const gotItBtn = await this.page.getByText('Got it');
const gotItBtn = this.page.getByText('Got it');
if (await gotItBtn.first().isVisible()) await gotItBtn.first().click();

// reject all tx in queue if exist
await this.rejectAllTxInQueue();
});
}

async rejectAllTxInQueue() {
//Is there is any tx in queue.
try {
const rejectTxBtn = this.page.getByTestId('page-container-footer-cancel');
await rejectTxBtn.waitFor({ state: 'visible', timeout: 1000 });
} catch (error) {
//No tx in queue
return;
}

const rejectTxsBtn = this.page.locator(
'div[class="page-container__footer-secondary"]',
);
if (await rejectTxsBtn.isVisible()) {
await rejectTxsBtn.click();
await this.page.locator('button:has-text("Reject all")').click();
} else await this.rejectTx(this.page);
}

async firstTimeSetup() {
await test.step('First time setup', async () => {
if (!this.page) throw "Page isn't ready";
Expand Down Expand Up @@ -342,7 +364,7 @@ export class MetamaskPage implements WalletPage {

async rejectTx(page: Page) {
await test.step('Reject TX', async () => {
await page.click('text=Reject');
await page.getByTestId('page-container-footer-cancel').click();
});
}

Expand Down

0 comments on commit 53d7e44

Please sign in to comment.