Files
EpicNext-Cms/src/features/housekeeping/cutover/route-cutover.test.ts
T

72 lines
2.1 KiB
TypeScript

import { existsSync, readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const CANONICAL_ENTRYPOINTS = [
"src/app/ase/layout.tsx",
"src/app/ase/page.tsx",
"src/app/ase/[domain]/layout.tsx",
"src/app/ase/[domain]/[[...segments]]/page.tsx",
"src/features/housekeeping/route-handlers.ts",
] as const;
const REMOVED_UI_ROOTS = [
"src/app/admin",
"src/app/admin-next",
"src/app/ase-next",
"src/app/mod",
] as const;
const CANONICAL_GLOBAL_SOURCES = [
"src/features/housekeeping/foundation/routing/href.ts",
"src/lib/admin/guard.ts",
"src/lib/proxy-access.ts",
"src/components/navigation.tsx",
"src/components/top-header.tsx",
] as const;
const REMOVED_UI_PATH = /\/(?:admin(?:-next)?|ase-next|mod)(?:[/?"'`]|$)/;
describe("atomic Housekeeping route cutover", () => {
it("publishes the canonical /ase entrypoints and dispatcher", () => {
for (const path of CANONICAL_ENTRYPOINTS) {
expect(existsSync(path), path).toBe(true);
}
});
it("removes every legacy UI tree while preserving internal admin APIs", () => {
for (const path of REMOVED_UI_ROOTS) {
expect(existsSync(path), path).toBe(false);
}
expect(existsSync("src/app/api/admin/csrf/route.ts")).toBe(true);
});
it("uses /ase for global links, proxy access, and authorization fallbacks", () => {
for (const path of CANONICAL_GLOBAL_SOURCES) {
const source = readFileSync(path, "utf8");
expect(source, path).toContain("/ase");
expect(source, path).not.toMatch(REMOVED_UI_PATH);
}
});
it("removes the preview gate and environment flag", () => {
expect(
existsSync("src/features/housekeeping/foundation/preview-gate.ts"),
).toBe(false);
for (const path of ["src/env.ts", ".env.example"] as const) {
expect(readFileSync(path, "utf8"), path).not.toContain(
"HOUSEKEEPING_NEXT_PREVIEW_ENABLED",
);
}
});
it("does not add redirects for removed UI paths", () => {
for (const path of ["next.config.ts", "src/proxy.ts"] as const) {
const source = readFileSync(path, "utf8");
expect(source, path).not.toMatch(
/(?:source|destination|redirect)\s*[:(][^\n]*(?:\/admin|\/admin-next|\/ase-next|\/mod)/,
);
}
});
});