Skip to content

Commit

Permalink
Update electron and e2e tests framework with webdriver (#455)
Browse files Browse the repository at this point in the history
* tests: add webdriver tests for e2e app testing on local and gh actions

* chore: upgrade electron from v25 to v27, rebuild to 3.4.1

* fix: register powerMonitor handlers after app ready, electron bug

* chore: only run e2e tests on pr to main or manually
  • Loading branch information
jgresham authored Dec 13, 2023
1 parent 8ef742e commit 449e1be
Show file tree
Hide file tree
Showing 26 changed files with 9,515 additions and 5,852 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ src/stories
src/stories/Generic
src/stories/Presentational
storybook-static

.eslintrc.js
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json',
project: ['./tsconfig.json', './tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
createDefaultProgram: true,
},
Expand All @@ -68,4 +68,7 @@ module.exports = {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
env: {
mocha: true,
},
};
51 changes: 51 additions & 0 deletions .github/workflows/e2e-test-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: e2e-tests-mac

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
e2e-build-n-test:
environment: staging
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-latest]
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: 💚 Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: 🧱 Install Dependencies
run: |
npm install
# This dependency wasn't needed until suddenly on Dec. 2, 2022
npm i dmg-license
shell: bash

- name: 📦 Bundle Application
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
MP_PROJECT_TOKEN: ${{ secrets.MP_PROJECT_TOKEN }}
MP_PROJECT_ENV: ${{ vars.MP_PROJECT_ENV }}
NICENODE_ENV: ${{ vars.NICENODE_ENV }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
npm run package
ls -al
- name: 🧪 Run Tests
uses: coactions/setup-xvfb@v1
with:
run: npm run wdio
- name: 🐛 Debug Build
uses: stateful/vscode-server-action@v1
if: failure()
with:
timeout: '120000'
49 changes: 49 additions & 0 deletions .github/workflows/e2e-test-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: e2e-tests-ubuntu

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
e2e-build-n-test:
environment: staging
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: 💚 Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: 🧱 Install Dependencies
run: |
npm install
sudo apt-get install --no-install-recommends -y rpm libarchive-tools
- name: 📦 Bundle Application
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
MP_PROJECT_TOKEN: ${{ secrets.MP_PROJECT_TOKEN }}
MP_PROJECT_ENV: ${{ vars.MP_PROJECT_ENV }}
NICENODE_ENV: ${{ vars.NICENODE_ENV }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
npm run package -- --linux --dir
ls -al ./release/build/linux-unpacked/
- name: 🧪 Run Tests
uses: coactions/setup-xvfb@v1
with:
run: npm run wdio
- name: 🐛 Debug Build
uses: stateful/vscode-server-action@v1
if: failure()
with:
timeout: '120000'
51 changes: 51 additions & 0 deletions .github/workflows/e2e-test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: e2e-tests-windows

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
e2e-build-n-test:
environment: staging
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: 💚 Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: 🧱 Install Dependencies
run: |
npm install
- name: 📦 Bundle Application
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
MP_PROJECT_TOKEN: ${{ secrets.MP_PROJECT_TOKEN }}
MP_PROJECT_ENV: ${{ vars.MP_PROJECT_ENV }}
NICENODE_ENV: ${{ vars.NICENODE_ENV }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
# run: npm run package
# if [ "$RUNNER_OS" == "macOS" ]; then
# npm run package -- --mac --x64
# elif [ "$RUNNER_OS" == "Windows" ]; then
# npm run package -- --win --x64
run: npm run package

- name: 🧪 Run Tests
uses: coactions/setup-xvfb@v1
with:
run: npm run wdio
- name: 🐛 Debug Build
uses: stateful/vscode-server-action@v1
if: failure()
with:
timeout: '120000'
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
".prettierrc": "jsonc",
".eslintignore": "ignore"
},

"javascript.validate.enable": false,
"javascript.format.enable": false,
"typescript.format.enable": false,

"search.exclude": {
".git": true,
".eslintcache": true,
Expand All @@ -22,9 +20,11 @@
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["javascript"],
"eslint.validate": [
"javascript"
],
"eslint.format.enable": false,
"prettier.configPath": "package.json"
}
}
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ For a specific platform & architecture:

```bash
npm run package -- --linux --arm64
npm run package -- --mac dmg --arm64
```

## Tests

Unit tests with `npm run test`

### End-to-end (e2e) tests

For e2e tests, we use webdriver and an electron plugin to automate testing.
It requires a packaged build to complete the tests.

To run them locally, package the source first (and after making any changes to anything other than `tests`), then run the e2e tests with `wdio`

```bash
npm run package <your os and arch>
npm run wdio
```

## Running Storybook
Expand Down
Loading

0 comments on commit 449e1be

Please sign in to comment.