Skip to content

Commit e245dd2

Browse files
committed
test(router): pin that a static hit is never metered and an orphan layout always is, on both passes (rango-t187)
walker-differential's static-hit and orphan cases now list the segments each walk meters (`metered`), not only that the two walks agree: the static-hit route is absent on both, the orphan layout and its slot present on both. walker-observability-parity's orphan case asserts the orphan layout's d2-handler row on the document and on the navigation. The CHANGELOG entry says a Static() route's navigation row disappears.
1 parent 71fbaaa commit e245dd2

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎packages/rangojs-router/CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ an HTTP redirect" warning on navigations only, not on document loads.
549549
loads too.
550550

551551
What renders is unchanged. No change in your code. A dashboard that reads the
552-
per-segment rows of navigations sees the slot and orphan rows appear.
552+
per-segment rows of navigations sees the slot and orphan rows appear, and a
553+
`Static()` route's row disappear (documents never had it).
553554

554555
## 0.27.0 (2026-10-23)
555556

‎packages/rangojs-router/src/router/segment-resolution/__tests__/walker-differential.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,21 @@ function recordedDifferences(
858858
return out;
859859
}
860860

861+
/**
862+
* The segments a walk meters, by segment id: each `handler:<id>` metric's
863+
* `<id>` is a layout's or route's namespace, or a slot's `parallelName`.
864+
*/
865+
function meteredSegments(walk: Walk): string[] {
866+
const ids = new Map<unknown, string>();
867+
for (const s of walk.segments) {
868+
if (s.type === "parallel") ids.set(s.parallelName, s.id as string);
869+
else if (s.type === "layout" || s.type === "route") {
870+
ids.set(s.namespace, s.id as string);
871+
}
872+
}
873+
return walk.recorded.metered.map((id) => ids.get(id) ?? `?${id}`).sort();
874+
}
875+
861876
function differences(
862877
fresh: Walk,
863878
revalidating: Walk,
@@ -973,6 +988,11 @@ interface Case extends Partial<PassKind> {
973988
expected: Differences;
974989
/** The differences in what the walks report (`Walk.recorded`); none by default. */
975990
recorded?: Differences;
991+
/**
992+
* The segments each walk meters (a `handler:<id>` metric), by segment id;
993+
* both walks alike. Unchecked when absent.
994+
*/
995+
metered?: string[];
976996
}
977997

978998
const CASES: Case[] = [
@@ -1069,6 +1089,7 @@ const CASES: Case[] = [
10691089
expected: {
10701090
"handler ran marker": ["M0L0", "M0L0L0", "M0L0L0R7L0.@aside", "M0L0L0R7"],
10711091
},
1092+
metered: ["M0L0", "M0L0L0", "M0L0L0R7", "M0L0L0R7L0", "M0L0L0R7L0.@aside"],
10721093
},
10731094
{
10741095
name: "routeless layout nested in a cache() marker (#918), route before the marker",
@@ -1251,6 +1272,8 @@ const CASES: Case[] = [
12511272
'M0L0L0R9 route "static hit"',
12521273
],
12531274
expected: {},
1275+
// A static hit runs no handler: neither walk meters the route.
1276+
metered: ["M0L0", "M0L0L0"],
12541277
},
12551278
{
12561279
name: "streamed slot handler returning a Response",
@@ -1282,6 +1305,7 @@ describe("fresh vs revalidating walker, nothing held by the client", () => {
12821305
fresh: freshLines,
12831306
expected,
12841307
recorded = {},
1308+
metered,
12851309
}) => {
12861310
const options = { isSSR, build, intercept, skipLoaders, aboveMarker };
12871311
const fresh = await walk("fresh", pathname, options);
@@ -1309,6 +1333,12 @@ describe("fresh vs revalidating walker, nothing held by the client", () => {
13091333
expect(recordedDifferences(fresh, revalidating, options)).toEqual(
13101334
recorded,
13111335
);
1336+
if (metered) {
1337+
expect({
1338+
fresh: meteredSegments(fresh),
1339+
revalidating: meteredSegments(revalidating),
1340+
}).toEqual({ fresh: metered, revalidating: metered });
1341+
}
13121342
},
13131343
);
13141344
});

‎packages/rangojs-router/src/testing/__tests__/walker-observability-parity.rsc-test.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ describe("a navigation reports a page's handlers as its document does", () => {
162162
it("an orphan layout and its slot have the same rows and spans on a navigation as on the document", async () => {
163163
const document = await serve("/orphan", "document");
164164
const navigation = await serve("/orphan", "navigation");
165+
// The orphan layout's own row, `d2-handler-…orphanlayout<n>`.
166+
const orphanRow = expect.stringMatching(/orphanlayout\d+$/);
167+
expect(document.rows).toContainEqual(orphanRow);
168+
expect(navigation.rows).toContainEqual(orphanRow);
165169
expect(document.spans.some((id) => id.endsWith(".@aside"))).toBe(true);
166170
expect(navigation.rows).toEqual(document.rows);
167171
expect(navigation.spans).toEqual(document.spans);

0 commit comments

Comments
 (0)