1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-28 23:06:37 +01:00
metamask-extension/test/e2e/mv3/phishing-warning-sw-restart.spec.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

const { strict: assert } = require('assert');
const {
withFixtures,
mockPhishingDetection,
SERVICE_WORKER_URL,
openDapp,
defaultGanacheOptions,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Phishing warning page', function () {
it('should restore the transaction when service worker restarts', async function () {
await withFixtures(
{
dapp: true,
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
title: this.test.title,
testSpecificMock: mockPhishingDetection,
},
async ({ driver }) => {
await driver.navigate();
// log in wallet
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
// Restart service worker
await driver.openNewPage(SERVICE_WORKER_URL);
await driver.clickElement({
text: 'Service workers',
tag: 'button',
});
await driver.clickElement({
text: 'terminate',
tag: 'span',
});
// Open the dapp site and extension detect it as phishing warning page
await openDapp(driver);
await driver.switchToWindowWithTitle('MetaMask Phishing Detection');
const phishingPageHeader = await driver.findElements({
text: 'Deceptive site ahead',
tag: 'h1',
});
assert.ok(phishingPageHeader.length, 1);
},
);
});
});