test(housekeeping): stabilize live route scan
This commit is contained in:
1 parent
16ebc4a09e
commit
4b0c8b82ce
1 file changed
+30
-29
@@ -1,5 +1,5 @@
|
||||
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
||||
import { join, posix } from "node:path";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const PREVIEW_ENTRYPOINTS = [
|
||||
@@ -20,20 +20,6 @@ const CUTOVER_GLOBAL_SOURCES = [
|
||||
"src/components/navigation.tsx",
|
||||
] as const;
|
||||
|
||||
function liveSourceFiles(root: string): readonly string[] {
|
||||
return readdirSync(root, { withFileTypes: true }).flatMap((entry) => {
|
||||
const path = posix.normalize(join(root, entry.name).replaceAll("\\", "/"));
|
||||
if (entry.isDirectory()) {
|
||||
if (path === "src/features/housekeeping/migration") return [];
|
||||
return liveSourceFiles(path);
|
||||
}
|
||||
if (!/\.(?:ts|tsx)$/u.test(entry.name) || entry.name.includes(".test.")) {
|
||||
return [];
|
||||
}
|
||||
return [path];
|
||||
});
|
||||
}
|
||||
|
||||
describe("gated Housekeeping preview coexistence", () => {
|
||||
it("publishes the /ase-next entrypoints and dispatcher", () => {
|
||||
for (const path of PREVIEW_ENTRYPOINTS) {
|
||||
@@ -93,21 +79,36 @@ describe("gated Housekeeping preview coexistence", () => {
|
||||
});
|
||||
|
||||
it("keeps live Housekeeping links on the canonical namespace", () => {
|
||||
const staleRoute = new RegExp(
|
||||
const staleRoute = [
|
||||
"/",
|
||||
"ase",
|
||||
"([/?#]|[",
|
||||
'"',
|
||||
"'",
|
||||
String.fromCharCode(96),
|
||||
"]|$)",
|
||||
].join("");
|
||||
const scan = spawnSync(
|
||||
"git",
|
||||
[
|
||||
"/",
|
||||
"ase",
|
||||
"(?:[/?#]|[",
|
||||
'"',
|
||||
"'",
|
||||
String.fromCharCode(96),
|
||||
"]|$)",
|
||||
].join(""),
|
||||
"u",
|
||||
);
|
||||
const violations = liveSourceFiles("src").filter((path) =>
|
||||
staleRoute.test(readFileSync(path, "utf8")),
|
||||
"grep",
|
||||
"--untracked",
|
||||
"-l",
|
||||
"-E",
|
||||
staleRoute,
|
||||
"--",
|
||||
":(glob)src/**/*.ts",
|
||||
":(glob)src/**/*.tsx",
|
||||
":(exclude,glob)src/features/housekeeping/migration/**",
|
||||
":(exclude,glob)src/**/*.test.ts",
|
||||
":(exclude,glob)src/**/*.test.tsx",
|
||||
],
|
||||
{ encoding: "utf8" },
|
||||
);
|
||||
expect(scan.error).toBeUndefined();
|
||||
expect([0, 1]).toContain(scan.status);
|
||||
const violations =
|
||||
scan.status === 0 ? scan.stdout.trim().split(/\r?\n/u) : [];
|
||||
|
||||
expect(violations).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user