Repository navigation
test(web): replace hardcoded server-fn hex with synthetic fixture - #201
Merged
Merged
Conversation
The server-fn regression tests embedded a live 64-char hex id and its
8-char prefix as literals, which reads as a real production identifier
and puts one in git history. Swap them for `"deadbeef".repeat(8)`,
which keeps the exact shape the transport needs (64-char hex for a
server-fn id, 8-char hex for a story permalink) while being obviously
synthetic, and reword the comments to say "synthetic" instead of
"production".
Behaviour under test is unchanged: `_serverFn` is still in
RESERVED_TOP, so `legacyStoryRedirectPath("/_serverFn/<hex>")` still
returns null and a server-function POST is still never redirected to a
story page. submitStory stays a createServerFn.
Refs #200
Reviewer's guide (collapsed on small PRs)Reviewer's GuideTest fixtures now use obviously synthetic File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 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 |
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.
Fixes #200
What
The server-function regression tests embedded a live 64-char hex id
(
HEX_FN_IDinapps/web/src/server-server-fn.test.ts, and inline in thelegacyStoryRedirectPathtest inapps/web/src/lib/slug.test.ts) along withits 8-char prefix. Those literals read as real production identifiers and put
one into git history. Replaced with
"deadbeef".repeat(8)— obviously fakehex that keeps the exact shape the transport depends on (64-char hex for a
server-fn id, 8-char hex for a story permalink), so every assertion still
exercises the same code path. Comments now say "synthetic" rather than
"production".
grep -rn "98a5ddcb" .is now clean; so is98a5ddcb12725b5c.Also updated the 8-char prefix literals that came from the same id
(
server-server-fn.test.tsregression comment + page-route request, and theisServerFnPathpage-route case inserver-fn-request.test.ts) so nofragment of the real hash is left behind.
98a5ddcb→deadbeefislength- and alphabet-identical, so the routing logic is exercised identically.
What is deliberately NOT changed
We keep
createServerFnfor first-party UI — this is not a rewrite to/apiroutes. The research decision is locked:submitStoryremains acreateServerFn({ method: "POST" })inapps/web/src/lib/submit-fn.ts, andSubmitFormstill calls the typed server function directly./apiis forexternal and webhook consumers only. The real fix for the
"
/_serverFn/*gets 307'd to a story page" failure is the reserved-prefixguard, not changing the transport.
legacyStoryRedirectPath/server.tsbehaviour is untouched:_serverFnis still in
RESERVED_TOP, so/_serverFn/*is never redirected to a storypage.
*-fn.tsfile was rewritten to REST.Verification
vitest run src/server-server-fn.test.ts src/lib/slug.test.ts src/lib/server-fn-request.test.ts→ 3 files, 23 tests passed.biome checkon the three touched files → clean.vitest runinapps/web: 150 files / 1572 tests pass. The 4 failingfiles are a pre-existing environment issue (
Error: No such built-in module: node:sqliteon Node 20.19.2) — verified failing on a clean stash ofmastertoo, unrelated to this change.Summary by Sourcery
Use synthetic hexadecimal identifiers in server-function routing tests to avoid committing live-looking production identifiers while preserving regression coverage.
Enhancements:
Tests: