Skip to content

Commit a31d808

Browse files
authored
test: [POM] Migrate Send tx Revoke Permissions spec (#29273)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** - Migrates `test/e2e/tests/request-queuing/sendTx-revokePermissions.spec.js` spec to POM and ts - Updates method classes to accommodate new functions needed in this spec - [A new bug](#29272) has been discovered thanks to this migration, and a new TODO has been added, to add a new spec to cover that flow, once the bug is fixed [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29273?quickstart=1) ## **Related issues** Fixes: #29276 ## **Manual testing steps** 1. Check ci 2. Run test ` yarn test:e2e:single test/e2e/tests/request-queuing/sendTx-revokePermissions.spec.ts --browser=chrome --leave-running=true` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 0ef0d54 commit a31d808

File tree

3 files changed

+98
-58
lines changed

3 files changed

+98
-58
lines changed

test/e2e/page-objects/pages/test-dapp.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,26 @@ class TestDapp {
321321
});
322322
}
323323

324+
/**
325+
* Verifies the accounts connected to the test dapp.
326+
*
327+
* @param connectedAccounts - The expected connected accounts separated by a comma. If no accounts are connected we can omit the param.
328+
*/
329+
async check_connectedAccounts(connectedAccounts: string = '') {
330+
console.log('Verify connected accounts');
331+
if (connectedAccounts) {
332+
await this.driver.waitForSelector({
333+
css: this.connectedAccount,
334+
text: connectedAccounts,
335+
});
336+
} else {
337+
await this.driver.waitForSelector({
338+
css: this.connectedAccount,
339+
text: ' ',
340+
});
341+
}
342+
}
343+
324344
/**
325345
* Verify the failed personal sign signature.
326346
*

test/e2e/tests/request-queuing/sendTx-revokePermissions.spec.js

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
2+
import TestDapp from '../../page-objects/pages/test-dapp';
3+
import TransactionConfirmation from '../../page-objects/pages/confirmations/redesign/transaction-confirmation';
4+
import { Ganache } from '../../seeder/ganache';
5+
import { Driver } from '../../webdriver/driver';
6+
import { DEFAULT_FIXTURE_ACCOUNT } from '../../constants';
7+
import FixtureBuilder from '../../fixture-builder';
8+
import {
9+
withFixtures,
10+
defaultGanacheOptions,
11+
WINDOW_TITLES,
12+
} from '../../helpers';
13+
14+
describe('Request Queuing', function () {
15+
// TODO: add a new spec which checks that after revoking and connecting again
16+
// a pending tx is still closed when using revokePermissions.
17+
// To be done once this bug is fixed: #29272
18+
it('should clear tx confirmation when revokePermission is called from origin dapp', async function () {
19+
await withFixtures(
20+
{
21+
dapp: true,
22+
fixtures: new FixtureBuilder()
23+
.withPermissionControllerConnectedToTestDapp()
24+
.withPreferencesControllerUseRequestQueueEnabled()
25+
.withSelectedNetworkControllerPerDomain()
26+
.build(),
27+
ganacheOptions: {
28+
...defaultGanacheOptions,
29+
},
30+
title: this.test?.fullTitle(),
31+
},
32+
async ({
33+
driver,
34+
ganacheServer,
35+
}: {
36+
driver: Driver;
37+
ganacheServer?: Ganache;
38+
}) => {
39+
await loginWithBalanceValidation(driver, ganacheServer);
40+
41+
// Open test dapp
42+
const testDapp = new TestDapp(driver);
43+
await testDapp.openTestDappPage();
44+
await testDapp.check_connectedAccounts(
45+
DEFAULT_FIXTURE_ACCOUNT.toLowerCase(),
46+
);
47+
48+
// Trigger a tx
49+
await testDapp.clickSimpleSendButton();
50+
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
51+
52+
const transactionConfirmation = new TransactionConfirmation(driver);
53+
await transactionConfirmation.check_dappInitiatedHeadingTitle();
54+
55+
// wallet_revokePermissions request
56+
const revokePermissionsRequest = JSON.stringify({
57+
jsonrpc: '2.0',
58+
method: 'wallet_revokePermissions',
59+
params: [
60+
{
61+
eth_accounts: {},
62+
},
63+
],
64+
});
65+
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
66+
await driver.executeScript(
67+
`return window.ethereum.request(${revokePermissionsRequest})`,
68+
);
69+
70+
// Should have cleared the tx confirmation
71+
await driver.waitUntilXWindowHandles(2);
72+
73+
// Cleared eth_accounts account label
74+
await testDapp.check_connectedAccounts();
75+
},
76+
);
77+
});
78+
});

0 commit comments

Comments
 (0)