(test): run Playwright journeys against the real Electron app in CI (#304) - #432
Conversation
jsdom has no layout and the unit suites run over fakes, so the four panel defects behind #304 were only found by launching the app. Five journeys now launch it with Playwright under a throwaway HOME, data dir and triggers dir, and assert structure, geometry and what reaches disk: Changes counts and totals, an untracked file opened from its row, an edit saved from the panel editor, the panel shell filling the panel without a sidebar row, and a directory with no git work tree. A new e2e job runs them on ubuntu-latest under xvfb-run, checks first that the native modules load under Electron, and uploads traces and screenshots on failure. task e2e runs them locally. The files sit in e2e/, outside node --test and c8. Refs #304. Not yet shown: a green run on the Linux job, and ten consecutive runs without an intermittent failure.
|
Adversarial review at 3e22c0a: no blocking finding. CI Non-blocking, to fix before merge:
Noted, accepted: the job is not a required check and the ten-run soak is outstanding (hence Checked: isolation of HOME/ |
On Linux and macOS the teardown sent SIGKILL to the main pid only; Playwright already starts Electron as a process-group leader there, so signal the group, falling back to the pid. Windows keeps taskkill /T. The saved-edit journey asserted a row that was already rendered. It now checks the row's counts before the edit and polls until the refresh after the save shows the new line. The launched environment drops every inherited GIT_* variable and HISTFILE, so a GIT_DIR or GIT_INDEX_FILE in the runner cannot point git at another repository.
|
Delta review at 406c9d7: items 1-3 fixed, no finding left. Playwright 1.63.0 spawns Electron detached off Windows (coreBundle.js launchProcess), so the group kill reaches the tree; pid guard excludes 0/-1, ESRCH falls back; the post-save poll waits for {added:2}, which only a refresh from git produces; the env filter keeps what the fixture re-sets. All checks green on this SHA, e2e 5/5. Approved. Still open on #304: the ten-run soak and making e2e a required check. |
Refs #304
What
Five Playwright journeys that launch the real Electron app (
_electron.launch()), plus a CI job that runs them on Linux.e2e/fixtures.js: each test gets its own temporary HOME (and USERPROFILE),SWITCHBOARD_DATA_DIR,SWITCHBOARD_TRIGGERS_DIRand git identity, withCLAUDE*variables dropped. It builds fixture git repositories and transcripts, starts a trace, and on failure savestrace.zipandfailure.png. Teardown is bounded: if the app has not exited within 10 s, the whole process tree is killed, then the HOME is deleted.e2e/changes.spec.js: tracked-file counts and the header total, an untracked file opened from its row, and an edit saved from the panel editor that reaches disk. The editor must take the panel's width, not two 225 px columns.e2e/panel.spec.js: the panel shell opened with no tab fills the panel and is not a sidebar row; Changes on a directory with no git work tree shows the not-a-repository note and no git output..github/workflows/test.yml: newe2ejob (ubuntu-latest,xvfb-run,timeout-minutes: 20). It checks thatbetter-sqlite3andnode-ptyload under Electron, becausepostinstallswallows a failed rebuild. It uploadse2e/test-results/and the HTML report on failure. It is not made a required check here.task e2e/npm run e2e. The new files are outsidenode --test(which reads onlytest/) and are excluded from c8 and from the patch-coverage gate.docs/e2e.md;docs/live-testing.mdupdated now that@playwright/testis a dev dependency; a quick-orientation row in.ai/shared-guidelines.md; a line indocs/README.md.There is no browser download. Native modules are already built for Electron by the existing
postinstall(electron-builder install-app-deps), and the existing test jobs are unchanged.The issue's fifth journey expected the Changes button to disappear. #310 made it unconditional, so the journey checks what the panel says instead.
How it was tested
Locally on Windows 11, against this tree, with the main checkout's Electron 41.0.3 and Playwright 1.63.0: 5 passed (48.8 s).
Each mutation below was applied in the worktree, run, and restored:
.shell-onlyregion rule removed (public/style.css).shell-onlyrules removedisPanelShellSessionskip removed (session-cache.js)panel:ids returned by getProjectsside-by-siderefreshChanges.changes-noteRemoving only the count on open leaves the untracked journey green, because status has already counted the file up front.
Not verified
xvfb-runwork on ubuntu-latest is unproven until it does.task checkwas not run, because the disk was full. Lint passed with 0 errors, and the related unit files passed (102 tests, 0 failed).No changelog entry: users see nothing (
no-changelog).