Skip to content

Commit

Permalink
test(webapp): setup electron tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinepouille committed Nov 14, 2024
1 parent fa4100f commit df9d8c5
Show file tree
Hide file tree
Showing 62 changed files with 272 additions and 133 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
path: |
site
viz
- name: Archive Javascript app
- name: Archive linux electron app
uses: actions/upload-artifact@v4
with:
name: linux
Expand Down Expand Up @@ -193,7 +193,11 @@ jobs:

webapp-playwright-test:
needs: [cli-and-doc, webapp-ubuntu]
if: github.ref == 'refs/heads/master'
# run only on master OR when the PR is _not_ a draft
# TODO: improve this?
if: |
github.ref == 'refs/heads/master' ||
github.event.pull_request.draft == false
timeout-minutes: 75
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -225,6 +229,15 @@ jobs:
' > lighttpd.conf
lighttpd -f lighttpd.conf -D &
sleep 10 && curl -i http://127.0.0.1:12345/index.html # test
- name: Download electron app
uses: actions/download-artifact@v4
with:
name: linux
- name: Setup electron app
run: >-
tar xzf Kappapp.tar.gz
mkdir -p build
mv Kappapp ./build/
- name: Run Playwright tests
run: DEBUG=pw:webserver npx playwright test --retries=3 --trace retain-on-first-failure
- uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion gui/resources/JsSim.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ rect { stroke-width: 2; }
}

.plot-legend-swatch { stroke-width : 1; }
.plot-tick-proof { }
/* .plot-tick-proof { } */
.contact-tooltip { position: fixed;
z-index: 10; padding: 2px;
border-style: solid;
Expand Down
10 changes: 9 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineConfig, devices } from '@playwright/test';

import type { TestOptions } from './tests/playwright/project_electron_param';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
Expand All @@ -11,7 +13,7 @@ import { defineConfig, devices } from '@playwright/test';
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
export default defineConfig<TestOptions>({
testDir: './tests/playwright',
/* Run tests in files in parallel */
fullyParallel: true,
Expand All @@ -33,6 +35,7 @@ export default defineConfig({
},

/* Configure projects for major browsers */
// See https://playwright.dev/docs/test-parameterize#parameterized-projects for electron param definition
projects: [
{
name: 'chromium',
Expand All @@ -44,6 +47,11 @@ export default defineConfig({
use: { ...devices['Desktop Firefox'] },
},

{
name: 'electron',
use: { run_in_electron: true },
},

// TODO: try making the app work on webkit
/*
{
Expand Down
8 changes: 8 additions & 0 deletions tests/playwright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ UPDATE_EXPORTS=true npx playwright test --update-snapshots
UPDATE_EXPORTS=true npx playwright test --update-snapshots --project firefox
UPDATE_EXPORTS=true npx playwright test procedure.spec.ts:449 --update-snapshots
```

### Electron

Local tests with electron need to have access to the actual screen, it seems.
So they should be run with `-j 1` to have a single worker, and the electron window has to stay visible at least.

Downloads open a dialog that is not handled by playwright, so there is no testing of electron downloads.
They may be enabled and completed manually by changing the boolean in `project_electron_param.ts` (untested).
Loading

0 comments on commit df9d8c5

Please sign in to comment.