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 { spawnSync } from "node:child_process";
|
||||||
import { join, posix } from "node:path";
|
import { existsSync, readFileSync } from "node:fs";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
const PREVIEW_ENTRYPOINTS = [
|
const PREVIEW_ENTRYPOINTS = [
|
||||||
@@ -20,20 +20,6 @@ const CUTOVER_GLOBAL_SOURCES = [
|
|||||||
"src/components/navigation.tsx",
|
"src/components/navigation.tsx",
|
||||||
] as const;
|
] 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", () => {
|
describe("gated Housekeeping preview coexistence", () => {
|
||||||
it("publishes the /ase-next entrypoints and dispatcher", () => {
|
it("publishes the /ase-next entrypoints and dispatcher", () => {
|
||||||
for (const path of PREVIEW_ENTRYPOINTS) {
|
for (const path of PREVIEW_ENTRYPOINTS) {
|
||||||
@@ -93,21 +79,36 @@ describe("gated Housekeeping preview coexistence", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("keeps live Housekeeping links on the canonical namespace", () => {
|
it("keeps live Housekeeping links on the canonical namespace", () => {
|
||||||
const staleRoute = new RegExp(
|
const staleRoute = [
|
||||||
|
"/",
|
||||||
|
"ase",
|
||||||
|
"([/?#]|[",
|
||||||
|
'"',
|
||||||
|
"'",
|
||||||
|
String.fromCharCode(96),
|
||||||
|
"]|$)",
|
||||||
|
].join("");
|
||||||
|
const scan = spawnSync(
|
||||||
|
"git",
|
||||||
[
|
[
|
||||||
"/",
|
"grep",
|
||||||
"ase",
|
"--untracked",
|
||||||
"(?:[/?#]|[",
|
"-l",
|
||||||
'"',
|
"-E",
|
||||||
"'",
|
staleRoute,
|
||||||
String.fromCharCode(96),
|
"--",
|
||||||
"]|$)",
|
":(glob)src/**/*.ts",
|
||||||
].join(""),
|
":(glob)src/**/*.tsx",
|
||||||
"u",
|
":(exclude,glob)src/features/housekeeping/migration/**",
|
||||||
);
|
":(exclude,glob)src/**/*.test.ts",
|
||||||
const violations = liveSourceFiles("src").filter((path) =>
|
":(exclude,glob)src/**/*.test.tsx",
|
||||||
staleRoute.test(readFileSync(path, "utf8")),
|
],
|
||||||
|
{ 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([]);
|
expect(violations).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user