app: e2e-tests: Make the desktop suite runnable as documented - #6654
Conversation
ff74ea8 to
034f197
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes the developer entry point for running the desktop (Electron) Playwright e2e suite and updates the accompanying README so the suite can be invoked by following the documented steps.
Changes:
- Updated the root
app:test:e2escript to calltest-app(the script that actually exists inapp/e2e-tests). - Added a
pretest-apphook inapp/e2e-teststo ensure the Electron entry point (app/build/main.js) is compiled before tests run. - Rewrote
app/e2e-tests/README.mdto document the real prerequisites and workflows for app vs web mode.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| package.json | Fixes the root e2e script to invoke the correct desktop test script (test-app). |
| app/e2e-tests/package.json | Adds pretest-app to build Electron dev output before running app-mode Playwright tests. |
| app/e2e-tests/README.md | Updates documentation to reflect actual prerequisites and how to run app/web modes. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
app/e2e-tests/README.md:77
- This note says flags cannot be passed through
npm run app:test:e2e, but they can be forwarded if you include an extra--so the secondnpm runreceives the arguments. As written, readers may conclude it’s impossible rather than just slightly awkward.
Note that flags cannot be passed through `npm run app:test:e2e` from the root,
because that delegates to a second `npm run` and the arguments are not
forwarded. Run the script from `app/e2e-tests` when you need flags.
Two problems stopped the desktop e2e suite from being runnable by following the documentation. `npm run app:test:e2e` failed with `Missing script: "test"`. The root script delegated to a `test` script in app/e2e-tests that does not exist; that package only defines `test-app` and `test-web`. Point the root script at `test-app`, which is the mode these tests are written for. Adding a delegating `test` script would also have worked, but it puts another `npm run` in the chain, and arguments are not forwarded across those. The README was missing a required setup step. app/package.json declares `main: build/main.js` and the specs launch the app with `electron .`, which resolves that field, but nothing created it. Rather than document another manual step, build it from a `pretest-app` hook so the suite cannot be run against a missing entry point. The README is rewritten around what the suite actually needs, verified by running it: a minikube cluster named `minikube` (the name matters, and `minikube` and `kubectl` must be on PATH), the frontend and backend built because app mode runs from source, and Chromium installed even though these are Electron tests, because the specs request Playwright's `page` fixture before switching to the Electron window. Also documents that flags cannot be passed through `npm run app:test:e2e` from the root, since that delegates to a second `npm run`. This does not make the suite pass; it currently fails for unrelated reasons tracked in kubernetes-sigs#6648 and fixed in kubernetes-sigs#6641.
034f197 to
7c78437
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: illume, unlikelyzero The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
Two problems stopped the desktop e2e suite from being runnable by following the documentation.
npm run app:test:e2efailed immediately withMissing script: "test". The root script delegated to atestscript inapp/e2e-teststhat does not exist; that package only definestest-appandtest-web.Separately, the README omitted a required setup step.
app/package.jsondeclares"main": "build/main.js"and the specs launch the app withelectron ., which resolves that field, but nothing in the README or the specs created it.Related Issue
Fixes #6633
Fixes #6640
Changes
app:test:e2enow points attest-app, the mode these tests are written for. Adding a delegatingtestscript toapp/e2e-testswould also have fixed the error, but it puts anothernpm runin the chain and arguments are not forwarded across those, so flags would be silently dropped.pretest-apphook that runscompile-electron -- --dev, so the Electron entry point is built automatically and the suite cannot be run against a missing one. That seemed better than documenting one more manual step people can skip.app/e2e-tests/README.mdaround what the suite actually requires.The README changes are based on getting the suite running rather than on reading the source. The previously undocumented requirements:
minikube. The name matters:clusterRename.spec.tsexpects it, andclusterAutoConnect.spec.tsshells out tominikubedirectly to create and delete its own throwaway profile, so bothminikubeandkubectlmust be onPATH.ELECTRON_DEV=true,app/electron/main.tsresolves../frontend/build/index.html(main.ts:91) and../backend/headlamp-server(main.ts:772).pagefixture before switching to the Electron window, and requesting it launches a browser. This one is easy to miss.It also documents that flags cannot be passed through
npm run app:test:e2efrom the repository root, because that delegates to a secondnpm run; run the script fromapp/e2e-testswhen you need flags.Steps to Test
The script fix, which needs no cluster:
The pre-hook, which is the point of the second fix:
That the suite is discoverable, without running it:
Then follow the README from a clean checkout and confirm you reach a running suite.
Screenshots (if applicable)
Not applicable, docs and npm scripts only.
Notes for the Reviewer
pretest-appversus documenting the step. npm runspre<script>automatically fornpm run test-app, so this costs nothing at the call site. The alternative was a README line saying "remember to run compile-electron first", which is the kind of step people skip and which produced a confusing failure. Happy to switch to documentation only if you would rather the scripts stay minimal.test-appgets the pre-hook, because web mode does not launch Electron and so does not needbuild/main.js.e2e-testsREADME, which has a similar but separate mismatch tracked in e2e-tests/README.md setup does not match what the tests require #6634.