mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
[FLASK] Update e2e tests for new react test-snaps page (#16324)
* Creates updated e2e tests compatible with the new react based test-snaps page.
This commit is contained in:
parent
7caeee9ea3
commit
327272f71e
@ -1,3 +1,3 @@
|
||||
module.exports = {
|
||||
TEST_SNAPS_WEBSITE_URL: 'https://metamask.github.io/test-snaps/3.2.0',
|
||||
TEST_SNAPS_WEBSITE_URL: 'https://metamask.github.io/test-snaps/4.0.2/',
|
||||
};
|
||||
|
@ -15,10 +15,9 @@ describe('Test Snap bip-32', function () {
|
||||
};
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withPermissionControllerConnectedToSnapDapp()
|
||||
.build(),
|
||||
fixtures: new FixtureBuilder().build(),
|
||||
ganacheOptions,
|
||||
failOnConsoleError: false,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
@ -32,20 +31,38 @@ describe('Test Snap bip-32', function () {
|
||||
await driver.driver.get(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.delay(1000);
|
||||
|
||||
// find and scroll to the correct card and click first
|
||||
const snapButton = await driver.findElement('#sendUpdateHello');
|
||||
await driver.scrollToElement(snapButton);
|
||||
await driver.delay(500);
|
||||
await driver.fill('#snapId6', 'npm:@metamask/test-snap-bip32');
|
||||
// find and scroll to the bip32 test and connect
|
||||
const snapButton1 = await driver.findElement('#connectBip32');
|
||||
await driver.scrollToElement(snapButton1);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#connectBip32');
|
||||
|
||||
// approve install of snap
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
|
||||
await driver.delay(2000);
|
||||
|
||||
// switch to metamask extension
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
|
||||
// approve install of snap
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement({
|
||||
text: 'Approve & install',
|
||||
tag: 'button',
|
||||
@ -65,10 +82,46 @@ describe('Test Snap bip-32', function () {
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
|
||||
// scroll to and click get public key
|
||||
await driver.delay(1000);
|
||||
const snapButton2 = await driver.findElement('#bip32GetPublic');
|
||||
await driver.scrollToElement(snapButton2);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#bip32GetPublic');
|
||||
|
||||
// check for proper public key response
|
||||
await driver.delay(1000);
|
||||
const retrievePublicKeyResult1 = await driver.findElement(
|
||||
'#bip32PublicKeyResult',
|
||||
);
|
||||
assert.equal(
|
||||
await retrievePublicKeyResult1.getText(),
|
||||
'"0x043e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366606ece56791c361a2320e7fad8bcbb130f66d51c591fc39767ab2856e93f8dfb"',
|
||||
);
|
||||
|
||||
// scroll to and click get compressed public key
|
||||
await driver.delay(1000);
|
||||
const snapButton3 = await driver.findElement(
|
||||
'#bip32GetCompressedPublic',
|
||||
);
|
||||
await driver.scrollToElement(snapButton3);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#bip32GetCompressedPublic');
|
||||
|
||||
// check for proper public key response
|
||||
await driver.delay(1000);
|
||||
const retrievePublicKeyResult2 = await driver.findElement(
|
||||
'#bip32PublicKeyResult',
|
||||
);
|
||||
assert.equal(
|
||||
await retrievePublicKeyResult2.getText(),
|
||||
'"0x033e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366"',
|
||||
);
|
||||
|
||||
// wait then run SECP256K1 test
|
||||
await driver.delay(1000);
|
||||
await driver.fill('#bip32SignMessage', 'foo bar');
|
||||
await driver.clickElement('#sendBip32Secp256k1');
|
||||
await driver.fill('#bip32Message-secp256k1', 'foo bar');
|
||||
await driver.clickElement('#sendBip32-secp256k1');
|
||||
|
||||
// hit 'approve' on the custom confirm
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
@ -89,16 +142,23 @@ describe('Test Snap bip-32', function () {
|
||||
// check result
|
||||
await driver.delay(1000);
|
||||
const secp256k1Result = await driver.findElement(
|
||||
'#bip32Secp256k1Result',
|
||||
'#bip32MessageResult-secp256k1',
|
||||
);
|
||||
assert.equal(
|
||||
await secp256k1Result.getText(),
|
||||
'Signature: "0xd30561eb9e3195e47d49198fb0bc66eda867a7dff4c5e8b60c2ec13851aa7d8cc3d485da177de63dad331f315d440cbb693a629efe228389c4693ea90465b101"',
|
||||
'"0x3045022100b3ade2992ea3e5eb58c7550e9bddad356e9554233c8b099ebc3cb418e9301ae2022064746e15ae024808f0ba5d860e44dc4c97e65c8cba6f5ef9ea2e8c819930d2dc"',
|
||||
);
|
||||
|
||||
// scroll further into messages section
|
||||
await driver.delay(1000);
|
||||
const snapButton4 = await driver.findElement('#bip32Message-ed25519');
|
||||
await driver.scrollToElement(snapButton4);
|
||||
await driver.delay(1000);
|
||||
|
||||
// wait then run ed25519 test
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#sendBip32Ed25519');
|
||||
await driver.fill('#bip32Message-ed25519', 'foo bar');
|
||||
await driver.clickElement('#sendBip32-ed25519');
|
||||
|
||||
// hit 'approve' on the custom confirm
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
@ -118,38 +178,12 @@ describe('Test Snap bip-32', function () {
|
||||
|
||||
// check result
|
||||
await driver.delay(1000);
|
||||
const ed25519Result = await driver.findElement('#bip32Ed25519Result');
|
||||
const ed25519Result = await driver.findElement(
|
||||
'#bip32MessageResult-ed25519',
|
||||
);
|
||||
assert.equal(
|
||||
await ed25519Result.getText(),
|
||||
'Signature: "0xf3215b4d6c59aac7e01b4ceef530d1e2abf4857926b85a81aaae3894505699243768a887b7da4a8c2e0f25196196ba290b6531050db8dc15c252bdd508532a0a"',
|
||||
);
|
||||
|
||||
const publicKeyButton = await driver.findElement('#sendBip32PublicKey');
|
||||
await driver.scrollToElement(publicKeyButton);
|
||||
// wait then run public key test
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#sendBip32PublicKey');
|
||||
// check result
|
||||
await driver.delay(1000);
|
||||
const publicKeyResult = await driver.findElement(
|
||||
'#bip32PublicKeyResult',
|
||||
);
|
||||
assert.equal(
|
||||
await publicKeyResult.getText(),
|
||||
'Public key: "0x043e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366606ece56791c361a2320e7fad8bcbb130f66d51c591fc39767ab2856e93f8dfb"',
|
||||
);
|
||||
|
||||
// wait then run compressed public key test
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#sendBip32CompressedPublicKey');
|
||||
// check result
|
||||
await driver.delay(1000);
|
||||
const compressedPublicKeyResult = await driver.findElement(
|
||||
'#bip32CompressedPublicKeyResult',
|
||||
);
|
||||
assert.equal(
|
||||
await compressedPublicKeyResult.getText(),
|
||||
'Public key: "0x033e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366"',
|
||||
'"0xf3215b4d6c59aac7e01b4ceef530d1e2abf4857926b85a81aaae3894505699243768a887b7da4a8c2e0f25196196ba290b6531050db8dc15c252bdd508532a0a"',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -16,10 +16,9 @@ describe('Test Snap bip-44', function () {
|
||||
};
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withPermissionControllerConnectedToSnapDapp()
|
||||
.build(),
|
||||
fixtures: new FixtureBuilder().build(),
|
||||
ganacheOptions,
|
||||
failOnConsoleError: false,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
@ -31,23 +30,37 @@ describe('Test Snap bip-44', function () {
|
||||
|
||||
// navigate to test snaps page and connect
|
||||
await driver.driver.get(TEST_SNAPS_WEBSITE_URL);
|
||||
const snapButton1 = await driver.findElement('#connectBip44Snap');
|
||||
await driver.scrollToElement(snapButton1);
|
||||
await driver.delay(1000);
|
||||
await driver.fill('#snapId3', 'npm:@metamask/test-snap-bip44');
|
||||
await driver.clickElement('#connectBip44Snap');
|
||||
|
||||
const snapButton = await driver.findElement('#snapId3');
|
||||
await driver.scrollToElement(snapButton);
|
||||
await driver.delay(500);
|
||||
|
||||
// connect the snap
|
||||
await driver.clickElement('#connectBip44');
|
||||
|
||||
// approve install of snap
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
|
||||
await driver.delay(2000);
|
||||
|
||||
// switch to metamask extension
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
|
||||
// approve install of snap
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement({
|
||||
text: 'Approve & install',
|
||||
tag: 'button',
|
||||
@ -66,14 +79,47 @@ describe('Test Snap bip-44', function () {
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#sendBip44');
|
||||
await driver.clickElement('#sendBip44Test');
|
||||
|
||||
// check the results of the public key test
|
||||
await driver.delay(2000);
|
||||
await driver.delay(1000);
|
||||
const bip44Result = await driver.findElement('#bip44Result');
|
||||
assert.equal(
|
||||
await bip44Result.getText(),
|
||||
'Public key: "0x86debb44fb3a984d93f326131d4c1db0bc39644f1a67b673b3ab45941a1cea6a385981755185ac4594b6521e4d1e08d1"',
|
||||
'"0x86debb44fb3a984d93f326131d4c1db0bc39644f1a67b673b3ab45941a1cea6a385981755185ac4594b6521e4d1e08d1"',
|
||||
);
|
||||
|
||||
// enter a message to sign
|
||||
await driver.fill('#bip44Message', '1234');
|
||||
await driver.delay(1000);
|
||||
const snapButton3 = await driver.findElement('#signBip44Message');
|
||||
await driver.scrollToElement(snapButton3);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#signBip44Message');
|
||||
|
||||
// Switch to approve signature message window and approve
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement({
|
||||
text: 'Approve',
|
||||
tag: 'button',
|
||||
});
|
||||
|
||||
// switch back to test-snaps page
|
||||
await driver.waitUntilXWindowHandles(1, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
await driver.delay(1000);
|
||||
|
||||
// check the results of the message signature
|
||||
const bip44SignResult = await driver.findElement('#bip44SignResult');
|
||||
assert.equal(
|
||||
await bip44SignResult.getText(),
|
||||
'"0xa41ab87ca50606eefd47525ad90294bbe44c883f6bc53655f1b8a55aa8e1e35df216f31be62e52c7a1faa519420e20810162e07dedb0fde2a4d997ff7180a78232ecd8ce2d6f4ba42ccacad33c5e9e54a8c4d41506bdffb2bb4c368581d8b086"',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -16,10 +16,9 @@ describe('Test Snap Confirm', function () {
|
||||
};
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withPermissionControllerConnectedToSnapDapp()
|
||||
.build(),
|
||||
fixtures: new FixtureBuilder().build(),
|
||||
ganacheOptions,
|
||||
failOnConsoleError: false,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
@ -31,12 +30,31 @@ describe('Test Snap Confirm', function () {
|
||||
|
||||
// navigate to test snaps page and connect
|
||||
await driver.driver.get(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.fill('#snapId1', 'npm:@metamask/test-snap-confirm');
|
||||
await driver.clickElement('#connectHello');
|
||||
const snapButton1 = await driver.findElement('#connectConfirmSnap');
|
||||
await driver.scrollToElement(snapButton1);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#connectConfirmSnap');
|
||||
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
|
||||
await driver.delay(2000);
|
||||
|
||||
// approve install of snap
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
@ -46,14 +64,14 @@ describe('Test Snap Confirm', function () {
|
||||
tag: 'button',
|
||||
});
|
||||
|
||||
// click send inputs on test snap page
|
||||
// switch back to test snaps page
|
||||
await driver.waitUntilXWindowHandles(1, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
|
||||
const snapButton = await driver.findElement('#sendConfirmButton');
|
||||
await driver.scrollToElement(snapButton);
|
||||
|
||||
// click send inputs on test snap page
|
||||
const snapButton2 = await driver.findElement('#sendConfirmButton');
|
||||
await driver.scrollToElement(snapButton2);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#sendConfirmButton');
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
const { strict: assert } = require('assert');
|
||||
const { withFixtures } = require('../helpers');
|
||||
const { PAGES } = require('../webdriver/driver');
|
||||
const FixtureBuilder = require('../fixture-builder');
|
||||
const { TEST_SNAPS_WEBSITE_URL } = require('./enums');
|
||||
|
||||
@ -17,10 +16,9 @@ describe('Test Snap Error', function () {
|
||||
};
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withPermissionControllerConnectedToSnapDapp()
|
||||
.build(),
|
||||
fixtures: new FixtureBuilder().build(),
|
||||
ganacheOptions,
|
||||
failOnConsoleError: false,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
@ -31,17 +29,31 @@ describe('Test Snap Error', function () {
|
||||
await driver.press('#password', driver.Key.ENTER);
|
||||
|
||||
// navigate to test snaps page and connect
|
||||
await driver.driver.get(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.fill('#snapId2', 'npm:@metamask/test-snap-error');
|
||||
|
||||
const snapButton = await driver.findElement('#connectError');
|
||||
await driver.openNewPage(TEST_SNAPS_WEBSITE_URL);
|
||||
const snapButton = await driver.findElement('#connectErrorSnap');
|
||||
await driver.scrollToElement(snapButton);
|
||||
await driver.delay(500);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#connectErrorSnap');
|
||||
|
||||
await driver.clickElement('#connectError');
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
const extensionPage = windowHandles[0];
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
|
||||
await driver.delay(2000);
|
||||
|
||||
// approve install of snap
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
@ -52,14 +64,19 @@ describe('Test Snap Error', function () {
|
||||
});
|
||||
|
||||
// click send inputs on test snap page
|
||||
await driver.waitUntilXWindowHandles(1, 5000, 10000);
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
await driver.delay(1000);
|
||||
|
||||
// find and click on send error
|
||||
await driver.clickElement('#sendError');
|
||||
|
||||
await driver.navigate(PAGES.HOME);
|
||||
// switch back to the extension page
|
||||
await driver.switchToWindow(extensionPage);
|
||||
await driver.delay(1000);
|
||||
|
||||
// look for the actual error and check if it is correct
|
||||
const error = await driver.findElement(
|
||||
'.home-notification__content-container',
|
||||
);
|
||||
@ -70,6 +87,12 @@ describe('Test Snap Error', function () {
|
||||
),
|
||||
true,
|
||||
);
|
||||
|
||||
// try to click on the dismiss button and pass test if it works
|
||||
await driver.clickElement({
|
||||
text: 'Dismiss',
|
||||
tag: 'button',
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@ -3,8 +3,8 @@ const { withFixtures } = require('../helpers');
|
||||
const FixtureBuilder = require('../fixture-builder');
|
||||
const { TEST_SNAPS_WEBSITE_URL } = require('./enums');
|
||||
|
||||
describe('Test Snap Confirm', function () {
|
||||
it('can pop up a snap confirm and get its result', async function () {
|
||||
describe('Test Snap Installed', function () {
|
||||
it('can tell if a snap is installed', async function () {
|
||||
const ganacheOptions = {
|
||||
accounts: [
|
||||
{
|
||||
@ -16,10 +16,9 @@ describe('Test Snap Confirm', function () {
|
||||
};
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withPermissionControllerConnectedToSnapDapp()
|
||||
.build(),
|
||||
fixtures: new FixtureBuilder().build(),
|
||||
ganacheOptions,
|
||||
failOnConsoleError: false,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
@ -30,13 +29,32 @@ describe('Test Snap Confirm', function () {
|
||||
await driver.press('#password', driver.Key.ENTER);
|
||||
|
||||
// navigate to test snaps page and connect
|
||||
await driver.driver.get(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.fill('#snapId1', 'npm:@metamask/test-snap-confirm');
|
||||
await driver.clickElement('#connectHello');
|
||||
await driver.openNewPage(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.delay(1000);
|
||||
const confirmButton = await driver.findElement('#connectConfirmSnap');
|
||||
await driver.scrollToElement(confirmButton);
|
||||
await driver.clickElement('#connectConfirmSnap');
|
||||
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
|
||||
await driver.delay(2000);
|
||||
|
||||
// approve install of snap
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
@ -47,18 +65,33 @@ describe('Test Snap Confirm', function () {
|
||||
});
|
||||
|
||||
// click send inputs on test snap page
|
||||
await driver.waitUntilXWindowHandles(1, 5000, 10000);
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
|
||||
const errorButton = await driver.findElement('#connectError');
|
||||
const errorButton = await driver.findElement('#connectErrorSnap');
|
||||
await driver.scrollToElement(errorButton);
|
||||
await driver.delay(1000);
|
||||
await driver.fill('#snapId2', 'npm:@metamask/test-snap-error');
|
||||
await driver.clickElement('#connectError');
|
||||
await driver.clickElement('#connectErrorSnap');
|
||||
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
|
||||
await driver.delay(2000);
|
||||
|
||||
// approve install of snap
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
@ -69,19 +102,13 @@ describe('Test Snap Confirm', function () {
|
||||
tag: 'button',
|
||||
});
|
||||
|
||||
await driver.waitUntilXWindowHandles(1, 5000, 10000);
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
|
||||
const getInstalledSnapsButton = await driver.findElement(
|
||||
'#getInstalledSnapsButton',
|
||||
);
|
||||
await driver.scrollToElement(getInstalledSnapsButton);
|
||||
const result = await driver.findElement('#installedSnapsResult');
|
||||
await driver.scrollToElement(result);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#getInstalledSnapsButton');
|
||||
await driver.delay(1000);
|
||||
|
||||
const result = await driver.findElement('#getInstalledSnapsResult');
|
||||
assert.equal(
|
||||
await result.getText(),
|
||||
'npm:@metamask/test-snap-confirm, npm:@metamask/test-snap-error',
|
@ -17,10 +17,9 @@ describe('Test Snap manageState', function () {
|
||||
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withPermissionControllerConnectedToSnapDapp()
|
||||
.build(),
|
||||
fixtures: new FixtureBuilder().build(),
|
||||
ganacheOptions,
|
||||
failOnConsoleError: false,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
@ -31,32 +30,45 @@ describe('Test Snap manageState', function () {
|
||||
await driver.press('#password', driver.Key.ENTER);
|
||||
|
||||
// navigate to test snaps page, then fill in the snapId
|
||||
await driver.driver.get(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.openNewPage(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.delay(1000);
|
||||
await driver.fill('#snapId4', 'npm:@metamask/test-snap-managestate');
|
||||
|
||||
// find and scroll to the rest of the card
|
||||
const snapButton = await driver.findElement('#snapId4');
|
||||
await driver.scrollToElement(snapButton);
|
||||
await driver.delay(500);
|
||||
|
||||
// connect the snap
|
||||
// find and scroll to the connect button and click it
|
||||
const snapButton1 = await driver.findElement('#connectManageState');
|
||||
await driver.scrollToElement(snapButton1);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#connectManageState');
|
||||
|
||||
// approve install of snap
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
await driver.delay(2000);
|
||||
|
||||
// approve install of snap
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement({
|
||||
text: 'Approve & install',
|
||||
tag: 'button',
|
||||
});
|
||||
|
||||
// fill and click send inputs on test snap page
|
||||
await driver.waitUntilXWindowHandles(1, 5000, 10000);
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
await driver.fill('#dataManageState', '23');
|
||||
@ -64,46 +76,40 @@ describe('Test Snap manageState', function () {
|
||||
await driver.clickElement('#sendManageState');
|
||||
|
||||
// check the results of the public key test
|
||||
await driver.delay(500);
|
||||
await driver.delay(1000);
|
||||
const manageStateResult = await driver.findElement(
|
||||
'#sendManageStateResult',
|
||||
);
|
||||
assert.equal(await manageStateResult.getText(), 'true');
|
||||
|
||||
// click get results
|
||||
await driver.clickElement('#retrieveManageState');
|
||||
|
||||
// check the results
|
||||
await driver.delay(500);
|
||||
await driver.delay(1000);
|
||||
const retrieveManageStateResult = await driver.findElement(
|
||||
'#retrieveManageStateResult',
|
||||
);
|
||||
assert.equal(
|
||||
await retrieveManageStateResult.getText(),
|
||||
'{"testState":["23"]}',
|
||||
'{ "testState": [ "23" ] }',
|
||||
);
|
||||
|
||||
// click clear results
|
||||
await driver.clickElement('#clearManageState');
|
||||
|
||||
// check if true
|
||||
await driver.delay(500);
|
||||
await driver.delay(1000);
|
||||
const clearManageStateResult = await driver.findElement(
|
||||
'#clearManageStateResult',
|
||||
);
|
||||
assert.equal(await clearManageStateResult.getText(), 'true');
|
||||
|
||||
// click get results again
|
||||
await driver.clickElement('#retrieveManageState');
|
||||
|
||||
// check result array is empty
|
||||
await driver.delay(500);
|
||||
await driver.delay(1000);
|
||||
const retrieveManageStateResult2 = await driver.findElement(
|
||||
'#retrieveManageStateResult',
|
||||
);
|
||||
assert.equal(
|
||||
await retrieveManageStateResult2.getText(),
|
||||
'{"testState":[]}',
|
||||
'{ "testState": [] }',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -1,6 +1,5 @@
|
||||
const { strict: assert } = require('assert');
|
||||
const { withFixtures } = require('../helpers');
|
||||
const { PAGES } = require('../webdriver/driver');
|
||||
const FixtureBuilder = require('../fixture-builder');
|
||||
const { TEST_SNAPS_WEBSITE_URL } = require('./enums');
|
||||
|
||||
@ -17,10 +16,9 @@ describe('Test Snap Notification', function () {
|
||||
};
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withPermissionControllerConnectedToSnapDapp()
|
||||
.build(),
|
||||
fixtures: new FixtureBuilder().build(),
|
||||
ganacheOptions,
|
||||
failOnConsoleError: false,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
@ -31,21 +29,35 @@ describe('Test Snap Notification', function () {
|
||||
await driver.press('#password', driver.Key.ENTER);
|
||||
|
||||
// navigate to test snaps page
|
||||
await driver.driver.get(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.openNewPage(TEST_SNAPS_WEBSITE_URL);
|
||||
await driver.delay(1000);
|
||||
|
||||
// find and scroll down to snapId5
|
||||
const snapButton = await driver.findElement('#snapId5');
|
||||
// find and scroll down to snapId5 and connect
|
||||
const snapButton = await driver.findElement('#connectNotification');
|
||||
await driver.scrollToElement(snapButton);
|
||||
await driver.delay(500);
|
||||
await driver.fill('#snapId5', 'npm:@metamask/test-snap-notification');
|
||||
|
||||
// connect the snap
|
||||
await driver.clickElement('#connectNotification');
|
||||
|
||||
// approve install of snap
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
const extensionPage = windowHandles[0];
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
await driver.delay(2000);
|
||||
|
||||
// approve install of snap
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
@ -56,14 +68,14 @@ describe('Test Snap Notification', function () {
|
||||
});
|
||||
|
||||
// click send inputs on test snap page
|
||||
await driver.waitUntilXWindowHandles(1, 5000, 10000);
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#sendInAppNotification');
|
||||
|
||||
// try to go to the MM pages
|
||||
await driver.navigate(PAGES.HOME);
|
||||
// switch back to the extension page
|
||||
await driver.switchToWindow(extensionPage);
|
||||
await driver.delay(1500);
|
||||
|
||||
// check to see that there is one notification
|
||||
@ -74,14 +86,14 @@ describe('Test Snap Notification', function () {
|
||||
|
||||
// try to click on the account menu icon (via xpath)
|
||||
await driver.clickElement('.account-menu__icon');
|
||||
await driver.delay(500);
|
||||
await driver.delay(1000);
|
||||
|
||||
// try to click on the notification item (via xpath)
|
||||
await driver.clickElement({
|
||||
text: 'Notifications',
|
||||
tag: 'div',
|
||||
});
|
||||
await driver.delay(500);
|
||||
await driver.delay(1000);
|
||||
|
||||
// look for the correct text in notifications (via xpath)
|
||||
const notificationResultMessage = await driver.findElement(
|
||||
|
@ -16,10 +16,9 @@ describe('Test Snap update', function () {
|
||||
};
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withPermissionControllerConnectedToSnapDapp()
|
||||
.build(),
|
||||
fixtures: new FixtureBuilder().build(),
|
||||
ganacheOptions,
|
||||
failOnConsoleError: false,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
@ -33,15 +32,32 @@ describe('Test Snap update', function () {
|
||||
await driver.openNewPage(TEST_SNAPS_WEBSITE_URL);
|
||||
|
||||
// find and scroll to the correct card and click first
|
||||
const snapButton = await driver.findElement('#sendUpdateHello');
|
||||
const snapButton = await driver.findElement('#connectUpdateNew');
|
||||
await driver.scrollToElement(snapButton);
|
||||
await driver.delay(500);
|
||||
await driver.fill('#snapId7', 'npm:@metamask/test-snap-confirm');
|
||||
await driver.clickElement('#connectUpdateOld');
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#connectUpdate');
|
||||
|
||||
await driver.delay(2000);
|
||||
|
||||
// switch to metamask extension and click connect
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
);
|
||||
await driver.clickElement(
|
||||
{
|
||||
text: 'Connect',
|
||||
tag: 'button',
|
||||
},
|
||||
10000,
|
||||
);
|
||||
await driver.delay(2000);
|
||||
|
||||
// approve install of snap
|
||||
let windowHandles = await driver.getAllWindowHandles();
|
||||
const extensionPage = windowHandles[0];
|
||||
await driver.waitUntilXWindowHandles(3, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle(
|
||||
'MetaMask Notification',
|
||||
windowHandles,
|
||||
@ -58,9 +74,9 @@ describe('Test Snap update', function () {
|
||||
await driver.delay(1000);
|
||||
|
||||
// find and scroll to the correct card and click first
|
||||
const snapButton2 = await driver.findElement('#snapId7');
|
||||
const snapButton2 = await driver.findElement('#connectUpdateNew');
|
||||
await driver.scrollToElement(snapButton2);
|
||||
await driver.delay(500);
|
||||
await driver.delay(1000);
|
||||
await driver.clickElement('#connectUpdateNew');
|
||||
|
||||
// switch to metamask extension and click connect
|
||||
@ -78,33 +94,15 @@ describe('Test Snap update', function () {
|
||||
tag: 'button',
|
||||
});
|
||||
|
||||
// switch to the original MM tab
|
||||
await driver.switchToWindow(extensionPage);
|
||||
await driver.delay(500);
|
||||
|
||||
// click on the account menu icon
|
||||
await driver.clickElement('.account-menu__icon');
|
||||
await driver.delay(500);
|
||||
|
||||
// try to click on the notification item
|
||||
await driver.clickElement({
|
||||
text: 'Settings',
|
||||
tag: 'div',
|
||||
});
|
||||
await driver.delay(500);
|
||||
|
||||
// try to click on the snaps item
|
||||
await driver.clickElement({
|
||||
text: 'Snaps',
|
||||
tag: 'div',
|
||||
});
|
||||
await driver.delay(500);
|
||||
// navigate to test snap page
|
||||
await driver.waitUntilXWindowHandles(2, 5000, 10000);
|
||||
windowHandles = await driver.getAllWindowHandles();
|
||||
await driver.switchToWindowWithTitle('Test Snaps', windowHandles);
|
||||
|
||||
// look for the correct version text
|
||||
const versionResult = await driver.findElement(
|
||||
'.snap-settings-card__version',
|
||||
);
|
||||
assert.equal(await versionResult.getText(), 'v2.0.0');
|
||||
const versionResult = await driver.findElement('#updateSnapVersion');
|
||||
await driver.delay(1000);
|
||||
assert.equal(await versionResult.getText(), '"2.0.0"');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user