|
| 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