From 612c1520b66f69d85b6e70324b1bb20b7f0661b2 Mon Sep 17 00:00:00 2001 From: bowensanders Date: Wed, 13 Sep 2023 12:59:58 -0500 Subject: [PATCH 1/8] created new e2e --- test/e2e/snaps/enums.js | 2 +- test/e2e/snaps/test-snap-get-locale.spec.js | 117 ++++++++++++++++++++ 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 test/e2e/snaps/test-snap-get-locale.spec.js diff --git a/test/e2e/snaps/enums.js b/test/e2e/snaps/enums.js index 6ec77de3087e..4e5a781b516b 100644 --- a/test/e2e/snaps/enums.js +++ b/test/e2e/snaps/enums.js @@ -2,5 +2,5 @@ module.exports = { TEST_SNAPS_WEBSITE_URL: 'https://metamask.github.io/snaps/test-snaps/0.38.0-flask.1/', TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL: - 'https://metamask.github.io/snap-simple-keyring/0.1.4/', + 'https://metamask.github.io/snap-simple-keyring/latest/', }; diff --git a/test/e2e/snaps/test-snap-get-locale.spec.js b/test/e2e/snaps/test-snap-get-locale.spec.js new file mode 100644 index 000000000000..f72c5c742c4a --- /dev/null +++ b/test/e2e/snaps/test-snap-get-locale.spec.js @@ -0,0 +1,117 @@ +const { strict: assert } = require('assert'); +const { withFixtures } = require('../helpers'); +const FixtureBuilder = require('../fixture-builder'); +const { TEST_SNAPS_WEBSITE_URL } = require('./enums'); + +describe('Test Snap Get Locale', function () { + it('test snap_getLocale functionality', async function () { + const ganacheOptions = { + accounts: [ + { + secretKey: + '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', + balance: 25000000000000000000, + }, + ], + }; + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions, + failOnConsoleError: false, + title: this.test.title, + }, + async ({ driver }) => { + await driver.navigate(); + + // enter pw into extension + await driver.fill('#password', 'correct horse battery staple'); + await driver.press('#password', driver.Key.ENTER); + + // navigate to test snaps page and connect to dialog snap + await driver.openNewPage(TEST_SNAPS_WEBSITE_URL); + await driver.delay(1000); + const dialogButton = await driver.findElement('#connectgetlocale'); + await driver.scrollToElement(dialogButton); + await driver.delay(1000); + await driver.clickElement('#connectgetlocale'); + await driver.delay(1000); + + // switch to metamask extension and click connect + let windowHandles = await driver.waitUntilXWindowHandles( + 3, + 1000, + 10000, + ); + await driver.switchToWindowWithTitle( + 'MetaMask Notification', + windowHandles, + ); + await driver.clickElement({ + text: 'Connect', + tag: 'button', + }); + + await driver.waitForSelector({ text: 'Install' }); + + await driver.clickElement({ + text: 'Install', + tag: 'button', + }); + + await driver.waitForSelector({ text: 'OK' }); + + await driver.clickElement({ + text: 'OK', + tag: 'button', + }); + + // switch to test snaps tab + await driver.switchToWindowWithTitle('Test Snaps', windowHandles); + + // wait for npm installation success + await driver.waitForSelector({ + css: '#connectgetlocale', + text: 'Reconnect to Get Locale Snap', + }); + + // click on alert dialog + await driver.clickElement('#sendGetLocaleHelloButton'); + await driver.delay(500); + + // switch to dialog popup + windowHandles = await driver.waitUntilXWindowHandles(3, 1000, 10000); + await driver.switchToWindowWithTitle( + 'MetaMask Notification', + windowHandles, + ); + await driver.delay(500); + + // check dialog contents + const result = await driver.findElement('.snap-ui-renderer__panel'); + await driver.scrollToElement(result); + await driver.delay(500); + assert.equal( + await result.getText(), + 'Hello https://metamask.github.io!\nThis is a dialog!', + ); + + // click ok button + await driver.clickElement({ + text: 'OK', + tag: 'button', + }); + + // switch back to test snaps tab + windowHandles = await driver.waitUntilXWindowHandles(2, 1000, 10000); + await driver.switchToWindowWithTitle('Test Snaps', windowHandles); + + // check for result correctness + await driver.waitForSelector({ + css: '#getLocaleResult', + text: 'null', + }); + }, + ); + }); +}); From eca7618d67b81b93d24017b4e19b3d3ff1399e2d Mon Sep 17 00:00:00 2001 From: bowensanders Date: Wed, 13 Sep 2023 13:37:28 -0500 Subject: [PATCH 2/8] fixed enums --- test/e2e/snaps/enums.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/snaps/enums.js b/test/e2e/snaps/enums.js index 4e5a781b516b..71b2b6e2b4b4 100644 --- a/test/e2e/snaps/enums.js +++ b/test/e2e/snaps/enums.js @@ -1,6 +1,6 @@ module.exports = { TEST_SNAPS_WEBSITE_URL: - 'https://metamask.github.io/snaps/test-snaps/0.38.0-flask.1/', + 'https://metamask.github.io/snaps/test-snaps/0.39.0-flask.1/', TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL: - 'https://metamask.github.io/snap-simple-keyring/latest/', + 'https://metamask.github.io/snap-simple-keyring/0.1.4/', }; From 2ce3e456cd8fc4edb3e1572d6432c940e1b1bc35 Mon Sep 17 00:00:00 2001 From: bowensanders Date: Wed, 13 Sep 2023 14:33:44 -0500 Subject: [PATCH 3/8] disabled test in run-all.js --- test/e2e/run-all.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/run-all.js b/test/e2e/run-all.js index 811f6b8fb94c..ff06a82c8646 100644 --- a/test/e2e/run-all.js +++ b/test/e2e/run-all.js @@ -108,6 +108,7 @@ async function main() { 'test-snap-manageAccount.spec.js', 'test-snap-rpc.spec.js', 'test-snap-lifecycle.spec.js', + 'test-snap-get-locale.spec.js', ]; testPaths = testPaths.filter((p) => filteredTests.every((filteredTest) => !p.endsWith(filteredTest)), From f42ba7e770f4d134a2050a7d5164715238d6bf4b Mon Sep 17 00:00:00 2001 From: bowensanders Date: Thu, 14 Sep 2023 10:28:44 -0500 Subject: [PATCH 4/8] added safe-scroll --- test/e2e/snaps/test-snap-get-locale.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/snaps/test-snap-get-locale.spec.js b/test/e2e/snaps/test-snap-get-locale.spec.js index f72c5c742c4a..bb72c5ed1e56 100644 --- a/test/e2e/snaps/test-snap-get-locale.spec.js +++ b/test/e2e/snaps/test-snap-get-locale.spec.js @@ -54,6 +54,8 @@ describe('Test Snap Get Locale', function () { await driver.waitForSelector({ text: 'Install' }); + await driver.clickElementSafe('[data-testid="snap-install-scroll"]'); + await driver.clickElement({ text: 'Install', tag: 'button', From d5d7f6602762ed02638ffd188595d464628348af Mon Sep 17 00:00:00 2001 From: Bowen Sanders Date: Thu, 21 Sep 2023 10:07:59 -0700 Subject: [PATCH 5/8] Update test/e2e/snaps/enums.js Co-authored-by: Frederik Bolding --- test/e2e/snaps/enums.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/snaps/enums.js b/test/e2e/snaps/enums.js index 71b2b6e2b4b4..aa7f488a2bfd 100644 --- a/test/e2e/snaps/enums.js +++ b/test/e2e/snaps/enums.js @@ -1,6 +1,6 @@ module.exports = { TEST_SNAPS_WEBSITE_URL: - 'https://metamask.github.io/snaps/test-snaps/0.39.0-flask.1/', + 'https://metamask.github.io/snaps/test-snaps/0.39.1-flask.1/', TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL: 'https://metamask.github.io/snap-simple-keyring/0.1.4/', }; From d9586ce4ddf6838f442d3e5fd43badcbf06bf62f Mon Sep 17 00:00:00 2001 From: bowensanders Date: Thu, 21 Sep 2023 13:24:47 -0700 Subject: [PATCH 6/8] added locale change and test --- test/e2e/snaps/test-snap-get-locale.spec.js | 54 +++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/e2e/snaps/test-snap-get-locale.spec.js b/test/e2e/snaps/test-snap-get-locale.spec.js index bb72c5ed1e56..bf270935762d 100644 --- a/test/e2e/snaps/test-snap-get-locale.spec.js +++ b/test/e2e/snaps/test-snap-get-locale.spec.js @@ -113,6 +113,60 @@ describe('Test Snap Get Locale', function () { css: '#getLocaleResult', text: 'null', }); + + // try switching language to dansk + // + // switch to the original MM tab + const extensionPage = windowHandles[0]; + await driver.switchToWindow(extensionPage); + await driver.delay(1000); + + // click on the global action menu + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + + // try to click on the notification item + await driver.clickElement({ text: 'Settings', tag: 'div' }); + await driver.delay(1000); + + // try to click on the snaps item + await driver.clickElement({ + text: 'General', + tag: 'div', + }); + await driver.delay(1000); + + // try to click on locale-select + await driver.clickElement('[data-testid="locale-select"]'); + + // try to select dansk from the list + await driver.clickElement({ text: 'Dansk', tag: 'option' }); + + // switch back to test snaps tab + windowHandles = await driver.waitUntilXWindowHandles(2, 1000, 10000); + await driver.switchToWindowWithTitle('Test Snaps', windowHandles); + + // click on alert dialog + await driver.clickElement('#sendGetLocaleHelloButton'); + await driver.delay(500); + + // switch to dialog popup + windowHandles = await driver.waitUntilXWindowHandles(3, 1000, 10000); + await driver.switchToWindowWithTitle( + 'MetaMask Notification', + windowHandles, + ); + await driver.delay(500); + + // check dialog contents for dansk result + const result2 = await driver.findElement('.snap-ui-renderer__panel'); + await driver.scrollToElement(result2); + await driver.delay(500); + assert.equal( + await result2.getText(), + 'Hej https://metamask.github.io!\nDette er en dialog!', + ); }, ); }); From be43fcbf6606b35c24ca3664905ce5802b475fc5 Mon Sep 17 00:00:00 2001 From: Bowen Sanders Date: Tue, 26 Sep 2023 09:19:51 -0700 Subject: [PATCH 7/8] Update enums.js Co-authored-by: Maarten Zuidhoorn --- test/e2e/snaps/enums.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/snaps/enums.js b/test/e2e/snaps/enums.js index b78ae8f7c99c..26c5d0d37536 100644 --- a/test/e2e/snaps/enums.js +++ b/test/e2e/snaps/enums.js @@ -1,6 +1,6 @@ module.exports = { TEST_SNAPS_WEBSITE_URL: - 'https://metamask.github.io/snaps/test-snaps/0.39.1-flask.1/', + 'https://metamask.github.io/snaps/test-snaps/1.0.0/', TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL: 'https://metamask.github.io/snap-simple-keyring/0.2.2/', }; From f26c3acb1d342e5bb4ea29c68519563e22720d0c Mon Sep 17 00:00:00 2001 From: bowensanders Date: Tue, 26 Sep 2023 11:26:32 -0700 Subject: [PATCH 8/8] fixed lint error --- test/e2e/snaps/enums.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/e2e/snaps/enums.js b/test/e2e/snaps/enums.js index 26c5d0d37536..15c9d13788b8 100644 --- a/test/e2e/snaps/enums.js +++ b/test/e2e/snaps/enums.js @@ -1,6 +1,5 @@ module.exports = { - TEST_SNAPS_WEBSITE_URL: - 'https://metamask.github.io/snaps/test-snaps/1.0.0/', + TEST_SNAPS_WEBSITE_URL: 'https://metamask.github.io/snaps/test-snaps/1.0.0/', TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL: 'https://metamask.github.io/snap-simple-keyring/0.2.2/', };