From 4b0c8b82ce885abc1e04dac34ce80e07e19ab475 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Thu, 3 Sep 2026 21:09:18 +0200 Subject: [PATCH] test(housekeeping): stabilize live route scan --- .../cutover/route-cutover.test.ts | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/features/housekeeping/cutover/route-cutover.test.ts b/src/features/housekeeping/cutover/route-cutover.test.ts index 2a295cd2..529bdd3c 100644 --- a/src/features/housekeeping/cutover/route-cutover.test.ts +++ b/src/features/housekeeping/cutover/route-cutover.test.ts @@ -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([]); });