Skip to content

test(agent): pin the file preview sheet - FilePreviewSheet (Closes #1543) - #1969

Merged
dmitrii-f-t27 merged 1 commit into
queenfrom
zcode-mbp/tests-1543-file-preview-sheet
Oct 14, 2026
Merged

dmitrii-f-t27 merged 1 commit into
queenfrom
zcode-mbp/tests-1543-file-preview-sheet

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Collaborator

Closes #1543

What

The first suite for apps/agent/entrypoints/app/agent-command/agent-conversation.file-preview-sheet.tsx (FilePreviewSheet, the only export), under bun test in the agent group.

  • describe block: agentConversationFilePreviewSheetTsxContract (appears nowhere else in the tree).
  • The sheet is controlled, so the static render reaches both states. The agent-files helpers stay real through a query-qualified spread-real read (mock.module registrations persist, so the module keeps its real value exports for every later-linking suite; only useFilePreview is replaced, answering a mutable preview state the test drives branch by branch). The agent-server URL hook answers baseUrl: null β€” exactly what the real hook gives a test process, and what the downstream OpenClaw suites bake in. A portal-free sheet stand-in carries all 8 value exports of the kit.
  • Pin: the closed sheet renders nothing; the open sheet answers the header with the basename and path, the download button, and every branch of the preview union β€” text (snippet, meta, truncation note), image (data url), pdf and binary fallbacks, the missing-file note, and the load failure with its message. The markdown branch and the download click are named in the suite header per User Story 2.
  • FR-004 shown both ways, quoted: broken subject (truncation-note string) β†’ 0 pass / 1 fail; restored β†’ 1 pass / 0 fail / 15 expect(). git diff --name-only lists only the new test file.

Local gates

  • Suite: 1 pass / 0 fail (15 expect()); grep -c 'it(' = 1; 1 + 0 blocked = 1.
  • Group (apps/agent): 260 pass / 3 fail / 263 tests β€” the 3 failures are the pre-existing port-helper noise, unchanged from baseline. (A first draft handing the OpenClaw suites a non-null baseUrl broke 3 of their tests locally β€” caught by the group run before the PR, fixed by answering the real test-env value.)
  • Biome: 0. Typecheck: 19 = base, 0 mentions of the new file.

No database, no container, no network.

@tri-claw

tri-claw Bot commented Oct 14, 2026

Copy link
Copy Markdown

Summary by t27-bees

This PR adds a contract test for FilePreviewSheet, pinning its current behavior across all preview union branches (text, image, pdf, binary, missing, error) and both sheet states (open/closed). The test stubs Radix portals with a portal-free stand-in, keeps agent-files helpers real via a query-qualified import while replacing only useFilePreview, and seeds the port env before the env module snapshots.

Worth a look

  • trios/agent-server/apps/agent/entrypoints/app/agent-command/agent-conversation.file-preview-sheet.test.ts:28 – Mocks useAgentServerUrl to return baseUrl: null, claiming this matches the real hook in test processes. If the real hook's test behavior changes (e.g., starts returning a loopback URL), this test and downstream OpenClaw suites could diverge.
  • trios/agent-server/apps/agent/entrypoints/app/agent-command/agent-conversation.file-preview-sheet.test.ts:44 – Uses a query-qualified import (?file-preview-sheet-real) to get real agent-files exports while mocking only useFilePreview. If the module's export structure changes or the query parameter caching behavior shifts, the spread could pull stale or incorrect values.
  • trios/agent-server/apps/agent/entrypoints/app/agent-command/agent-conversation.file-preview-sheet.test.ts:68 – Stubs the entire @/components/ui/sheet module with a custom portal-free implementation. If the real Sheet component API changes (new required props, different rendering logic), this mock will not catch it and the test will pass against a stale contract.
  • trios/agent-server/apps/agent/entrypoints/app/agent-command/agent-conversation.file-preview-sheet.test.ts:120-180 – Asserts against hardcoded UI strings (e.g., "Showing the first part of this file", "No inline preview for this file type.", "Could not load preview"). Any copy change in the component will break the test without indicating a behavioral regression.
  • trios/agent-server/apps/agent/entrypoints/app/agent-command/agent-conversation.file-preview-sheet.test.ts:95 – Single it block mutates shared previewState to cover all branches. A failure in an early branch (e.g., text preview) prevents later branches (image, pdf, etc.) from being exercised, reducing coverage per run.

Read: 1 files, +200 -0, the whole diff. Head 3eb1fdb. Model: openai-compatible/nvidia/nemotron-3-ultra-550b-a55b. Commands: @t27-bees review | summary | help | pause | resume. Free for every repository.

@github-actions

Copy link
Copy Markdown

βœ… Tests passed β€” 3635/3705

Suite Passed Failed Skipped
βœ… agent 263/263 0 0
βœ… build 9/9 0 0
βœ… cdp-protocol 5/5 0 0
βœ… eval 93/93 0 0
βœ… server-agent 280/280 0 0
βœ… server-api 2159/2228 0 69
βœ… server-browser 6/6 0 0
βœ… server-integration 10/11 0 1
βœ… server-lib 279/279 0 0
βœ… server-pglive 166/166 0 0
βœ… server-root 68/68 0 0
βœ… server-sim 8/8 0 0
βœ… server-skills 31/31 0 0
βœ… server-tools 244/244 0 0
βœ… shared 14/14 0 0

View workflow run

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