Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLASK] Update e2e tests for new react test-snaps page #16324

Merged
merged 32 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
65b43c3
initial commit
bowensanders Oct 27, 2022
87e51dc
switched enums.js to point to local
bowensanders Oct 31, 2022
1fa361a
error snap test completed
bowensanders Nov 1, 2022
a816df5
confirm snap test completed
bowensanders Nov 1, 2022
69ee6ac
bip-44 snap test completed
bowensanders Nov 1, 2022
fb906f4
manageState test complete
bowensanders Nov 2, 2022
afa1368
notification test complete
bowensanders Nov 2, 2022
0b1294f
bip32 test completed
bowensanders Nov 2, 2022
cb03a0a
update test completed
bowensanders Nov 2, 2022
301ea42
small fixes
bowensanders Nov 4, 2022
d1855f3
delay adjustments
bowensanders Nov 11, 2022
1fe73b3
attempt to fix merge conflicts
bowensanders Nov 11, 2022
1d00bef
removed unnecessary comment
bowensanders Nov 11, 2022
d377ea2
fixed linting and fixtures errors
bowensanders Nov 11, 2022
6d8d25a
fixed bip-32 snap for new keytree
bowensanders Nov 12, 2022
2743041
Merge branch 'develop' into bowen/react-e2e-tests
bowensanders Nov 14, 2022
3378d26
Merge branch 'bowen/react-e2e-tests' of https://github.com/metamask/m…
bowensanders Nov 14, 2022
1eb255b
fix to update test to bip-32
bowensanders Nov 14, 2022
8f48dac
revert update to use confirm until next test-snaps update
bowensanders Nov 14, 2022
7b0bba7
re-introduced delays to combat CI flaky testing
bowensanders Nov 15, 2022
273745a
Merge branch 'develop' into bowen/react-e2e-tests
bowensanders Nov 15, 2022
1af772f
changes to bip32 and bip44 to try to pass CI
bowensanders Nov 15, 2022
062f39f
added more anti-flake
bowensanders Nov 15, 2022
3b2e3cb
even more delays and window changes
bowensanders Nov 15, 2022
2168f04
Merge branch 'develop' into bowen/react-e2e-tests
bowensanders Nov 15, 2022
d7b69c0
Merge branch 'develop' into bowen/react-e2e-tests
bowensanders Nov 16, 2022
81d179a
removed commented code
bowensanders Nov 16, 2022
f67dc1b
Merge branch 'bowen/react-e2e-tests' of https://github.com/metamask/m…
bowensanders Nov 16, 2022
e4f25c9
Merge branch 'develop' into bowen/react-e2e-tests
bowensanders Nov 16, 2022
a5c9f4c
reverted policy changes
bowensanders Nov 16, 2022
7d92d9d
Merge branch 'bowen/react-e2e-tests' of https://github.com/metamask/m…
bowensanders Nov 16, 2022
9bec385
added logic to test-snap-error
bowensanders Nov 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/e2e/snaps/enums.js
Original file line number Diff line number Diff line change
@@ -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/',
};
122 changes: 78 additions & 44 deletions test/e2e/snaps/test-snap-bip-32.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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',
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -118,38 +178,12 @@ describe('Test Snap bip-32', function () {

// check result
await driver.delay(1000);
const ed25519Result = await driver.findElement('#bip32Ed25519Result');
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',
const ed25519Result = await driver.findElement(
'#bip32MessageResult-ed25519',
);
assert.equal(
await compressedPublicKeyResult.getText(),
'Public key: "0x033e98d696ae15caef75fa8dd204a7c5c08d1272b2218ba3c20feeb4c691eec366"',
await ed25519Result.getText(),
'"0xf3215b4d6c59aac7e01b4ceef530d1e2abf4857926b85a81aaae3894505699243768a887b7da4a8c2e0f25196196ba290b6531050db8dc15c252bdd508532a0a"',
);
},
);
Expand Down
74 changes: 60 additions & 14 deletions test/e2e/snaps/test-snap-bip-44.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -31,19 +30,33 @@ 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);
// 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,
);

// connect the snap
await driver.clickElement('#connectBip44');
await driver.delay(2000);

// approve install of snap
// switch to metamask extension
await driver.waitUntilXWindowHandles(2, 5000, 10000);
let windowHandles = await driver.getAllWindowHandles();
windowHandles = await driver.getAllWindowHandles();

// approve install of snap
await driver.switchToWindowWithTitle(
'MetaMask Notification',
windowHandles,
Expand All @@ -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"',
);
},
);
Expand Down
38 changes: 28 additions & 10 deletions test/e2e/snaps/test-snap-confirm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -31,29 +30,48 @@ 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');

// 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);

// approve install of snap
await driver.waitUntilXWindowHandles(2, 5000, 10000);
windowHandles = await driver.getAllWindowHandles();
await driver.switchToWindowWithTitle(
'MetaMask Notification',
windowHandles,
);
await driver.clickElement({
text: 'Approve & install',
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');

Expand Down
Loading