Skip to content

Commit

Permalink
fix: rework the cancel and confirm transaction function
Browse files Browse the repository at this point in the history
  • Loading branch information
jake4take committed Sep 30, 2024
1 parent d24f187 commit 53591c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 35 deletions.
14 changes: 1 addition & 13 deletions packages/wallets/src/metamask/metamask.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}

Expand Down
31 changes: 13 additions & 18 deletions packages/wallets/src/metamask/pages/walletOperations.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class WalletOperationPage {
page: Page;
nextButton: Locator;
confirmButton: Locator;
rejectButton: Locator;
approvalRejectButton: Locator;
cancelButton: Locator;
addTokenButton: Locator;
editGasFeeButton: Locator;
Expand All @@ -22,17 +22,17 @@ 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');
this.setHighGasFeeButton = this.page.getByTestId('edit-gas-fee-item-high');
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")',
);
Expand 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,
});
Expand All @@ -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() {
Expand Down
4 changes: 0 additions & 4 deletions packages/wallets/src/wallet.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ export interface WalletPage {

confirmTx(page: Page, setAggressiveGas?: boolean): Promise<void>;

signTx(page: Page): Promise<void>;

rejectTx?(page: Page): Promise<void>;

cancelSignTx?(page: Page): Promise<void>;

approveTokenTx?(page: Page): Promise<void>;

openLastTxInEthplorer?(txIndex?: number): Promise<Page>;
Expand Down

0 comments on commit 53591c2

Please sign in to comment.