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

feature: add e2e test with playwright #849

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
216fd67
added new e2e framework and CI config
Nov 9, 2023
21bd8fa
change test dir
Nov 9, 2023
c42600a
removed test example
Nov 9, 2023
20165fc
added onboarding tests and changed CI script
Nov 9, 2023
cc86c8a
removed CI scripts for selenium tests
Nov 9, 2023
1144add
fixed CI script and removed unused function
Nov 9, 2023
10abace
removed unused import
Nov 9, 2023
073f6af
CI config improvements
Nov 9, 2023
abc5c07
added onboarding tests for firefox
Nov 9, 2023
bb8a5c4
increase workers for CI tests
Nov 9, 2023
02c9b2c
added docker container for CI tests
Nov 9, 2023
4bf0573
fixing flaky test and removed docker container form CI
Nov 9, 2023
091a58f
added headless mode for tests
Nov 9, 2023
09105c0
updated PR template and fixed whitespaces in the CI config file
Nov 9, 2023
bc4e907
clean up playwright config
Nov 9, 2023
ed1564a
added a few e2e tests for popup
Nov 13, 2023
0ae2614
added a few e2e tests for popup
Nov 14, 2023
c19a2e9
added CI config for popup tests
Nov 14, 2023
98f6b4b
updated CI config for popup tests
Nov 14, 2023
73904e1
skipped all tests except import account
Nov 15, 2023
a498e9a
fixing import account test
Nov 15, 2023
ab104eb
fixing import account test
Nov 15, 2023
c453bc4
fixing import account test
Nov 15, 2023
d234720
fixing import account test
Nov 15, 2023
7c09e4a
fixing import account test
Nov 15, 2023
ae872ee
fixing import account test
Nov 15, 2023
b462f54
fixing import account test
Nov 15, 2023
eb3e75a
fixing import account test
Nov 15, 2023
107b725
fixing tests on CI
Nov 15, 2023
fadef75
use config context
Nov 15, 2023
714b430
testing
Nov 15, 2023
ed3346b
use config context
Nov 15, 2023
b3a6f31
testing
Nov 15, 2023
c9db3af
testing
Nov 15, 2023
e70f006
testing
Nov 15, 2023
ef6887e
added docker container to CI config
Nov 15, 2023
80cd01a
testing
Nov 15, 2023
c20a8f9
testing
Nov 15, 2023
9233651
testing
Nov 15, 2023
51acba3
testing
Nov 15, 2023
57b2376
testing
Nov 15, 2023
6ba7fe4
testing
Nov 15, 2023
1a8d93f
testing
Nov 15, 2023
4d84da0
testing
Nov 15, 2023
6132fb6
testing
Nov 15, 2023
cd7e01e
testing
Nov 15, 2023
5e93b88
testing
Nov 15, 2023
5613ce9
testing
Nov 15, 2023
9e21de8
testing
Nov 15, 2023
00ca63b
testing
Nov 15, 2023
ee0af11
enabled connect account test
Nov 15, 2023
412c227
enabled all popup tests
Nov 15, 2023
2452f76
removed Firefox test from CI
Nov 15, 2023
47c21e8
cleanup
Nov 15, 2023
40d6199
added container to CI config for onboarding tests
Nov 15, 2023
60514a6
cleanup
Nov 15, 2023
4d2e26b
testing
Nov 15, 2023
e401bf8
added signature tests for popup
Nov 16, 2023
5b716c3
added a few new tests
Nov 16, 2023
53e4653
fix import issue
Nov 16, 2023
41cb69c
Merge branch 'develop' into WALLET-214-as-a-casper-wallet-i-need-to-i…
Nov 16, 2023
73df1c6
fixed issues with truncated keys
Nov 16, 2023
7763f12
fixed test issue
Nov 16, 2023
17e2b37
updated playwright config
Nov 16, 2023
f59616e
removed old e2e config and unused packages
Nov 16, 2023
79fd522
added a new test and minor fixes
Nov 17, 2023
d3e2155
minor fix
Nov 17, 2023
23b5496
Merge branch 'develop' into WALLET-214-as-a-casper-wallet-i-need-to-i…
Comp0te Nov 25, 2023
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 .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _**Make sure to fill in all the below sections.**_

