mirror of
https://github.com/morluto/rea
synced 2026-10-28 06:46:47 -04:00
fix(javascript): bind Next page admission to source context
This commit is contained in:
@@ -20,12 +20,52 @@ const source = (
|
||||
status: "complete",
|
||||
reason: null,
|
||||
facts: analyzeJavaScriptStaticSource(text).routes!,
|
||||
...(url === null && key.startsWith("app/")
|
||||
? {
|
||||
next_app_context: {
|
||||
kind: "app-directory" as const,
|
||||
directory: "app",
|
||||
package: {
|
||||
path: "package.json",
|
||||
sha256: "b".repeat(64),
|
||||
container_sha256: "c".repeat(64),
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
const build = (inputs: JavaScriptRouteInventoryInput[], bytes?: number) =>
|
||||
javaScriptRouteInventorySchema.parse(
|
||||
completeSemanticSteps(buildJavaScriptRouteInventorySteps(inputs, bytes)),
|
||||
);
|
||||
|
||||
it("does not promote page-shaped paths without source-router applicability", () => {
|
||||
const unknown = source("app/page.js", "");
|
||||
delete (unknown as { next_app_context?: unknown }).next_app_context;
|
||||
const result = build([unknown]);
|
||||
expect(result.routes).toEqual([]);
|
||||
expect(result.unknowns).toMatchObject([
|
||||
{ kind: "interpretation", reason: expect.stringContaining("not measured") },
|
||||
]);
|
||||
});
|
||||
|
||||
it("binds source identity to the package evidence establishing router applicability", () => {
|
||||
const first = source("app/page.js", "");
|
||||
const context = first.next_app_context;
|
||||
if (context?.kind !== "app-directory")
|
||||
throw new Error("Expected declared fixture context");
|
||||
const second = {
|
||||
...first,
|
||||
next_app_context: {
|
||||
...context,
|
||||
package: { ...context.package, sha256: "d".repeat(64) },
|
||||
},
|
||||
};
|
||||
expect(build([first]).sources[0]!.id).not.toBe(
|
||||
build([second]).sources[0]!.id,
|
||||
);
|
||||
});
|
||||
|
||||
it("coalesces exact patterns while retaining independent occurrences and stable identities", () => {
|
||||
const inputs = [
|
||||
source("one.js", `router.push('/reports');`),
|
||||
|
||||
Reference in New Issue
Block a user