You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6fe9451
Browse filesBrowse the repository at this point in the historyBrowse files
fix(testing): #582 close three @rangojs/router/testing fidelity gaps (executionContext, scoped reverse, no consumer-object pollution)
Three lower-severity testing-primitive gaps from the #572 audit, all of the
same shape (the harness diverged from production or mutated consumer state):
1. dispatch() resolved router.cache(env, executionContext) with a hardcoded
undefined. A consumer whose cache config branches on executionContext (store
selection, waitUntil availability) resolved a different store/enabled flag in
a dispatch test than in production. Add an executionContext option to
DispatchOptions and thread it to BOTH the cache resolver and
createRequestContext (so ctx.waitUntil also defers to the platform), matching
rsc/handler.ts.
2. renderToFlightString/renderServerTree only had routeName; ctx.reverse stayed
bound to the GLOBAL route map (last-registered router), so a server
component's reverse() was order-dependent across routers/test files. Add a
scoped routeMap option (mirrors renderHandler/runLoader): when supplied,
reverse rebinds to it with the same routeName/params scoping.
3. renderRoute's ensureSyntheticId stamped $$id / __rsc_ls_key onto the
consumer's own loader/locationState objects as ENUMERABLE properties. The
stamp is load-bearing (useLoader/location-state read the id off the SAME
object by identity, so cloning would orphan the data), so the fix is to
define the field NON-ENUMERABLE via Object.defineProperty -- matching how
production stamps __rsc_ls_key (location-state-shared.ts) -- so it no longer
leaks into the consumer's Object.keys/spread/JSON/toEqual.
Userland coverage (through the public primitives):
- dispatch.test.ts: the cache resolver receives the passed executionContext
(and undefined when omitted), and ctx.waitUntil() routes to the platform
executionContext.waitUntil.
- flight.rsc-test.tsx: a server component's reverse() resolves against the
supplied routeMap, and a second render with a different map for the same name
resolves to the new pattern (order-independence).
- render-route.test.tsx: an ad-hoc loader's data still resolves (the stamp is
load-bearing) while Object.keys/spread/JSON of the consumer's object stay
clean ($$id present but non-enumerable).
0 commit comments