Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cancel and confirm transaction function after MM version updated #189

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions packages/wallets/src/metamask/metamask.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
});
}
Expand All @@ -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
}
});
Expand Down 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) {
async cancelTx(page: Page) {
await test.step('Reject TX', async () => {
await new WalletOperationPage(page).rejectTransaction();
await new WalletOperationPage(page).cancelTransaction();
});
}

Expand Down
39 changes: 17 additions & 22 deletions packages/wallets/src/metamask/pages/walletOperations.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ export class WalletOperationPage {
page: Page;
nextButton: Locator;
confirmButton: Locator;
rejectButton: Locator;
approvalCancelButton: Locator;
cancelButton: Locator;
addTokenButton: Locator;
editGasFeeButton: Locator;
setHighGasFeeButton: Locator;
scrollRequestSignatureBlockButton: Locator;
rejectAllTxsButton: Locator;
cancelAllTxsButton: Locator;
confirmRejectAllTxsButton: Locator;
recipientButton: Locator;
recipientAddress: 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.approvalCancelButton = 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.cancelAllTxsButton = this.page.getByTestId('confirm-nav__reject-all');
this.confirmRejectAllTxsButton = this.page.locator(
'button:has-text("Reject all")',
);
Expand All @@ -47,35 +47,30 @@ export class WalletOperationPage {
);
}

async rejectAllTxInQueue() {
async cancelAllTxInQueue() {
//Is there is any tx in queue.
try {
await this.rejectButton.waitFor({
await this.cancelButton.waitFor({
state: 'visible',
timeout: 1000,
});
} catch (er) {
return;
}

if (await this.rejectAllTxsButton.isVisible()) {
await this.rejectAllTxsButton.click();
await this.confirmRejectAllTxsButton.click();
if (await this.cancelAllTxsButton.isVisible()) {
await this.cancelAllTxsButton.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() {
itaven marked this conversation as resolved.
Show resolved Hide resolved
try {
await this.cancelButton.click();
} catch {
await this.approvalCancelButton.click();
}
}

async confirmTransactionOfTokenApproval() {
Expand Down
6 changes: 1 addition & 5 deletions packages/wallets/src/wallet.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ 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>;
cancelTx?(page: Page): Promise<void>;

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

Expand Down
Loading