-
Notifications
You must be signed in to change notification settings - Fork 5.5k
test: add snap-simple-keyring-site as a local server and remove live requests to the site
#36557
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
Changes from all commits
2e2e742
ddfae71
5b322f0
2ae9ae5
5fae7cd
e149e1d
6344fa5
0e0a79b
42b02d0
8718472
3310db5
3079782
7187ab7
a5996de
6f6665c
b9d7684
533b3dd
a544bad
ec19a77
9541866
91be053
1d4109c
d79b247
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,6 +168,7 @@ async function defineAndRunBuildTasks() { | |
| 'browser', // for testing vault corruption | ||
| 'chrome', // for testing vault corruption | ||
| `indexedDB`, // for testing vault corruption | ||
| 'devicePixelRatio', // for using snap simple keyring site | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we allow this, only for tests |
||
| ]; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,7 +128,9 @@ export const lavamoatPlugin = (args: Args) => | |
| // globals opera needs to function | ||
| 'opr', | ||
| // globals used by e2e | ||
| ...(args.test ? ['ret_nodes', 'browser', 'chrome', 'indexedDB'] : []), | ||
| ...(args.test | ||
| ? ['ret_nodes', 'browser', 'chrome', 'indexedDB', 'devicePixelRatio'] | ||
| : []), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same for webpack |
||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -481,6 +481,7 @@ | |
| "@metamask/foundryup": "^1.0.1", | ||
| "@metamask/phishing-warning": "^5.0.1", | ||
| "@metamask/preferences-controller": "^19.0.0", | ||
| "@metamask/snap-simple-keyring-site": "^2.0.0", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ we can now use the npm package
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MetaMask/policy-reviewers I'm adding this new dev dependency which is our snap simple keyring site, so we can use it in our e2e. That pulls in UI libs (MUI, Popper, Emotion/styled-components), which trigger policy entries.
|
||
| "@metamask/superstruct": "^3.2.1", | ||
| "@metamask/test-bundler": "^1.0.0", | ||
| "@metamask/test-dapp": "9.3.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import { TRADES_API_MOCK_RESULT } from '../../data/mock-data'; | |
| import { installSnapSimpleKeyring } from '../page-objects/flows/snap-simple-keyring.flow'; | ||
| import { loginWithBalanceValidation } from '../page-objects/flows/login.flow'; | ||
| import { Mockttp } from '../mock-e2e'; | ||
| import { mockSimpleKeyringSnap } from '../mock-response-data/snaps/snap-binary-mocks'; | ||
| import { mockSnapSimpleKeyringAndSite } from '../tests/account/snap-keyring-site-mocks'; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ in all places we used the mock for the snap simple keyring binary, now we also mock the website |
||
|
|
||
| const DAI = 'DAI'; | ||
| const TEST_ETH = 'TESTETH'; | ||
|
|
@@ -29,7 +29,7 @@ async function mockSwapsTransactionQuote(mockServer: Mockttp) { | |
|
|
||
| async function mockSwapsAndSimpleKeyringSnap(mockServer: Mockttp) { | ||
| return [ | ||
| await mockSimpleKeyringSnap(mockServer), | ||
| ...(await mockSnapSimpleKeyringAndSite(mockServer)), | ||
| await mockSwapsTransactionQuote(mockServer), | ||
| ]; | ||
| } | ||
|
|
@@ -39,9 +39,11 @@ describe('Snap Account - Swap', function () { | |
| it.skip('swaps ETH for DAI using a snap account', async function () { | ||
| await withFixtures( | ||
| { | ||
| dapp: true, | ||
| dappPaths: ['snap-simple-keyring-site'], | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ with this key, we can indicate we want a local server for the snap simple keyring site |
||
| fixtures: new FixtureBuilder().build(), | ||
| title: this.test?.fullTitle(), | ||
| testSpecificMock: mockSwapsAndSimpleKeyringSnap, | ||
| title: this.test?.fullTitle(), | ||
| }, | ||
| async ({ driver }: { driver: Driver }) => { | ||
| await loginWithBalanceValidation(driver); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -279,21 +279,57 @@ async function withFixtures(options, testSuite) { | |
| if (dapp) { | ||
| if (dappOptions?.numberOfDapps) { | ||
| numberOfDapps = dappOptions.numberOfDapps; | ||
| // Note: We don't cap numberOfDapps here even if dappPaths is shorter, | ||
| // because tests may need multiple dapps where some use default paths | ||
| } else if (dappPaths && Array.isArray(dappPaths)) { | ||
| numberOfDapps = dappPaths.length; | ||
| } else { | ||
| // Default to 1 dapp when dapp=true but no specific configuration | ||
| numberOfDapps = 1; | ||
seaona marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| for (let i = 0; i < numberOfDapps; i++) { | ||
| let dappDirectory; | ||
| if (dappPath || (dappPaths && dappPaths[i])) { | ||
| dappDirectory = path.resolve(__dirname, dappPath || dappPaths[i]); | ||
| let currentDappPath; | ||
| if (dappPath) { | ||
| // Single dappPath takes precedence | ||
| currentDappPath = dappPath; | ||
| } else if ( | ||
| dappPaths && | ||
| Array.isArray(dappPaths) && | ||
| i < dappPaths.length | ||
| ) { | ||
| // Use dappPaths[i] if within bounds | ||
| currentDappPath = dappPaths[i]; | ||
| } else { | ||
| dappDirectory = path.resolve( | ||
| __dirname, | ||
| '..', | ||
| '..', | ||
| 'node_modules', | ||
| '@metamask', | ||
| 'test-dapp', | ||
| 'dist', | ||
| ); | ||
| // Fallback to default | ||
| currentDappPath = 'test-dapp'; | ||
| } | ||
|
|
||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| switch (currentDappPath) { | ||
| case 'snap-simple-keyring-site': | ||
| dappDirectory = path.resolve( | ||
| __dirname, | ||
| '..', | ||
| '..', | ||
| 'node_modules', | ||
| '@metamask/snap-simple-keyring-site', | ||
| 'public', | ||
| ); | ||
| break; | ||
| case 'test-dapp': | ||
| dappDirectory = path.resolve( | ||
| __dirname, | ||
| '..', | ||
| '..', | ||
| 'node_modules', | ||
| '@metamask/test-dapp', | ||
| 'dist', | ||
| ); | ||
| break; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ we'll add more cases in the future, for supporting the rest of live site requests to other dapps we use in our test |
||
| default: | ||
| dappDirectory = path.resolve(__dirname, currentDappPath); | ||
| break; | ||
| } | ||
| dappServer.push( | ||
| createStaticServer({ public: dappDirectory, ...staticServerOptions }), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,15 +19,6 @@ const ALLOWLISTED_URLS = [ | |
| 'https://metamask.github.io/snap-account-abstraction-keyring/0.5.0/page-data/app-data.json', | ||
| 'https://metamask.github.io/snap-account-abstraction-keyring/0.5.0/page-data/index/page-data.json', | ||
| 'https://metamask.github.io/snap-account-abstraction-keyring/0.5.0/webpack-runtime-eb27ff9e27bd689ff465.js', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/72585f70-b0685205a809efe121dc.js', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/f36c6662-7e78236bba23a76b6101.js', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/app-f4c2969992b9afb13e7f.js', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/component---src-pages-index-tsx-1bd38618fcde51a7fab0.js', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/framework-fe667a09be4a08a9b5f4.js', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/page-data/app-data.json', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/page-data/index/page-data.json', | ||
| 'https://metamask.github.io/snap-simple-keyring/1.1.6/webpack-runtime-f26b9ef4aabef2136bf7.js', | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. less live requests in our e2e, yay! 🎉 |
||
| 'https://metamask.github.io/snaps/test-snaps/2.28.1', | ||
| 'https://metamask.github.io/snaps/test-snaps/2.28.1/', | ||
| 'https://metamask.github.io/snaps/test-snaps/2.28.1/main.js', | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ the snap file binary changes are just the result of updating the snap package, by running this command: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "Accept-Ranges": "bytes", | ||
| "Content-Length": "746597", | ||
| "Content-Length": "289072", | ||
| "Content-Type": "application/octet-stream", | ||
| "Etag": "\"5e3236532d71422b12b808da978c2fbf\"", | ||
| "Etag": "\"6e270316be30ae430f404e1d920de4db\"", | ||
| "Vary": "Accept-Encoding" | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ added to exceptions to fix the unused dependencies error, because that's not used anywhere (only in the e2e)