Make the /api/sync category parity test read the real getSupportedCategories - #5924
Merged
Conversation
…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.
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.
Summary
/api/synccategory "parity withgetSupportedCategories" 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 indataSync.CATEGORIESbut forgotten incategoryParam, which 400s before the handler runs) produced a green suite.getSupportedCategoriesto the real module viavi.importActual. The three I/O entry points stay stubbed, so the route test still never touches a store.categoryParamis exported fromserver/routes/dataSync.jsso 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.not.toBe(400)— which a 500 from a broken handler also satisfies — to the actual contract (200 plus the exactgetChecksumarguments).applyRemotearguments instead of only that it was called.Rolled in
Pulling the real export loads the whole
dataSyncservice graph, so thesettings.jsmock 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 whyprivacyNeverFederates.test.jsgets an explicit timeout: its lazyimport('../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 inservices/sprites/atlas.test.jsare pre-existing: verified reproducing on a cleanorigin/maincheckout outside the worktree (7 failures there, 6 on this branch), and untouched by this diff.CATEGORIESinserver/services/dataSync.jswithout adding it tocategoryParam— 2 failures (matches the service category list exactlyand the generated checksum case for it). The old test passed this.categoryParamthat the service does not support —matches the service category list exactlyfails. Previously unguarded.agy --effort medium; its two substantive findings (use a symmetric list assertion, drop the duplicated apply sweep) are applied above.Closes #5705