1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

chore: refactor connect to dapp action in e2e (#19015)

* chore: refactor connect to dapp action in e2e

* chore: refactor 2nd dapp connection

* chore: rename to openDapp
This commit is contained in:
Danica Shen 2023-05-05 14:56:08 +01:00 committed by GitHub
parent 69132e7785
commit 395ac34bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 137 additions and 114 deletions

View File

@ -8,6 +8,7 @@ const {
ACTION_QUEUE_METRICS_E2E_TEST,
} = require('../../shared/constants/test-flags');
const { SMART_CONTRACTS } = require('./seeder/smart-contracts');
const { DAPP_URL } = require('./helpers');
function defaultFixture() {
return {
@ -594,13 +595,13 @@ class FixtureBuilder {
withPermissionControllerConnectedToTestDapp() {
return this.withPermissionController({
subjects: {
'http://127.0.0.1:8080': {
origin: 'http://127.0.0.1:8080',
[DAPP_URL]: {
origin: DAPP_URL,
permissions: {
eth_accounts: {
id: 'ZaqPEWxyhNCJYACFw93jE',
parentCapability: 'eth_accounts',
invoker: 'http://127.0.0.1:8080',
invoker: DAPP_URL,
caveats: [
{
type: 'restrictReturnedAccounts',

View File

@ -383,7 +383,18 @@ const testSRPDropdownIterations = async (options, driver, iterations) => {
}
};
const DAPP_URL = 'http://127.0.0.1:8080';
const DAPP_ONE_URL = 'http://127.0.0.1:8081';
const openDapp = async (driver, contract = null, dappURL = DAPP_URL) => {
contract
? await driver.openNewPage(`${dappURL}/?contract=${contract}`)
: await driver.openNewPage(dappURL);
};
module.exports = {
DAPP_URL,
DAPP_ONE_URL,
getWindowHandles,
convertToHexValue,
tinyDelayMs,
@ -398,4 +409,5 @@ module.exports = {
createDownloadFolder,
importWrongSRPOnboardingFlow,
testSRPDropdownIterations,
openDapp,
};

View File

@ -8,6 +8,7 @@ const {
regularDelayMs,
largeDelayMs,
veryLargeDelayMs,
openDapp,
} = require('./helpers');
const { buildWebDriver } = require('./webdriver');
const Ganache = require('./ganache');
@ -177,7 +178,7 @@ describe('MetaMask', function () {
let popup;
let dapp;
it('connects the dapp', async function () {
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.delay(regularDelayMs);
await driver.clickElement({ text: 'Connect', tag: 'button' });

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('MV3 - Dapp interactions', function () {
@ -31,7 +31,7 @@ describe('MV3 - Dapp interactions', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
// Terminate Service Worker
await driver.openNewPage('chrome://inspect/#service-workers/');

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
const {
ACTION_QUEUE_METRICS_E2E_TEST,
@ -142,7 +142,7 @@ describe('MV3 - Service worker restart', function () {
await driver.press('#password', driver.Key.ENTER);
// initialize a transaction of send from dapp
await driver.openNewPage('http://127.0.0.1:8080');
await openDapp(driver);
await driver.clickElement('#sendButton');
// A popup window is initialized

View File

@ -1,5 +1,10 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const {
convertToHexValue,
withFixtures,
DAPP_URL,
openDapp,
} = require('../helpers');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
const FixtureBuilder = require('../fixture-builder');
@ -34,7 +39,7 @@ describe('ERC1155 NFTs testdapp interaction', function () {
await driver.press('#password', driver.Key.ENTER);
// Open Dapp and wait for deployed contract
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
await openDapp(driver, contract);
await driver.findClickableElement('#deployButton');
// Mint
@ -91,7 +96,7 @@ describe('ERC1155 NFTs testdapp interaction', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
await openDapp(driver, contract);
await driver.fill('#batchTransferTokenIds', '1, 2, 3');
await driver.fill('#batchTransferTokenAmounts', '1, 1, 1000000000000');
@ -150,7 +155,7 @@ describe('ERC1155 NFTs testdapp interaction', function () {
await driver.press('#password', driver.Key.ENTER);
// Create a set approval for all erc1155 token request in test dapp
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
await openDapp(driver, contract);
await driver.clickElement('#setApprovalForAllERC1155Button');
// Wait for notification popup and check the displayed message
@ -170,7 +175,7 @@ describe('ERC1155 NFTs testdapp interaction', function () {
const displayedUrl = await driver.findElement(
'.confirm-approve-content h6',
);
assert.equal(await displayedUrl.getText(), 'http://127.0.0.1:8080');
assert.equal(await displayedUrl.getText(), DAPP_URL);
const displayedDescription = await driver.findElement(
'.confirm-approve-content__description',
);
@ -239,7 +244,7 @@ describe('ERC1155 NFTs testdapp interaction', function () {
await driver.press('#password', driver.Key.ENTER);
// Create a revoke approval for all erc1155 token request in test dapp
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
await openDapp(driver, contract);
await driver.clickElement('#revokeERC1155Button');
// Wait for notification popup and check the displayed message
@ -260,7 +265,7 @@ describe('ERC1155 NFTs testdapp interaction', function () {
const displayedUrl = await driver.findElement(
'.confirm-approve-content h6',
);
assert.equal(await displayedUrl.getText(), 'http://127.0.0.1:8080');
assert.equal(await displayedUrl.getText(), DAPP_URL);
const displayedDescription = await driver.findElement(
'.confirm-approve-content__description',
);

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
const FixtureBuilder = require('../fixture-builder');
@ -34,7 +34,7 @@ describe('ERC721 NFTs testdapp interaction', function () {
await driver.press('#password', driver.Key.ENTER);
// Open Dapp and wait for deployed contract
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
await openDapp(driver, contract);
await driver.findClickableElement('#deployButton');
// Click Transer
@ -86,7 +86,7 @@ describe('ERC721 NFTs testdapp interaction', function () {
await driver.press('#password', driver.Key.ENTER);
// Open Dapp and wait for deployed contract
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
await openDapp(driver, contract);
await driver.findClickableElement('#deployButton');
// Click Approve
@ -158,7 +158,7 @@ describe('ERC721 NFTs testdapp interaction', function () {
await driver.press('#password', driver.Key.ENTER);
// Open Dapp and wait for deployed contract
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
await openDapp(driver, contract);
await driver.findClickableElement('#deployButton');
// Enable Set approval for all
@ -229,7 +229,7 @@ describe('ERC721 NFTs testdapp interaction', function () {
await driver.press('#password', driver.Key.ENTER);
// Open Dapp and wait for deployed contract
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
await openDapp(driver, contract);
await driver.findClickableElement('#deployButton');
// Disable Set approval for all

View File

@ -1,6 +1,6 @@
const { strict: assert } = require('assert');
const FixtureBuilder = require('../fixture-builder');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
describe('Custom network', function () {
const chainID = '42161';
@ -33,7 +33,7 @@ describe('Custom network', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.executeScript(`
var params = [{
chainId: "0x1",
@ -111,7 +111,7 @@ describe('Custom network', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.executeScript(`
var params = [{
chainId: "0x123",
@ -176,7 +176,7 @@ describe('Custom network', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.executeScript(`
var params = [{
chainId: "0x123",

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Chain Interactions', function () {
@ -29,7 +29,7 @@ describe('Chain Interactions', function () {
await driver.press('#password', driver.Key.ENTER);
// trigger add chain confirmation
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement('#addEthereumChain');
await driver.waitUntilXWindowHandles(3);
const windowHandles = await driver.getAllWindowHandles();
@ -81,7 +81,7 @@ describe('Chain Interactions', function () {
await driver.press('#password', driver.Key.ENTER);
// trigger add chain confirmation
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement('#addEthereumChain');
await driver.waitUntilXWindowHandles(3);
const windowHandles = await driver.getAllWindowHandles();

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
const FixtureBuilder = require('../fixture-builder');
@ -34,9 +34,7 @@ describe('Deploy contract and call contract methods', function () {
await driver.press('#password', driver.Key.ENTER);
// deploy contract
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
// wait for deployed contract, calls and confirms a contract method where ETH is sent
await driver.findClickableElement('#deployButton');

View File

@ -1,6 +1,6 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
@ -36,9 +36,7 @@ describe('Create token, approve token and approve token without gas', function (
await driver.press('#password', driver.Key.ENTER);
// create token
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
const windowHandles = await driver.getAllWindowHandles();
const extension = windowHandles[0];
@ -100,9 +98,7 @@ describe('Create token, approve token and approve token without gas', function (
await driver.press('#password', driver.Key.ENTER);
// create token
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
let windowHandles = await driver.getAllWindowHandles();
const extension = windowHandles[0];
@ -226,9 +222,7 @@ describe('Create token, approve token and approve token without gas', function (
await driver.press('#password', driver.Key.ENTER);
// create token
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
let windowHandles = await driver.getAllWindowHandles();
const extension = windowHandles[0];
@ -372,10 +366,7 @@ describe('Create token, approve token and approve token without gas', function (
await driver.press('#password', driver.Key.ENTER);
// create token
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
const windowHandles = await driver.getAllWindowHandles();
const extension = windowHandles[0];
@ -458,9 +449,7 @@ describe('Create token, approve token and approve token without gas', function (
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
const windowHandles = await driver.getAllWindowHandles();
const extension = windowHandles[0];

View File

@ -1,5 +1,11 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const {
convertToHexValue,
withFixtures,
openDapp,
DAPP_URL,
DAPP_ONE_URL,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Dapp interactions', function () {
@ -31,7 +37,7 @@ describe('Dapp interactions', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
windowHandles = await driver.getAllWindowHandles();
extension = windowHandles[0];
@ -76,7 +82,7 @@ describe('Dapp interactions', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
windowHandles = await driver.getAllWindowHandles();
extension = windowHandles[0];
@ -86,7 +92,7 @@ describe('Dapp interactions', function () {
await driver.clickElement({ text: 'Lock', tag: 'button' });
// Connect to Dapp1
await driver.openNewPage('http://127.0.0.1:8081/');
await openDapp(driver, null, DAPP_ONE_URL);
await driver.clickElement({ text: 'Connect', tag: 'button' });
await driver.waitUntilXWindowHandles(4);
windowHandles = await driver.getAllWindowHandles();
@ -111,11 +117,11 @@ describe('Dapp interactions', function () {
);
await driver.clickElement({ text: 'Connected sites', tag: 'div' });
const connectedDapp1 = await driver.isElementPresent({
text: 'http://127.0.0.1:8080',
text: DAPP_URL,
tag: 'bdi',
});
const connectedDapp2 = await driver.isElementPresent({
text: 'http://127.0.0.1:8081',
text: DAPP_ONE_URL,
tag: 'bdi',
});

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
const FixtureBuilder = require('../fixture-builder');
@ -34,10 +34,7 @@ describe('Editing confirmations of dapp initiated contract interactions', functi
await driver.press('#password', driver.Key.ENTER);
// deploy contract
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
// wait for deployed contract, calls and confirms a contract method where ETH is sent
await driver.findClickableElement('#deployButton');
await driver.clickElement('#depositButton');
@ -80,7 +77,7 @@ describe('Editing confirmations of dapp initiated contract interactions', functi
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage(`http://127.0.0.1:8080/`);
await openDapp(driver);
await driver.clickElement('#sendButton');
await driver.waitUntilXWindowHandles(3);
const windowHandles = await driver.getAllWindowHandles();

View File

@ -3,6 +3,7 @@ const {
convertToHexValue,
getWindowHandles,
withFixtures,
openDapp,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
@ -206,7 +207,7 @@ describe('Editing Confirm Transaction', function () {
await driver.press('#password', driver.Key.ENTER);
// open dapp and connect
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement({
text: 'Send EIP 1559 Transaction',
tag: 'button',

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Encrypt Decrypt', function () {
@ -28,7 +28,7 @@ describe('Encrypt Decrypt', function () {
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');
await openDapp(driver);
// ------ Get Encryption key ------
await driver.clickElement('#getEncryptionKeyButton');
@ -109,7 +109,7 @@ describe('Encrypt Decrypt', function () {
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');
await openDapp(driver);
// ------ Get Encryption key and display ETH ------
await driver.clickElement('#getEncryptionKeyButton');
@ -153,7 +153,7 @@ describe('Encrypt Decrypt', function () {
await driver.press('#password', driver.Key.ENTER);
await driver.clickElement('.account-menu__icon');
await driver.openNewPage('http://127.0.0.1:8080');
await openDapp(driver);
// ------ Get Encryption key and display ETH ------
await driver.clickElement('#getEncryptionKeyButton');

View File

@ -1,5 +1,10 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const {
convertToHexValue,
withFixtures,
openDapp,
DAPP_URL,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
const ganacheOptions = {
@ -28,7 +33,7 @@ describe('Eth sign', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement('#ethSign');
await driver.delay(1000);
@ -64,7 +69,7 @@ describe('Eth sign', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement('#ethSign');
// Wait for Signature request popup
@ -80,7 +85,7 @@ describe('Eth sign', function () {
);
const origin = await driver.findElement('.request-signature__origin');
assert.equal(await title.getText(), 'Signature request');
assert.equal(await origin.getText(), 'http://127.0.0.1:8080');
assert.equal(await origin.getText(), DAPP_URL);
const personalMessageRow = await driver.findElement(
'.request-signature__row-value',

View File

@ -1,4 +1,9 @@
const { convertToHexValue, withFixtures } = require('../helpers');
const {
convertToHexValue,
withFixtures,
openDapp,
DAPP_ONE_URL,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('eth_subscribe', function () {
@ -28,7 +33,7 @@ describe('eth_subscribe', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
const setupSubscriptionListener = `
const responseContainer = document.createElement('div');
@ -63,7 +68,7 @@ describe('eth_subscribe', function () {
await driver.findElement('[data-testid="eth-subscribe-response"]');
// Switch to the second dapp
await driver.openNewPage('http://127.0.0.1:8081/');
await openDapp(driver, null, DAPP_ONE_URL);
// Setup the same subscription listener as on the first dapp, but without registering a new subscription
await driver.executeScript(setupSubscriptionListener);

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
const FixtureBuilder = require('../fixture-builder');
@ -34,9 +34,7 @@ describe('Failing contract interaction ', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
let windowHandles = await driver.getAllWindowHandles();
const extension = windowHandles[0];
@ -114,9 +112,7 @@ describe('Failing contract interaction on non-EIP1559 network', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
await openDapp(driver, contractAddress);
let windowHandles = await driver.getAllWindowHandles();
const extension = windowHandles[0];
// waits for deployed contract and calls failing contract method

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Incremental Security', function () {
@ -89,7 +89,7 @@ describe('Incremental Security', function () {
const extension = windowHandles[0];
// switched to Dapp
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
// sends eth to the current account
await driver.fill('#address', publicAddress);

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Navigate transactions', function () {
@ -130,7 +130,7 @@ describe('Navigate transactions', function () {
);
// add transaction
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement({ text: 'Send', tag: 'button' });
await driver.waitUntilXWindowHandles(3);
const windowHandles = await driver.getAllWindowHandles();

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Permissions', function () {
@ -27,7 +27,7 @@ describe('Permissions', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement({
text: 'Connect',
tag: 'button',

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Personal sign', function () {
@ -29,7 +29,7 @@ describe('Personal sign', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement('#personalSign');
await driver.waitUntilXWindowHandles(3);

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
const STALELIST_URL =
@ -107,7 +107,7 @@ describe('Phishing Detection', function () {
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');
await openDapp(driver);
await driver.clickElement({
text: 'continue to the site.',
});
@ -208,7 +208,7 @@ describe('Phishing Detection', function () {
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');
await openDapp(driver);
await driver.clickElement({ text: 'report a detection problem.' });
@ -236,7 +236,7 @@ describe('Phishing Detection', function () {
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');
await openDapp(driver);
await driver.clickElement({ text: 'report a detection problem.' });
@ -276,7 +276,7 @@ describe('Phishing Detection', function () {
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');
await openDapp(driver);
await driver.clickElement({ text: 'report a detection problem.' });

View File

@ -1,6 +1,6 @@
const { strict: assert } = require('assert');
const { errorCodes } = require('eth-rpc-errors');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('MetaMask', function () {
@ -31,7 +31,7 @@ describe('MetaMask', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
const networkDiv = await driver.waitForSelector({
css: '#network',
text: '1337',
@ -83,7 +83,7 @@ describe('MetaMask', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
for (const unsupportedMethod of ['eth_signTransaction']) {
assert.equal(
await driver.executeAsyncScript(`

View File

@ -1,5 +1,5 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
const OPENSEA_URL =
@ -94,7 +94,7 @@ describe('Transaction security provider', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
windowHandles = await driver.getAllWindowHandles();
await driver.clickElement('#personalSign');
@ -134,7 +134,7 @@ describe('Transaction security provider', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
windowHandles = await driver.getAllWindowHandles();
await driver.clickElement('#signTypedData');
@ -174,7 +174,7 @@ describe('Transaction security provider', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
windowHandles = await driver.getAllWindowHandles();
await driver.clickElement('#siwe');
@ -214,7 +214,7 @@ describe('Transaction security provider', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
windowHandles = await driver.getAllWindowHandles();
await driver.clickElement('#signTypedDataV4');

View File

@ -1,6 +1,6 @@
const { strict: assert } = require('assert');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Send ETH from inside MetaMask using default gas', function () {
@ -232,7 +232,7 @@ describe('Send ETH from dapp using advanced gas controls', function () {
await driver.press('#password', driver.Key.ENTER);
// initiates a send from the dapp
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement({ text: 'Send', tag: 'button' });
await driver.waitUntilXWindowHandles(3);
const windowHandles = await driver.getAllWindowHandles();
@ -311,7 +311,7 @@ describe('Send ETH from dapp using advanced gas controls', function () {
await driver.press('#password', driver.Key.ENTER);
// initiates a transaction from the dapp
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement({ text: 'Create Token', tag: 'button' });
await driver.waitUntilXWindowHandles(3);
const windowHandles = await driver.getAllWindowHandles();

View File

@ -3,6 +3,8 @@ const {
convertToHexValue,
withFixtures,
regularDelayMs,
openDapp,
DAPP_URL,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
@ -33,7 +35,7 @@ describe('Sign Typed Data V4 Signature Request', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
// creates a sign typed data signature request
await driver.clickElement('#signTypedDataV4');
@ -57,7 +59,7 @@ describe('Sign Typed Data V4 Signature Request', function () {
);
assert.equal(await title.getText(), 'Signature request');
assert.equal(await origin.getText(), 'http://127.0.0.1:8080');
assert.equal(await origin.getText(), DAPP_URL);
verifyContractDetailsButton.click();
await driver.findElement({ text: 'Third-party details', tag: 'h5' });
@ -114,7 +116,7 @@ describe('Sign Typed Data V3 Signature Request', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
// creates a sign typed data signature request
await driver.clickElement('#signTypedDataV3');
@ -139,7 +141,7 @@ describe('Sign Typed Data V3 Signature Request', function () {
);
assert.equal(await title.getText(), 'Signature request');
assert.equal(await origin.getText(), 'http://127.0.0.1:8080');
assert.equal(await origin.getText(), DAPP_URL);
verifyContractDetailsButton.click();
await driver.findElement({ text: 'Third-party details', tag: 'h5' });
@ -196,7 +198,7 @@ describe('Sign Typed Data Signature Request', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
// creates a sign typed data signature request
await driver.clickElement('#signTypedData');
@ -216,7 +218,7 @@ describe('Sign Typed Data Signature Request', function () {
'.request-signature__row-value',
);
assert.equal(await title.getText(), 'Signature request');
assert.equal(await origin.getText(), 'http://127.0.0.1:8080');
assert.equal(await origin.getText(), DAPP_URL);
assert.equal(await message[0].getText(), 'Hi, Alice!');
assert.equal(await message[1].getText(), '1337');

View File

@ -1,5 +1,10 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const {
convertToHexValue,
withFixtures,
openDapp,
DAPP_URL,
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('Sign in with ethereum', function () {
@ -36,7 +41,7 @@ describe('Sign in with ethereum', function () {
await driver.press('#password', driver.Key.ENTER);
// Create a signin with ethereum request in test dapp
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement('#siwe');
// Wait for signature request popup and check the message title
@ -51,7 +56,7 @@ describe('Sign in with ethereum', function () {
);
const origin = await driver.findElement('.site-origin');
assert.equal(await title.getText(), 'Sign-in request');
assert.equal(await origin.getText(), 'http://127.0.0.1:8080');
assert.equal(await origin.getText(), DAPP_URL);
const displayedMessageTitle = await driver.findElement(
'.permissions-connect-header__subtitle',

View File

@ -1,6 +1,6 @@
const { strict: assert } = require('assert');
const FixtureBuilder = require('../fixture-builder');
const { convertToHexValue, withFixtures } = require('../helpers');
const { convertToHexValue, withFixtures, openDapp } = require('../helpers');
describe('Swtich ethereum chain', function () {
const ganacheOptions = {
@ -33,7 +33,7 @@ describe('Swtich ethereum chain', function () {
const windowHandles = await driver.getAllWindowHandles();
const extension = windowHandles[0];
await driver.openNewPage('http://127.0.0.1:8080/');
await openDapp(driver);
await driver.clickElement({
tag: 'button',