feat(electron): add Playwright-driven e2e tests for the demo app#133
Open
Harriet-star-glitch wants to merge 1 commit into
Open
feat(electron): add Playwright-driven e2e tests for the demo app#133Harriet-star-glitch wants to merge 1 commit into
Harriet-star-glitch wants to merge 1 commit into
Conversation
Roadmap floatboatai#25 (End-to-end testing) — no OpenSpec required per the roadmap row. Adds a real end-to-end layer that drives the *packaged* electron-demo build (real Chromium, real main process, real IPC) via playwright-core's `_electron`, catching the class of bug that never shows up in the jsdom unit suite: production build wiring, preload bridge exposure, real layout/paint, real mouse coordinates. - apps/electron-demo/e2e/driver.ts: launchApp()/closeApp() helper. Resolves the electron binary via the `electron` package's own export (portable — no hardcoded paths) and strips ELECTRON_RUN_AS_NODE from the spawned env, since some sandboxed/CI shells set it to stop a stray `electron` invocation from opening a GUI window, which would otherwise make the launch handshake silently time out. - apps/electron-demo/e2e/smoke.e2e.test.ts: three golden-path scenarios — app launches to an empty editor, live-preview renders typed markdown (heading/bold/italic), and a GFM task checkbox toggles via a real DOM click. The checkbox assertion re-queries the element after clicking rather than trusting the original reference: its click handler dispatches a CM6 change whose decoration key embeds the checked state, so CM6 replaces the <input> node synchronously and the original reference is left detached. - apps/electron-demo/vitest.e2e.config.ts + new `test:e2e` script: separate from the default `pnpm test` on purpose — these need a prior `pnpm build` and a display, so keeping them in the default jsdom run would make the fast unit suite flaky in headless CI. - vitest.config.ts: excludes `**/e2e/**` from the root config. Without this, the root `pnpm test` picked the new file up anyway (vitest's default include glob matches any `*.test.ts`, `.e2e.` infix or not) and ran it under jsdom with no built app — confirmed by running `pnpm test` before adding the exclude. - docs/ROADMAP.md: floatboatai#25 marked done, documents how to run it and what's intentionally out of scope for this first pass (vault/file-IO e2e coverage — needs a way to bypass native OS file dialogs, which is its own piece of work). CI wiring (roadmap floatboatai#26, "missing e2e gate") is intentionally not part of this PR — different roadmap item, kept separate per "one PR, one concern". Verified: `pnpm --filter @floatboat/nexus-electron-demo build` then `test:e2e` — 3/3 passing, stable across 3 consecutive runs (~3s each). Full repo `pnpm test` (515/515), `pnpm typecheck`, and `pnpm build` all pass unaffected.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 摘要
Adds a real end-to-end test layer (Roadmap #25) that drives the packaged electron-demo build via Playwright's
_electron— real Chromium, real main process, real IPC — instead of jsdom.Motivation / 背景与动机
Changes / 变更内容
apps/electron-demo:e2e/driver.ts:launchApp()/closeApp()helper. Resolves the electron binary via theelectronpackage's own export (portable, no hardcoded paths) and stripsELECTRON_RUN_AS_NODEfrom the spawned env — some sandboxed/CI shells set it to stop a strayelectroninvocation from opening a GUI window, which would otherwise make the launch handshake silently time out.e2e/smoke.e2e.test.ts: three golden-path scenarios — app launches to an empty editor, live-preview renders typed markdown (heading/bold/italic), and a GFM task checkbox toggles via a real DOM click.vitest.e2e.config.ts+ newtest:e2escript: separate from the defaultpnpm teston purpose (needs a priorpnpm build+ a display).tsconfig.json: includee2e/**/*.tsso it's typechecked.package.json: newplaywright-coredevDependency.vitest.config.ts(root): excludes**/e2e/**. Without this the rootpnpm testpicked the new file up anyway (vitest's default include glob matches any*.test.tsregardless of the.e2e.infix) and ran it under jsdom with no built app — confirmed by actually runningpnpm testbefore adding the exclude and watching it try (and fail the isolation goal, though the individual test happened to still pass).docs/ROADMAP.md: 完成笔试题 #25 → done, documents how to run it and what's out of scope for this first pass.Explicitly out of scope (flagging so it doesn't look like an oversight):
dialog.showOpenDialog), which Playwright can't drive directly; bypassing it needs its own design (e.g. a test-only IPC shortcut) rather than folding it into this PR.Testing / 测试
pnpm testpasses (515/515) — confirmed the e2e file does NOT run here after thevitest.config.tsexclude fixpnpm typecheckpasses repo-widepnpm buildpasses repo-widepnpm --filter @floatboat/nexus-electron-demo build && pnpm --filter @floatboat/nexus-electron-demo test:e2e— 3/3 passing, run 4 times total (~3s each) with no flakiness observedCompliance / 合规自检
test:e2eoutput across multiple runs, and the repo-widepnpm test/typecheck/buildresults, and caught (and had it fix) one real bug along the way: the checkbox e2e assertion originally trusted a stale DOM reference after.click(), which the app's own decoration-keying behavior detaches. I have not independently rewritten the implementation myself. Disclosing this explicitly per GOVERNANCE.md §6.2 rather than checking "not AI-generated" — understand maintainers may decide this doesn't meet that bar.playwright-core@^1.61.1(devDependency,apps/electron-demoonly) — Apache-2.0 license — needed to drive the packaged Electron app from outside its process;-corevariant specifically because it doesn't bundle/download its own browser binaries, it drives the project's own already-installed Electron binary.Checklist / 自检清单
electron-demois a private app, not a published packagelive-preview-table.ts— n/a, not touched in this PR