Files
cloudflare__vinext/tests/cache-runtime-loading.test.ts
James Anderson 0736fdd50b fix(app-router): route server actions through their owning pages (#2520)
* fix(app-router): align server action routing

* perf(app-router): cache action ownership discovery

* fix(app-router): retain client-bound action owners

* fix(app-router): harden action owner forwarding

* fix(app-router): escape action owner metadata

* fix(routing): parse route parameters linearly

* perf(app-router): collect action owners during RSC scans

* perf(app-router): reuse RSC action consumer metadata

* perf(app-router): narrow RSC action metadata patch

* perf(app-router): move action edge analysis into vinext

* fix(app-router): finalize action scan observer integration

* fix(app-router): preserve original action scan metadata

* fix(app-router): retain imported inline action ownership

* test(actions): cover production action ownership edge cases

* fix(build): resolve action runtimes from generated entries

* test(actions): cover nested client form actions

* test(actions): cover same-named non-action exports

* refactor(app-router): derive action owners from final module graphs

* fix(app-router): lazily access RSC plugin API

* fix(app-router): harden action ownership forwarding

* fix(app-router): preserve forwarded action misses

* fix(app-router): resolve shared action owner roots

* fix(app-router): route progressive action owners

* fix(app-router): preserve progressive action routing

* fix(app-router): route bound progressive actions safely

* fix(app-router): preserve forwarded action redirects

* fix(app-router): reject unsafe progressive references

* fix(app-router): validate nested action references

* fix(app-router): decode outlined action chunk ids

* test(app-router): cover cached action ownership

* test(app-router): cover action owner route handlers

* test(app-router): cover direct object-wrapped actions

Adapt the regression from #2743 to assert successful direct form submission through the final action ownership graph.
2026-08-19 01:46:19 +01:00

39 lines
1.3 KiB
TypeScript

import fs from "node:fs";
import path from "node:path";
import { parseSync } from "vite";
import type { ESTree } from "vite";
import { describe, expect, it } from "vite-plus/test";
describe("cache runtime loading", () => {
it("uses cache leaf modules without importing the public cache facade", () => {
const source = fs.readFileSync(
path.join(import.meta.dirname, "../packages/vinext/src/shims/cache-runtime.ts"),
"utf8",
);
const parsed = parseSync("cache-runtime.ts", source, {
astType: "ts",
lang: "ts",
sourceType: "module",
});
const runtimeImports = parsed.program.body
.filter(
(statement): statement is ESTree.ImportDeclaration =>
statement.type === "ImportDeclaration" && statement.importKind !== "type",
)
.map((statement) => statement.source.value);
expect(runtimeImports).toContain("./cache-handler.js");
expect(runtimeImports).toContain("./cache-request-state.js");
expect(runtimeImports).not.toContain("./cache.js");
});
it("replays cached RSC payloads without importing server reference modules", () => {
const source = fs.readFileSync(
path.join(import.meta.dirname, "../packages/vinext/src/shims/cache-runtime.ts"),
"utf8",
);
expect(source).toContain("{ preserveServerReferences: true }");
});
});