From 127eeaee7c97f5bca3843d15970292e04b8ad290 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Thu, 17 Sep 2026 17:50:51 -0700 Subject: [PATCH] test(code-pages): make the docs.json redirect round-trip hermetic The round-trip test pruned a real retired model and expected exactly one redirect appended to docs.json. That held on main only until the sync branch ran the generator: it wrote the redirect for that very model, so on that branch the test found it already present, appended nothing, and failed the snippet-script-tests job. Prune a page no provider will ever ship instead, and assert the precondition the test relies on. --- .github/scripts/snippets/gen-code-pages.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/scripts/snippets/gen-code-pages.test.ts b/.github/scripts/snippets/gen-code-pages.test.ts index 6bf3e97b6..7d8b47eee 100644 --- a/.github/scripts/snippets/gen-code-pages.test.ts +++ b/.github/scripts/snippets/gen-code-pages.test.ts @@ -163,11 +163,15 @@ describe("modelPageRedirects: a pruned page keeps answering on its URL", () => { }); describe("renderDocsJson: the redirect lands in the real docs.json", () => { - const retired = "development/comfy-router/models/kling/kling-v1/code"; + // A page no provider will ever ship. The real `docs.json` already carries a + // redirect for every model the generator has retired so far, so a real + // retired id would find its redirect already present and append nothing. + const retired = "development/comfy-router/models/test-provider/never-shipped/code"; const before = JSON.parse(readFileSync(join(ROOT, "docs.json"), "utf8")); const nav = modelsNav([{ model: "kling/kling-v3", page: "development/comfy-router/models/kling/kling-v3/code" }]); test("a pruned page appends exactly one redirect and leaves the others alone", () => { + expect(before.redirects.some((r: { source: string }) => r.source === `/${retired}`)).toBe(false); const after = JSON.parse(renderDocsJson(nav, { live: [], pruned: [retired] })); expect(after.redirects.length).toBe(before.redirects.length + 1); expect(after.redirects.slice(0, -1)).toEqual(before.redirects);