1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/test/e2e/mv3/phishing-warning-sw-restart.spec.js
Danica Shen fd8b81def0
feature(16691): mv3 e2e test for phishing warning page when sw restarts (#19196)
* feature(16691): mv3 e2e test for phishing warning page when sw restarts

* feature(16691): code review feedback to remove console and extract helper
2023-05-19 11:17:53 +01:00

53 lines
1.5 KiB
JavaScript

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);
},
);
});
});