hermes-agent/apps/desktop/e2e
张豪杰 1535c114c9 test(desktop): cover connection.json owner-only mode end to end
The helpers were tested; nothing proved main.ts called them. Reverting both
call sites and both imports in readDesktopConnectionConfig /
writeDesktopConnectionConfig left the whole suite green (947 passed / 2
skipped, tsc 0, eslint clean, e2e 1 passed 1 skipped) while connection.json
went back to 0644 — the user-visible fix this PR promises was untested.

The e2e spec could not catch it by construction: it asserts the ENCRYPTION
contract with a raw-bytes scan, and safeStorage keeps the token opaque
regardless of the file's mode, so a 0644 file passes that scan every time.
There was no mode assertion anywhere in e2e/.

Adds the missing third contract — unreadable by other local accounts — on all
three paths that can produce the file:

- write: assert the mode of the artifact test 1 already proves the app wrote.
- read, valid file: seed the app's own encrypted connection.json back to 0644
  and assert launch tightens it. Scoped to the MODE only, so it is independent
  of the still-deferred plaintext migration — the fixture's token is already
  ciphertext, so nothing re-encrypts, no #62319 opt-in marker is involved, and
  no rotation guidance is owed.
- read, corrupt file: a truncated file still holds the token bytes and throws
  into the swallowing catch, so it would be the one file never tightened. This
  is the only test that distinguishes the chmod's placement relative to the
  parse.

Also moves the tighten above JSON.parse for exactly that reason, and pins the
cache invariant the placement depends on: the tighten must be a chmod, not a
rewrite, because it sits inside the function whose cache keys on mtimeMs.

Asserted as `mode & 0o077 === 0` rather than `=== 0o600` to avoid a
change-detector, and skipped on win32, where chmod maps to the read-only bit
and the fix deliberately no-ops (ACLs are PR #77527).

Every assertion was mutation-tested: reverting the full wiring fails all three;
reverting only the write path fails only the write test; deleting only the
tighten-on-read fails only the two read tests; moving the tighten below the
parse fails only the corrupt test; making the tighten a rewrite instead of a
chmod fails the mtime assertions. Bundle greps confirmed each mutation reached
dist/electron-main.mjs before the run.

(cherry picked from commit 99cfc16e7c)
2026-08-12 22:38:17 -07:00
..
at-rest-connection-token.spec.ts test(desktop): cover connection.json owner-only mode end to end 2026-08-12 22:38:17 -07:00
boot-failure.spec.ts fix: `tool_calls` double-encoding on import (#68856) 2026-07-21 18:53:05 +00:00
boot.spec.ts fix: `tool_calls` double-encoding on import (#68856) 2026-07-21 18:53:05 +00:00
chat.spec.ts fix(desktop): show steer glyph in busy composer (#69612) 2026-07-22 23:29:38 +00:00
correction-session-switch.spec.ts fix(desktop): preserve correction order in session tabs 2026-07-26 05:00:18 -05:00
fix-electron-tracing.ts fix(desktop): address review — overlay a11y, e2e typecheck, nits 2026-07-20 14:37:39 -04:00
fixtures.ts fix(desktop): reveal every window after a missed ready event, not just the main one 2026-08-08 16:51:44 -05:00
hidden-history-messages.spec.ts fix(timeline): persist typed display events (#69771) 2026-07-23 14:46:24 -04:00
image-attachment-resume.spec.ts fix(desktop): preserve correction order in session tabs 2026-07-26 05:00:18 -05:00
interim-messages.spec.ts test(desktop): add E2E coverage for session lifecycle (#69580) 2026-07-22 22:56:13 +00:00
large-session-resume.spec.ts test(desktop): wait for backfill before the duplicate-count baseline 2026-07-27 01:44:42 -05:00
launch-packaged-app.spec.ts test(desktop): widen HUD composer containment regression coverage (#82319) 2026-08-09 04:03:46 -05:00
mock-backend-setup.spec.ts fix: `tool_calls` double-encoding on import (#68856) 2026-07-21 18:53:05 +00:00
mock-server.ts fix(desktop-e2e): end the sidebar background-dot wall-clock race 2026-07-26 00:12:36 -07:00
onboarding.spec.ts fix: `tool_calls` double-encoding on import (#68856) 2026-07-21 18:53:05 +00:00
queue-turn-boundary.spec.ts fix(desktop): split steer and queue keyboard shortcuts (#69797) 2026-07-23 00:13:58 -04:00
real-session-builder.ts test(desktop): cover attached-image resume end to end 2026-07-24 21:20:52 -05:00
right-pane.spec.ts perf(desktop): isolate right pane layout work 2026-08-03 13:39:33 +05:30
session-compression-and-queue-stop.spec.ts test(desktop): isolate compression from slash completion 2026-07-26 23:34:29 -07:00
sidebar-states.spec.ts fix(desktop-e2e): end the sidebar background-dot wall-clock race 2026-07-26 00:12:36 -07:00
submit-drift.spec.ts test(desktop): cover submit drift through e2e (#69599) 2026-07-22 16:44:54 -04:00
test.ts fix: `tool_calls` double-encoding on import (#68856) 2026-07-21 18:53:05 +00:00
tile-unread-bug.spec.ts fix(desktop-e2e): poll for the finished-unread dot instead of sampling once 2026-07-26 00:12:36 -07:00
visual-snapshot.ts fix(desktop): link artifacts in E2E summary + upload all screenshots 2026-07-20 11:44:41 -04:00
warm-resume-jitter.spec.ts fix(desktop): expect keep-alive tabs not to repaint on reactivation 2026-07-26 05:11:46 -05:00
worktree-branch-status.spec.ts fix(desktop): mount one worktree dialog instead of one per composer 2026-08-05 11:43:09 -04:00