## Linked tickets

// Add a `#XXX` link to a related ticket
[WALLET-XXX](https://make-software.atlassian.net/browse/WALLET-XXX)

## Checklist

Expand Down
65 changes: 25 additions & 40 deletions .github/workflows/e2e-onboarding-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,36 @@ on:

jobs:
e2e-onboarding-tests:
timeout-minutes: 60
runs-on: ubuntu-latest

container:
image: node:16

strategy:
fail-fast: false
matrix:
# Add Firefox after fixing CI errors
browser: [ 'chrome' ]
node-version: [ 16.x ]

services:
selenium:
image: selenium/standalone-${{ matrix.browser }}
image: mcr.microsoft.com/playwright:v1.39.0-jammy

steps:
- uses: actions/checkout@v3

- name: Cache npm dependencies
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
node-version: 18

- name: Install dependencies
run: |
npm install

- name: Run E2E onboarding tests on ${{ matrix.browser }}
run: npm run test:e2e:${{ matrix.browser }}:headless:onboarding
env:
SELENIUM_HOST: selenium
SELENIUM_PORT: 4444
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Chrome tests
run: npm run e2e:chrome:headless:onboarding

- uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

- uses: actions/upload-artifact@v3
if: failure()
with:
name: test-results
path: test-results/
retention-days: 30
65 changes: 21 additions & 44 deletions .github/workflows/e2e-popup-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,36 @@ on:

jobs:
e2e-popup-tests:
timeout-minutes: 60
runs-on: ubuntu-latest

container:
image: node:16

strategy:
fail-fast: false
matrix:
# Add Firefox after fixing CI errors
browser: [ 'chrome' ]
node-version: [ 16.x ]

services:
selenium:
image: selenium/standalone-${{ matrix.browser }}
options: --shm-size=2gb
image: mcr.microsoft.com/playwright:v1.39.0-jammy

steps:
- uses: actions/checkout@v3

- name: Cache npm dependencies
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
node-version: 18

- name: Install dependencies
run: |
npm install
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Chrome tests
run: npm run e2e:chrome:headless:popup

- name: Run E2E popup tests on ${{ matrix.browser }}
run: npm run test:e2e:${{ matrix.browser }}:headless:popup
env:
SELENIUM_HOST: selenium
SELENIUM_PORT: 4444
- uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

- name: Add screenshot
uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v3
if: failure()
with:
name: ${{ matrix.browser }}
path: test-artifacts/
name: test-results
path: test-results/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ secrets.*.js

# packed extension
chrome.crx
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,10 @@ You should install Redux DevTools browser extension and connect it to Redux DevT

## E2E tests

Write tests into `e2e/tests` folder.
Write tests into `e2e-tests` folder.

There are a few options to run tests:
To run e2e tests, you must use npm script `npm run e2e:chrome:ui:popup` or `e2e:chrome:ui:onboarding`.
Tests are run in UI mode.

1. In docker container
- Run docker and up containers. `docker compose up` or `docker-compose -f docker-compose.arm.yml up` for Apple M processors
- Use npm scripts `npm run test:e2e:{chrome/firefox}:headless:{popup/onboarding}` depends on target browser and tests
- To see what is happening inside the container, open your web browser and navigate to the URL <http://localhost:7900> for Chrome and <http://localhost:7901> for Firefox, enter the password `secret`, and run your test again
2. Locally on computer
- Use npm scripts `npm run test:e2e:chrome` or `npm run test:e2e:firefox` depends on target browser
All information
about how to run and debug tests can be found in [playwright docs](https://playwright.dev/docs/running-tests).
14 changes: 6 additions & 8 deletions constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { Browser } = require('selenium-webdriver');
const { NODE_ENV, BROWSER: browserEnvVar } = require('./utils/env');

const extensionName = 'Casper Wallet';
Expand All @@ -7,9 +6,9 @@ const buildRootDir = ['test', 'production'].includes(NODE_ENV)
: 'output';

const ExtensionBuildPath = {
Chrome: `${buildRootDir}/${Browser.CHROME}`,
Firefox: `${buildRootDir}/${Browser.FIREFOX}`,
Safari: `${buildRootDir}/${Browser.SAFARI}/${extensionName}`
Chrome: `${buildRootDir}/chrome`,
Firefox: `${buildRootDir}/firefox`,
Safari: `${buildRootDir}/safari/${extensionName}`
};

const ManifestPath = {
Expand All @@ -18,16 +17,15 @@ const ManifestPath = {
v2_Safari: 'src/manifest.v2.safari.json'
};

const isSafari = browserEnvVar && browserEnvVar === Browser.SAFARI;
const isChrome = browserEnvVar && browserEnvVar === Browser.CHROME;
const isFirefox = browserEnvVar && browserEnvVar === Browser.FIREFOX;
const isSafari = browserEnvVar && browserEnvVar === 'safari';
const isChrome = browserEnvVar && browserEnvVar === 'chrome';
const isFirefox = browserEnvVar && browserEnvVar === 'firefox';

module.exports = {
ExtensionBuildPath,
extensionName,
browserEnvVar,
ManifestPath,
Browser,
isFirefox,
isSafari,
isChrome
Expand Down
23 changes: 0 additions & 23 deletions docker-compose.arm.yml

This file was deleted.

23 changes: 0 additions & 23 deletions docker-compose.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIHRZr1HEgKVbgchuatwA7dCWDWB7QZe+bpDb5dguIyLE
-----END PRIVATE KEY-----
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIHRZr1HEgKVbgchuatwA7dCWDWB7QZe+bpDb5dguIyLE
-----END PRIVATE KEY-----
47 changes: 47 additions & 0 deletions e2e-tests/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import path from 'path';

export const vaultPassword = '3hQqzYn4C7Y8rEZTVEZb';
export const recoverSecretPhrase =
'hold matrix spider subway bottom jazz charge fire lawn valley stay coil moral hospital dream cycle multiply december agree huge major tower devote old';
export const secretKeyPath = path.join(__dirname, './account_secret_key.pem');

export const ACCOUNT_NAMES = {
defaultFirstAccountName: 'Account 1',
defaultSecondAccountName: 'Account 2',
createdAccountName: 'New account 1',
importedAccountName: 'Imported account',
renamedAccountName: 'Renamed account'
};

export const PLAYGROUND_URL = 'https://casper-wallet-playground.make.services/';

export const IMPORTED_ACCOUNT = {
accountName: ACCOUNT_NAMES.importedAccountName,
publicKey:
'0184f6d260f4ee6869ddb36affe15456de6ae045278fa2f467bb677561ce0dad55',
truncatedPublicKey: '0184...ad55'
};

export const DEFAULT_FIRST_ACCOUNT = {
accountName: ACCOUNT_NAMES.defaultFirstAccountName,
publicKey:
'0202b1943511b8c23b1b2b8ed7ddcedffcc7be70d9366a5005c7beab08a81b7ae633',
truncatedPublicKey: '0202...e633'
};

export const DEFAULT_SECOND_ACCOUNT = {
accountName: ACCOUNT_NAMES.defaultSecondAccountName,
publicKey:
'0203b2e05f074452f5e69ba512310deceaca152ebd3394eadcec26c6e68e91aa7724',
truncatedPublicKey: '0203...7724'
};

export const VALIDATOR = {
name: 'Validator',
truncatedPublicKey: '0106...a2ca'
};

export const NEW_VALIDATOR = {
name: 'New validator',
truncatedPublicKey: '017d...009e'
};
Loading
Loading