Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 18 additions & 24 deletions .github/scripts/split-tests-by-timings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
// Quality Gate Retries
const RETRIES_FOR_NEW_OR_CHANGED_TESTS = 4;

function readTestResults(TEST_RESULTS_PATH: string): TestRun | undefined {
function readTestResults(TEST_RESULTS_PATH: string): TestRun {
const testSuiteName =
process.env.TEST_SUITE_NAME || 'test-e2e-chrome-browserify';

Expand All @@ -19,9 +19,12 @@ function readTestResults(TEST_RESULTS_PATH: string): TestRun | undefined {
readFileSync(TEST_RESULTS_PATH, 'utf8'),
);

const testRun: TestRun | undefined = testRuns.find(
const testRun: TestRun = testRuns.find(
(run) => run.name === testSuiteName,
);
) || { // If the file doesn't exist, return a dummy object to do the naïve split
name: testSuiteName,
testFiles: [],
};

return testRun;
} catch (error) {
Expand Down Expand Up @@ -82,31 +85,22 @@ export function splitTestsByTimings(
TEST_RESULTS_FILE = `test/test-results/test-runs-${process.env.SELENIUM_BROWSER}.json`,
} = process.env;

try {
const testRunLastTime = readTestResults(TEST_RESULTS_FILE);

if (testRunLastTime) {
let testRunNew: TestRun = { name: testRunLastTime.name, testFiles: [] };
const testRunLastTime = readTestResults(TEST_RESULTS_FILE);
let testRunNew: TestRun = { name: testRunLastTime.name, testFiles: [] };

testList.forEach((path) => {
const testFileLastTime = testRunLastTime.testFiles.find(
(file) => file.path === path,
);

if (testFileLastTime) {
testRunNew.testFiles.push(testFileLastTime);
} else {
testRunNew.testFiles.push(getNewBlankTestFile(path));
}
});
testList.forEach((path) => {
const testFileLastTime = testRunLastTime.testFiles.find(
(file) => file.path === path,
);

return splitTests(testRunNew, changedOrNewTests, totalChunks);
if (testFileLastTime) {
testRunNew.testFiles.push(testFileLastTime);
} else {
testRunNew.testFiles.push(getNewBlankTestFile(path));
}
} catch (error) {
console.trace(error);
}
});

return [];
return splitTests(testRunNew, changedOrNewTests, totalChunks);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e-chrome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ jobs:
matrix-index: ${{ matrix.index }}
matrix-total: ${{ strategy.job-total }}

test-e2e-chrome-vault-decryption:
test-e2e-chrome-dist:
# This if statement is equivalent to IS_FORK
if: ${{ !(github.event.pull_request.head.repo.fork || github.event.repository.fork) }}
uses: ./.github/workflows/run-e2e.yml
with:
test-suite-name: test-e2e-chrome-vault-decryption
test-suite-name: test-e2e-chrome-dist
build-artifact: build-dist-browserify
test-command: yarn test:e2e:single test/e2e/vault-decryption-chrome.spec.ts --browser chrome
test-command: yarn test:e2e:chrome:dist

test-e2e-chrome-api-specs:
uses: ./.github/workflows/run-e2e.yml
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
- test-e2e-chrome-multiple-providers
- test-e2e-chrome-rpc
- test-e2e-chrome-flask
- test-e2e-chrome-vault-decryption
- test-e2e-chrome-dist
- test-e2e-chrome-api-specs
- test-e2e-chrome-api-specs-multichain
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/e2e-firefox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ jobs:
matrix-index: ${{ matrix.index }}
matrix-total: ${{ strategy.job-total }}

test-e2e-firefox-dist:
uses: ./.github/workflows/run-e2e.yml
with:
test-suite-name: test-e2e-firefox-dist
build-artifact: build-dist-mv2-browserify
test-command: yarn test:e2e:firefox:dist

test-e2e-firefox-report:
needs:
- test-e2e-firefox-browserify
- test-e2e-firefox-flask
- test-e2e-firefox-dist
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ jobs:
e2e-firefox:
needs:
- needs-e2e
- build-dist-mv2-browserify
- build-test-mv2-browserify
- build-test-flask-mv2-browserify
if: ${{ needs.needs-e2e.outputs.needs-e2e == 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ app/.DS_Store
storybook-build/
coverage/
jest-coverage/
dist
/dist
builds*/
builds.zip
development/ts-migration-dashboard/build
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"test:integration": "yarn webpack-cli build --config ./development/webpack/webpack.integration.tests.config.ts && jest --config jest.integration.config.js",
"test:integration:coverage": "yarn test:integration --coverage",
"test:e2e:chrome": "SELENIUM_BROWSER=chrome tsx test/e2e/run-all.ts",
"test:e2e:chrome:dist": "SELENIUM_BROWSER=chrome tsx test/e2e/run-all.ts --dist",
"test:e2e:chrome:flask": "SELENIUM_BROWSER=chrome tsx test/e2e/run-all.ts --build-type flask",
"test:e2e:chrome:webpack": "SELENIUM_BROWSER=chrome tsx test/e2e/run-all.ts",
"test:api-specs": "SELENIUM_BROWSER=chrome tsx test/e2e/run-openrpc-api-test-coverage.ts",
Expand All @@ -63,6 +64,7 @@
"test:e2e:chrome:rpc": "SELENIUM_BROWSER=chrome tsx test/e2e/run-all.ts --rpc",
"test:e2e:chrome:multi-provider": "MULTIPROVIDER=true SELENIUM_BROWSER=chrome tsx test/e2e/run-all.ts --multi-provider",
"test:e2e:firefox": "SELENIUM_BROWSER=firefox tsx test/e2e/run-all.ts",
"test:e2e:firefox:dist": "SELENIUM_BROWSER=firefox tsx test/e2e/run-all.ts --dist",
"test:e2e:firefox:flask": "SELENIUM_BROWSER=firefox tsx test/e2e/run-all.ts --build-type flask",
"test:e2e:single": "node test/e2e/run-e2e-test.js",
"ganache:start": "./development/run-ganache.sh",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import os from 'os';
import path from 'path';
import fs from 'fs-extra';
import level from 'level';
import { Driver } from './webdriver/driver';
import { WALLET_PASSWORD, WINDOW_TITLES, withFixtures } from './helpers';
import HeaderNavbar from './page-objects/pages/header-navbar';
import HomePage from './page-objects/pages/home/homepage';
import PrivacySettings from './page-objects/pages/settings/privacy-settings';
import SettingsPage from './page-objects/pages/settings/settings-page';
import VaultDecryptorPage from './page-objects/pages/vault-decryptor-page';
import { completeCreateNewWalletOnboardingFlowWithCustomSettings } from './page-objects/flows/onboarding.flow';
import { Driver } from '../webdriver/driver';
import { WALLET_PASSWORD, WINDOW_TITLES, withFixtures } from '../helpers';
import HeaderNavbar from '../page-objects/pages/header-navbar';
import HomePage from '../page-objects/pages/home/homepage';
import PrivacySettings from '../page-objects/pages/settings/privacy-settings';
import SettingsPage from '../page-objects/pages/settings/settings-page';
import VaultDecryptorPage from '../page-objects/pages/vault-decryptor-page';
import { completeCreateNewWalletOnboardingFlowWithCustomSettings } from '../page-objects/flows/onboarding.flow';

const VAULT_DECRYPTOR_PAGE = 'https://metamask.github.io/vault-decryptor';

Expand Down Expand Up @@ -165,6 +165,10 @@ async function closePopoverIfPresent(driver: Driver) {

describe('Vault Decryptor Page', function () {
it('is able to decrypt the vault uploading the log file in the vault-decryptor webapp', async function () {
if (process.env.SELENIUM_BROWSER !== 'chrome') {
// TODO: Get this working on Firefox
this.skip();
}
await withFixtures(
{
disableServerMochaToBackground: true,
Expand Down Expand Up @@ -223,6 +227,10 @@ describe('Vault Decryptor Page', function () {
});

it('is able to decrypt the vault pasting the text in the vault-decryptor webapp', async function () {
if (process.env.SELENIUM_BROWSER !== 'chrome') {
// TODO: Get this working on Firefox
this.skip();
}
await withFixtures(
{
disableServerMochaToBackground: true,
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/run-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ async function main(): Promise<void> {
description: `run json-rpc specific e2e tests`,
type: 'boolean',
})
.option('dist', {
description: `run e2e tests for production-like builds`,
type: 'boolean',
})
.option('multi-provider', {
description: `run multi injected provider e2e tests`,
type: 'boolean',
Expand Down Expand Up @@ -128,6 +132,7 @@ async function main(): Promise<void> {
const {
browser,
debug,
dist,
retries,
rpc,
buildType,
Expand All @@ -137,6 +142,7 @@ async function main(): Promise<void> {
} = argv as {
browser?: 'chrome' | 'firefox';
debug?: boolean;
dist?: boolean;
retries?: number;
rpc?: boolean;
buildType?: string;
Expand All @@ -161,6 +167,9 @@ async function main(): Promise<void> {
...(await getTestPathsForTestDir(path.join(__dirname, 'flask'))),
...featureTestsOnMain,
];
} else if (dist) {
const testDir = path.join(__dirname, 'dist');
testPaths = await getTestPathsForTestDir(testDir);
} else if (rpc) {
const testDir = path.join(__dirname, 'json-rpc');
testPaths = await getTestPathsForTestDir(testDir);
Expand Down
Loading