1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 03:12:42 +02:00

Nft build for e2e tests (#17430)

This commit is contained in:
Peter Yinusa 2023-01-27 18:45:35 +00:00 committed by GitHub
parent c23bd4925b
commit 245c32a99e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 131 additions and 1 deletions

View File

@ -60,6 +60,9 @@ workflows:
- prep-build-test-mv3:
requires:
- prep-deps
- prep-build-test-nft:
requires:
- prep-deps
- prep-build-test-flask:
requires:
- prep-deps
@ -94,6 +97,12 @@ workflows:
- test-e2e-chrome-mv3:
requires:
- prep-build-test-mv3
- test-e2e-chrome-nft:
requires:
- prep-build-test-nft
- test-e2e-firefox-nft:
requires:
- prep-build-test-nft
- test-unit-mocha:
requires:
- prep-deps
@ -177,6 +186,7 @@ workflows:
- prep-build-storybook
- prep-build-ts-migration-dashboard
- prep-build-test-mv3
- prep-build-test-nft
- benchmark
- user-actions-benchmark
- stats-module-load-init
@ -444,6 +454,27 @@ jobs:
- dist-test-mv3
- builds-test-mv3
prep-build-test-nft:
executor: node-browsers-medium-plus
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Build extension with nft's enabled for testing
command: yarn build:test:nft
- run:
name: Move test build to 'dist-test-nft' to avoid conflict with production build
command: mv ./dist ./dist-test-nft
- run:
name: Move test zips to 'builds-test-nft' to avoid conflict with production build
command: mv ./builds ./builds-test-nft
- persist_to_workspace:
root: .
paths:
- dist-test-nft
- builds-test-nft
prep-build-test:
executor: node-browsers-medium-plus
steps:
@ -650,6 +681,62 @@ jobs:
path: test-artifacts
destination: test-artifacts
test-e2e-chrome-nft:
executor: node-browsers
parallelism: 1
steps:
- checkout
- run:
name: Re-Install Chrome
command: ./.circleci/scripts/chrome-install.sh
- attach_workspace:
at: .
- run:
name: Move test build to dist
command: mv ./dist-test-nft ./dist
- run:
name: Move test zips to builds
command: mv ./builds-test-nft ./builds
- run:
name: test:e2e:chrome
command: |
if .circleci/scripts/test-run-e2e.sh
then
yarn test:e2e:chrome:nft --retries 2
fi
no_output_timeout: 20m
- store_artifacts:
path: test-artifacts
destination: test-artifacts
test-e2e-firefox-nft:
executor: node-browsers
parallelism: 1
steps:
- checkout
- run:
name: Install Firefox
command: ./.circleci/scripts/firefox-install.sh
- attach_workspace:
at: .
- run:
name: Move test build to dist
command: mv ./dist-test-nft ./dist
- run:
name: Move test zips to builds
command: mv ./builds-test-nft ./builds
- run:
name: test:e2e:firefox
command: |
if .circleci/scripts/test-run-e2e.sh
then
yarn test:e2e:firefox:nft --retries 2
fi
no_output_timeout: 20m
- store_artifacts:
path: test-artifacts
destination: test-artifacts
test-e2e-firefox-snaps:
executor: node-browsers
parallelism: 2

View File

@ -21,6 +21,7 @@
"build:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://fake@sentry.io/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build test",
"build:test:flask": "yarn build test --build-type flask",
"build:test:mv3": "ENABLE_MV3=true SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://fake@sentry.io/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build test",
"build:test:nft": "NFTS_V1=1 SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://fake@sentry.io/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build test",
"test": "yarn lint && yarn test:unit && yarn test:unit:jest",
"dapp": "node development/static-server.js node_modules/@metamask/test-dapp/dist --port 8080",
"dapp-chain": "GANACHE_ARGS='-b 2' concurrently -k -n ganache,dapp -p '[{time}][{name}]' 'yarn ganache:start' 'sleep 5 && yarn dapp'",
@ -32,8 +33,10 @@
"test:unit:mocha": "node ./test/run-unit-tests.js --mocha",
"test:e2e:chrome": "SELENIUM_BROWSER=chrome node test/e2e/run-all.js",
"test:e2e:chrome:snaps": "SELENIUM_BROWSER=chrome node test/e2e/run-all.js --snaps",
"test:e2e:chrome:nft": "SELENIUM_BROWSER=chrome node test/e2e/run-all.js --nft",
"test:e2e:firefox": "SELENIUM_BROWSER=firefox node test/e2e/run-all.js",
"test:e2e:firefox:snaps": "SELENIUM_BROWSER=firefox node test/e2e/run-all.js --snaps",
"test:e2e:firefox:nft": "SELENIUM_BROWSER=firefox node test/e2e/run-all.js --nft",
"test:e2e:single": "node test/e2e/run-e2e-test.js",
"test:coverage:mocha": "node ./test/run-unit-tests.js --mocha --coverage",
"test:coverage:jest": "node ./test/run-unit-tests.js --jestGlobal --coverage",

33
test/e2e/nft/nft.spec.js Normal file
View File

@ -0,0 +1,33 @@
const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const FixtureBuilder = require('../fixture-builder');
describe('NFT Feature Flag', function () {
const ganacheOptions = {
accounts: [
{
secretKey:
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
balance: convertToHexValue(25000000000000000000),
},
],
};
it('should display the NFT tab', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder().build(),
ganacheOptions,
title: this.test.title,
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
const nftTab = await driver.findElement(
'[data-testid="home__nfts-tab"]',
);
assert.equal(await nftTab.isDisplayed(), true);
},
);
});
});

View File

@ -50,6 +50,10 @@ async function main() {
description: `run mv3 specific e2e tests`,
type: 'boolean',
})
.option('nft', {
description: `run nft specific e2e tests`,
type: 'boolean',
})
.option('retries', {
description:
'Set how many times the test should be retried upon failure.',
@ -59,13 +63,16 @@ async function main() {
.strict()
.help('help');
const { browser, debug, retries, snaps, mv3 } = argv;
const { browser, debug, retries, snaps, mv3, nft } = argv;
let testPaths;
if (snaps) {
const testDir = path.join(__dirname, 'snaps');
testPaths = await getTestPathsForTestDir(testDir);
} else if (nft) {
const testDir = path.join(__dirname, 'nft');
testPaths = await getTestPathsForTestDir(testDir);
} else {
const testDir = path.join(__dirname, 'tests');
testPaths = [