Files
siftlode/frontend/src/lib/removedFeatures.contract.test.ts
T
peter eecc195b7e fix(migrations): dropping the demo also takes its reset job's interval-change audit rows
0098 deleted the reset job's run rows but not the scheduler_interval rows that changing its interval
wrote; with the job's label gone they rendered as a raw id. The delete now takes every job-targeted
row for it, and a test seeds both kinds below 0098 and upgrades (red on the old filter). The test
has its own file so the removed-features guard can name it.
2026-10-05 00:19:50 +02:00

52 lines
2.2 KiB
TypeScript

import { readdirSync, readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
// The shared demo account was removed (the owner's decision, 2026-10-04): its user, its whitelist, its
// login entry, and every `is_demo` branch that kept it from quota, YouTube, downloads and the debug
// recorder. A guard left behind is not harmless — it reads as a live rule, and the next reader keeps
// it alive by copying it — so this fails on the word anywhere in the code a feature could live in:
// the backend (app + tests), the frontend (src + e2e) and the repo scripts.
//
// Not scanned: the Alembic migrations (0014 added the account and 0098 removed it, and both stay true
// as history) and the release notes, which record what shipped when. `audit_metrics.py` counts the
// footprint by this same word, and test_migration_0098.py tests the removal itself, so both name it
// on purpose.
const REPO = new URL("../../../", import.meta.url);
const ROOTS = ["backend/app", "backend/tests", "frontend/src", "frontend/e2e", "scripts"];
const SKIP_DIRS = new Set(["node_modules", "__pycache__", "dist", ".speed", "release-notes"]);
const EXTENSIONS = /\.(py|ts|tsx|js|mjs|json|css|md|sh)$/;
const ALLOWED = new Set([
"frontend/src/lib/removedFeatures.contract.test.ts",
"scripts/audit_metrics.py",
"backend/tests/test_migration_0098.py",
]);
// "demo" as a word or an identifier part (`is_demo`, `DemoBanner`, `tryDemo`) — not "demote" (a role
// change) and not "Demokratikus" (a country's Hungarian name in the vocab).
const DEMO = /demo(?!t(e|ion)|kr)/i;
function files(dir: string): string[] {
return readdirSync(new URL(dir, REPO), { withFileTypes: true }).flatMap((e) =>
e.isDirectory()
? SKIP_DIRS.has(e.name)
? []
: files(`${dir}/${e.name}`)
: EXTENSIONS.test(e.name)
? [`${dir}/${e.name}`]
: [],
);
}
describe("removed features stay removed", () => {
it("leaves no trace of the demo account", () => {
const hits = ROOTS.flatMap(files)
.filter((f) => !ALLOWED.has(f))
.flatMap((f) =>
readFileSync(new URL(f, REPO), "utf-8")
.split("\n")
.flatMap((line, i) => (DEMO.test(line) ? [`${f}:${i + 1}: ${line.trim()}`] : [])),
);
expect(hits).toEqual([]);
});
});