mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test(landing): guard _redirects against catalog drift (#575)
Exports a pure buildRedirects() from generate-redirects.mjs and adds a unit test asserting the committed apps/landing/public/_redirects matches it, so tool additions can't silently leave the generated redirects stale (see #573).
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildRedirects,
|
||||
REDIRECTS_PATH,
|
||||
} from "../../../apps/landing/scripts/generate-redirects.mjs";
|
||||
|
||||
/**
|
||||
* Drift guard: apps/landing/public/_redirects is generated from the shared
|
||||
* TOOLS catalog by scripts/generate-redirects.mjs (runs in the landing
|
||||
* prebuild) but is committed, so it silently goes stale whenever a tool is
|
||||
* added without regenerating it (that is how remove-gif-background's redirects
|
||||
* went missing, PR #573). Adding a tool touches @snapotter/shared and runs this
|
||||
* suite, so the drift fails here at PR time instead of shipping.
|
||||
*/
|
||||
describe("landing _redirects drift", () => {
|
||||
it("committed public/_redirects matches the generator output", () => {
|
||||
const committed = readFileSync(REDIRECTS_PATH, "utf8");
|
||||
expect(
|
||||
committed,
|
||||
"apps/landing/public/_redirects is stale. Regenerate it with `pnpm --filter @snapotter/landing prebuild` and commit the file.",
|
||||
).toBe(buildRedirects());
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user