Skip to content

Commit 80d3723

Browse files
committed
implement basic automation test with playwright
1 parent 3ec8589 commit 80d3723

File tree

11 files changed

+272
-7
lines changed

11 files changed

+272
-7
lines changed

.github/workflows/app-test.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: app-test
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- '**'
8+
- '!*.md'
9+
- '!LICENSE'
10+
- '!.github/**'
11+
pull_request:
12+
branches: [master]
13+
workflow_dispatch:
14+
15+
jobs:
16+
app-test:
17+
runs-on: ${{ matrix.os }}
18+
name: Test NodeJS ${{ matrix.node_version }} on ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
node_version: ['16', '18', '20']
23+
os: [windows-latest, macos-latest, ubuntu-latest]
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Setup NodeJS ${{ matrix.node_version }}
31+
uses: actions/setup-node@v2
32+
with:
33+
node-version: ${{ matrix.node_version }}
34+
cache: npm
35+
cache-dependency-path: '**/package-lock.json'
36+
37+
- name: Cache dependencies
38+
uses: actions/cache@v2
39+
id: npm-cache
40+
with:
41+
path: |
42+
**/node_modules
43+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
44+
restore-keys: |
45+
${{ runner.os }}-npm-
46+
- name: Install dependencies
47+
if: steps.npm-cache.outputs.cache-hit != 'true'
48+
run: npm i
49+
50+
- name: Test module script
51+
run: npm run test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules/
33
release/
44
dist/
5+
tests/results/
56

67
.eslintcache
78
vite-plugin-electron.log

electron-builder.json5

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
buildResources: './buildAssets/installer/',
1111
output: './release/${version}',
1212
},
13-
files: ['dist/**/*', '!release/**/*'],
13+
files: ['dist/**/*', '!release/**/*', '!tests/**/*'],
1414
fileAssociations: [
1515
{
1616
ext: 'swf',

package-lock.json

+153-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727
"dev:debug:force": "vite -d --force",
2828
"build": "npm run build:pre && electron-builder -wml",
2929
"build:pre": "tsc && vite build",
30+
"build:dir": "npm run build:pre && electron-builder --dir",
3031
"build:mac": "npm run build:pre && electron-builder --mac",
3132
"build:win": "npm run build:pre && electron-builder --windows",
3233
"build:linux": "npm run build:pre && electron-builder --linux",
3334
"format": "prettier .",
34-
"format:fix": "prettier . --write"
35+
"format:fix": "prettier . --write",
36+
"test": "npm run build:dir && xvfb-maybe -- playwright test",
37+
"test:nobuild": "xvfb-maybe -- playwright test"
3538
},
3639
"devDependencies": {
40+
"@playwright/test": "^1.36.1",
3741
"@types/react": "^18.2.15",
3842
"@types/react-dom": "^18.2.7",
3943
"@typescript-eslint/parser": "^6.1.0",
@@ -49,12 +53,14 @@
4953
"eslint-plugin-jsx-a11y": "^6.7.1",
5054
"eslint-plugin-react": "^7.33.0",
5155
"eslint-plugin-react-hooks": "^4.6.0",
56+
"playwright": "^1.36.1",
5257
"prettier": "^3.0.0",
5358
"typescript": "^5.1.6",
5459
"vite": "^4.4.6",
5560
"vite-plugin-electron": "^0.12.0",
5661
"vite-plugin-electron-renderer": "^0.14.5",
57-
"vite-plugin-eslint": "^1.8.1"
62+
"vite-plugin-eslint": "^1.8.1",
63+
"xvfb-maybe": "^0.2.1"
5864
},
5965
"dependencies": {
6066
"@emotion/react": "^11.11.1",

playwright.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from '@playwright/test';
2+
3+
export default defineConfig({
4+
outputDir: 'tests/results',
5+
});

src/main/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ global.APP_VERSION_CODE = pkg.versionCode;
5656
global.APP_VERSION_DATE = pkg.versionDate;
5757
global.APP_AUTHOR = pkg.author;
5858
global.APP_RUFFLE_VERSION_DATE = pkg.ruffleVersionDate;
59-
global.ENV_IS_DEV = !app.isPackaged;
59+
global.ENV_IS_DEV = process.env.E2E === 'yes' ? false : !app.isPackaged;
6060
global.ENV_OS = CURRENT_OS;
6161
global.ENV_IS_WINDOWS = CURRENT_OS === 'Windows';
6262
global.ENV_IS_MAC = CURRENT_OS === 'macOS';

src/renderer/components/layouts/Layout.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const Layout = ({
4444
{title}
4545
{withTail ? titleTail : ''}
4646
</title>
47+
<script src="js/ruffle/ruffle.js" />
4748
</Helmet>
4849
{header ? <Header title={title} withBackButton={withBackButton} /> : ''}
4950
<Grid

src/renderer/index.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="utf-8" />
@@ -14,5 +14,4 @@
1414
<div id="app"></div>
1515
</body>
1616
<script type="module" src="./index.tsx"></script>
17-
<script src="js/ruffle/ruffle.js"></script>
1817
</html>

src/renderer/screens/Explorer.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ const Explorer = () => {
142142
<Paper css={paperSm}>
143143
<div
144144
{...getRootProps({
145+
id: 'uiFileOpen',
145146
css: css`
146147
cursor: pointer;
147148
user-select: none;

0 commit comments

Comments
 (0)