Skip to content

test(web): Cover the Client and useRun wiring - #29

Merged
OffCrazyFreak merged 2 commits into
mainfrom
test/run-wiring
Sep 11, 2026
Merged

OffCrazyFreak merged 2 commits into
mainfrom
test/run-wiring

Conversation

@OffCrazyFreak

Copy link
Copy Markdown
Owner

Closes #27

Changes:

  • client.test.ts walks the worker protocol through a fake Worker: init base, ready and failed, ids and transfer lists, error replies, answers, reset and terminate
  • use-run.test.ts drives the hook with a fake client: the phase walk, grouping, unreadable rows, shelved catalogues, live-request answers, stop with a late answer, reset, retry, the sample, and repair in both modes including the real client-zip archive, the empty-batch case from fix(web): Build the download zip on the page one book at a time #28 and the write-back handles
  • Add happy-dom, @testing-library/react and @testing-library/dom as dev dependencies with pnpm add -D; the two new files opt into happy-dom per file, the existing tests stay in node

The page-to-worker wiring had no tests; only applyEvent from the mock simulation was covered, and manual checks in the T3 preview were the only evidence the request ids, the stale-run token, stop, retry and repair behaved.

Why these packages: React 19 needs a DOM to mount into and react-test-renderer is deprecated; Vitest 5.0.0 lists happy-dom and jsdom as optional peers and takes either per file, and happy-dom has fewer dependencies for the little the hook needs (a container). @testing-library/react 16.3.3 supports React 19 and provides renderHook; @testing-library/dom is its peer.

Verified: pnpm test 33 passed (7 existing, 10 client, 16 hook), pnpm typecheck, pnpm format:check. No page change, so nothing to open in the preview.

Notes:

  • A run parked on an unanswered propose must not be awaited inside act, or the open act scope swallows every later render in the file

Changes:
- `client.test.ts` walks the worker protocol through a fake `Worker`: init base, ready and failed, ids and transfer lists, error replies, answers, reset and terminate
- `use-run.test.ts` drives the hook with a fake client: the phase walk, grouping, unreadable rows, shelved catalogues, live-request answers, stop with a late answer, reset, retry, the sample, and repair in both modes including the real `client-zip` archive and the write-back handles
- Add `happy-dom`, `@testing-library/react` and `@testing-library/dom` as dev dependencies; the two new files opt into happy-dom per file, the existing tests stay in node

The page-to-worker wiring had no tests; only `applyEvent` from the mock simulation was covered, and manual checks in the T3 preview were the only evidence the request ids, the stale-run token, stop, retry and repair behaved.

Notes:
- A run parked on an unanswered propose must not be awaited inside `act`, or the open act scope swallows every later render in the file

Closes #27
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 045bd174-3c96-47b6-b57a-17c556e3637a

📥 Commits

Reviewing files that changed from the base of the PR and between db54ea0 and aa8d457.

⛔ Files ignored due to path filters (1)
  • web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • web/package.json
  • web/src/__tests__/client.test.ts
  • web/src/__tests__/use-run.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Changes:
- Assert the exact init base with a stubbed `BASE_URL` instead of a pattern the page URL also matches
- Register the act environment and unmount every hook after its test, since the library does neither without vitest globals
- Cover the pause between books, a reset during runtime load, a runtime failure followed by retry, the failed sample's retry, the folder permission prompt, a prompt that is then granted, an apply that throws, the five-file boundary and the sample after a real run
- Make the retry test prove the second worker ran a book

The first draft could pass with a wrong base URL, left hooks mounted across tests, and never reached the pacing, permission and failure branches.
@OffCrazyFreak
OffCrazyFreak merged commit cd4f7ed into main Sep 11, 2026
4 checks passed
@OffCrazyFreak
OffCrazyFreak deleted the test/run-wiring branch September 11, 2026 21:59
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.

No tests for Client and useRun, the page-to-worker wiring

1 participant