test(web): Cover the Client and useRun wiring - #29
Merged
Merged
Conversation
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
|
Warning Review limit reachedNext included review available in 45 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
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. Comment |
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.
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.
Closes #27
Changes:
client.test.tswalks the worker protocol through a fakeWorker: init base, ready and failed, ids and transfer lists, error replies, answers, reset and terminateuse-run.test.tsdrives 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 realclient-ziparchive, the empty-batch case from fix(web): Build the download zip on the page one book at a time #28 and the write-back handleshappy-dom,@testing-library/reactand@testing-library/domas dev dependencies withpnpm add -D; the two new files opt into happy-dom per file, the existing tests stay in nodeThe page-to-worker wiring had no tests; only
applyEventfrom 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-rendereris deprecated; Vitest 5.0.0 listshappy-domandjsdomas optional peers and takes either per file, and happy-dom has fewer dependencies for the little the hook needs (a container).@testing-library/react16.3.3 supports React 19 and providesrenderHook;@testing-library/domis its peer.Verified:
pnpm test33 passed (7 existing, 10 client, 16 hook),pnpm typecheck,pnpm format:check. No page change, so nothing to open in the preview.Notes:
act, or the open act scope swallows every later render in the file