Skip to content

Make the /api/sync category parity test read the real getSupportedCategories - #5924

Merged
atomantic merged 1 commit into
mainfrom
claim/issue-5705
Sep 2, 2026
Merged

Make the /api/sync category parity test read the real getSupportedCategories#5924
atomantic merged 1 commit into
mainfrom
claim/issue-5705

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

  • The /api/sync category "parity with getSupportedCategories" test mocked that export to return [] and then iterated a hardcoded copy of the route's own Zod enum — it compared the route to itself. The Optional cross-machine resumable story-builder sessions #730 regression it exists to catch (a category registered in dataSync.CATEGORIES but forgotten in categoryParam, which 400s before the handler runs) produced a green suite.
  • The service mock now delegates getSupportedCategories to the real module via vi.importActual. The three I/O entry points stay stubbed, so the route test still never touches a store.
  • categoryParam is exported from server/routes/dataSync.js so the test compares the two lists symmetrically rather than re-typing one. That also covers the previously unguarded direction: an enum entry the service retired, which reaches a 404 at the service.
  • Per-category cases are generated from the real list, and the assertion moves from not.toBe(400) — which a 500 from a broken handler also satisfies — to the actual contract (200 plus the exact getChecksum arguments).
  • The apply verb parses the same enum as the reads, so it gets no second per-category sweep; its existing case is tightened to assert the exact applyRemote arguments instead of only that it was called.

Rolled in

Pulling the real export loads the whole dataSync service graph, so the settings.js mock spreads the real module instead of listing one export — a hand-listed stub breaks again the next time that graph grows an import. The same graph is why privacyNeverFederates.test.js gets an explicit timeout: its lazy import('../dataSync.js') runs inside the test body and was already flaking against the default 10s cap.

Test plan

  • cd server && npm test — 37715 passing. The two failures in services/sprites/atlas.test.js are pre-existing: verified reproducing on a clean origin/main checkout outside the worktree (7 failures there, 6 on this branch), and untouched by this diff.
  • Bypass probes, run against the fixed test and then reverted:
    • Added a category to CATEGORIES in server/services/dataSync.js without adding it to categoryParam — 2 failures (matches the service category list exactly and the generated checksum case for it). The old test passed this.
    • Added a category to categoryParam that the service does not support — matches the service category list exactly fails. Previously unguarded.
  • Reviewed locally with agy --effort medium; its two substantive findings (use a symmetric list assertion, drop the duplicated apply sweep) are applied above.

Closes #5705

…tedCategories (#5705)

The parity test stubbed `getSupportedCategories` to return `[]` and then
iterated a hardcoded copy of the route's own `categoryParam` enum, so it
compared the route to itself. The #730 regression it exists to catch — a
category registered in `dataSync.CATEGORIES` but forgotten in the route enum,
which 400s before the handler runs — produced a green suite.

The service mock now delegates that one export to the real module
(`vi.importActual`); the three I/O entry points stay stubbed so the route test
still never touches a store. `categoryParam` is exported so the test compares
the two lists symmetrically instead of re-typing one, which also covers the
previously unguarded direction: an enum entry the service retired, which
reaches a 404 at the service. The per-category cases are generated from the
real list, and the assertion moves from `not.toBe(400)` — which a 500 from a
broken handler also satisfies — to the actual contract.

The apply verb parses the same enum as the reads, so it gets no second sweep;
its existing case is tightened to assert the exact `applyRemote` arguments
rather than only that it was called.

Pulling the real export loads the whole dataSync graph, so the settings mock
spreads the real module rather than listing one export. Same reason for the
explicit timeout on the privacy guard's lazy `import('../dataSync.js')`: that
import runs inside the test body and was flaking against the default 10s cap.
@atomantic
atomantic merged commit 4d5748e into main Sep 2, 2026
7 checks passed
@atomantic
atomantic deleted the claim/issue-5705 branch September 2, 2026 22:57
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.

The /api/sync category "parity with getSupportedCategories" test mocks away the thing it claims parity with

1 participant