Skip to content

test: share one fake desktop runtime across e2e specs - #139

Merged
vycdev merged 2 commits into
developfrom
test/issue-134-fake-desktop
Nov 7, 2026
Merged

vycdev merged 2 commits into
developfrom
test/issue-134-fake-desktop

Conversation

@vycdev

@vycdev vycdev commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Refs #134.

What

Adds tests/e2e/helpers/fakeDesktop.ts, one fake Tauri runtime for e2e specs:

  • Installs window.isTauri, __TAURI_INTERNALS__ (invoke and transformCallback), and __TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener.
  • Answers every startup command with neutral defaults: get_app_version returns 4.1.0, check_for_updates and take_opened_file return null, and plugin:event|listen/unlisten register and remove real listeners.
  • Specs handle only the commands they test with desktop.handle(command | commands[], (args, command) => …), which replaces a default if one exists. Any other command still throws (Unexpected desktop command: …), so a new native call is noticed.
  • desktop.calls records every command name; desktop.emit(event, payload) delivers events to listeners.
  • Two entry points, one for each existing style:
    • fakeDesktopBeforeLoad(page, setup?, arg?) uses an init script and runs before any app code.
    • fakeDesktopAfterLoad(page, setup?, arg?) uses page.evaluate for specs that check web behavior first and then switch. App is lazy-loaded, so startup code can still run against the fake. Because the startup commands now have defaults, that is harmless, and specs no longer need to sequence around it.
  • Node-side helper: fakeDesktopCalls(page).

setup runs in the page, so like any Playwright page function it must be self-contained. arg must be JSON-serializable.

Migrated specs

  • Before load: i18n.spec.ts (release notes), settings-legal-links.spec.ts, desktop-file-open.spec.ts. The opened-file signal() is now desktop.emit('kromacut-opened-files'), still in the same page task as the queue push, and the spec-local calls log is now fakeDesktopCalls.
  • After load: i18n.spec.ts (desktop save prompts), palette-, profile-, hd-calibration-, and stack-matrix-desktop-save.spec.ts. Each still keeps its own save-flow state and handlers. Only the runtime plumbing moved.

No CI workflows or npm scripts changed (those are in #138's scope). There is no changelog entry, since this is test-only infrastructure with no new coverage.

Verification

  • npm run lint and tsc -b pass.
  • CI=1 npx playwright test --config playwright.i18n.config.ts: 17 passed.
  • The other six migrated specs, all tests in each (not just @smoke), under the default playwright.config.ts settings (production build + preview): 34 passed. Port 5173 was held by another worktree's preview server, so I ran them through a temporary config that only changed the port to 5274 and disabled server reuse. That config is not committed.

🤖 Generated with Claude Code

vycdev and others added 2 commits November 7, 2026 13:26
Add tests/e2e/helpers/fakeDesktop.ts, which installs isTauri and
__TAURI_INTERNALS__ (with transformCallback and event listen/unlisten),
answers the desktop startup commands with neutral defaults, and throws
on any command a spec did not handle. Move the seven specs that wrote
their own fakes onto it, before or after load.

Refs #134

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Addresses self-review of #139: push files and emit the inbox event in
one page task as before, add unregisterCallback so Channel cleanup has a
fake, document the JSON-only arg for fakeDesktopAfterLoad, and drop the
unused emitDesktopEvent helper.

Refs #134

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant