-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[e2e] Setup MV3 specific test folder and add 1 simple testcase introd…
…ucing Service Worker re-start (#16606) * First e2e mv3 specific dapp testcase * Fix testpath for snaps * Update `it` description Co-authored-by: Mark Stacey <[email protected]> * e2e test paths improvement Co-authored-by: Mark Stacey <[email protected]>
- Loading branch information
Showing
3 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const { strict: assert } = require('assert'); | ||
const { convertToHexValue, withFixtures } = require('../helpers'); | ||
const FixtureBuilder = require('../fixture-builder'); | ||
|
||
describe('MV3 - Dapp interactions', function () { | ||
let windowHandles; | ||
const ganacheOptions = { | ||
accounts: [ | ||
{ | ||
secretKey: | ||
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', | ||
balance: convertToHexValue(25000000000000000000), | ||
}, | ||
], | ||
}; | ||
it('should continue to support dapp interactions after service worker re-start', async function () { | ||
await withFixtures( | ||
{ | ||
dapp: true, | ||
fixtures: new FixtureBuilder() | ||
.withPermissionControllerConnectedToTestDapp() | ||
.build(), | ||
ganacheOptions: { | ||
...ganacheOptions, | ||
}, | ||
title: this.test.title, | ||
}, | ||
async ({ driver }) => { | ||
await driver.navigate(); | ||
await driver.fill('#password', 'correct horse battery staple'); | ||
await driver.press('#password', driver.Key.ENTER); | ||
|
||
await driver.openNewPage('http://127.0.0.1:8080/'); | ||
|
||
// Terminate Service Worker | ||
await driver.openNewPage('chrome://inspect/#service-workers/'); | ||
await driver.clickElement({ | ||
text: 'Service workers', | ||
tag: 'button', | ||
}); | ||
|
||
await driver.clickElement({ | ||
text: 'terminate', | ||
tag: 'span', | ||
}); | ||
|
||
// Trigger Notification | ||
windowHandles = await driver.getAllWindowHandles(); | ||
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles); | ||
await driver.clickElement('#addEthereumChain'); | ||
await driver.waitUntilXWindowHandles(4); | ||
await driver.switchToWindowWithTitle( | ||
'MetaMask Notification', | ||
windowHandles, | ||
); | ||
|
||
const notification = await driver.isElementPresent({ | ||
text: 'Allow this site to add a network?', | ||
tag: 'h3', | ||
}); | ||
|
||
assert.ok(notification, 'Dapp action does not appear in Metamask'); | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters