mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-10-04 02:33:47 +10:00
Prune the unit and e2e suites to what protects security, user data, public contracts and past regressions. Drop what slowed development without catching bugs: markup and label assertions, wrappers that only proved Base UI works, copied inventories and snapshots, mock call-shape checks, permutation matrices across templates, fonts and locales, and env-gated suites that never ran in CI. - Unit: 4749 tests in 421 files become 1212 in 227. PDF tests that rendered or rasterized every template, font and locale combination go; one render per template stays and now checks that every visible section reaches a page, which a blank page used to pass. - E2E: 55 tests in 35 specs become 11 in 9, one journey per severe area: sign-up and sign-in, autosave, a failed save during navigation, JSON export and import, public and password-protected sharing, slug redirects, OAuth consent for MCP clients, and the assistant. - Tests a coverage review found to be the only guard of a contract were kept or restored, each checked by breaking the code it guards. - Remove exports, tooling and dev dependencies that only the pruned tests used. - The Semantic CSS guide check now reads indented code fences, so the guide example it skipped is compiled too.
92 lines
3.5 KiB
TypeScript
92 lines
3.5 KiB
TypeScript
import { execFileSync } from "node:child_process";
|
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { afterAll, beforeAll, expect, it } from "vitest";
|
|
|
|
const root = fileURLToPath(new URL("../../", import.meta.url));
|
|
const turbo = join(root, "node_modules", "turbo", "bin", "turbo");
|
|
const tasks = ["build", "typecheck", "test", "test:coverage", "test:ci", "test:agent"];
|
|
type DryTask = { taskId: string; task: string; hash: string };
|
|
let directory: string;
|
|
let baseline: Map<string, DryTask>;
|
|
|
|
function dryRun() {
|
|
const output = execFileSync(process.execPath, [turbo, "run", ...tasks, "--dry=json"], {
|
|
cwd: directory,
|
|
encoding: "utf8",
|
|
maxBuffer: 8 * 1024 * 1024,
|
|
env: { ...process.env, TURBO_TELEMETRY_DISABLED: "1" },
|
|
});
|
|
const result = JSON.parse(output) as { tasks: DryTask[] };
|
|
return new Map(result.tasks.map((task) => [task.taskId, task]));
|
|
}
|
|
|
|
beforeAll(async () => {
|
|
directory = await mkdtemp(join(tmpdir(), "reactive-resume-turbo-cache-"));
|
|
const packageJson = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
await writeFile(
|
|
join(directory, "package.json"),
|
|
JSON.stringify({ private: true, packageManager: packageJson.packageManager }),
|
|
);
|
|
await writeFile(join(directory, "pnpm-workspace.yaml"), 'packages: ["packages/*"]\n');
|
|
await writeFile(join(directory, ".gitignore"), "node_modules/\n.turbo/\n");
|
|
await writeFile(join(directory, "turbo.json"), await readFile(join(root, "turbo.json")));
|
|
|
|
// app -> api -> pdf mirrors a source-consumed dependency with no build script.
|
|
const dependencies: Record<string, string[]> = { app: ["api"], api: ["pdf"], pdf: [] };
|
|
let lock = "lockfileVersion: '9.0'\nimporters:\n .: {}\n";
|
|
for (const [name, deps] of Object.entries(dependencies)) {
|
|
const packageDirectory = join(directory, "packages", name);
|
|
await mkdir(packageDirectory, { recursive: true });
|
|
await writeFile(join(packageDirectory, "source.ts"), "export const value = 1;\n");
|
|
await writeFile(
|
|
join(packageDirectory, "package.json"),
|
|
JSON.stringify({
|
|
name,
|
|
version: "0.0.0",
|
|
private: true,
|
|
dependencies: Object.fromEntries(deps.map((dependency) => [dependency, "workspace:*"])),
|
|
scripts: name === "pdf" ? {} : Object.fromEntries(tasks.map((task) => [task, "node -e ''"])),
|
|
}),
|
|
);
|
|
lock += ` packages/${name}:`;
|
|
lock += deps.length
|
|
? `\n dependencies:\n${deps.map((dependency) => ` ${dependency}:\n specifier: workspace:*\n version: link:../${dependency}\n`).join("")}`
|
|
: " {}\n";
|
|
}
|
|
await writeFile(join(directory, "pnpm-lock.yaml"), lock);
|
|
baseline = dryRun();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
if (directory) await rm(directory, { recursive: true, force: true });
|
|
});
|
|
|
|
async function withChangedSource(name: string, check: (result: Map<string, DryTask>) => void) {
|
|
const path = join(directory, "packages", name, "source.ts");
|
|
const original = await readFile(path);
|
|
try {
|
|
await writeFile(path, "export const value = 2;\n");
|
|
check(dryRun());
|
|
} finally {
|
|
await writeFile(path, original);
|
|
}
|
|
}
|
|
|
|
it("invalidates every cached consumer task after a transitive source-only package changes", async () => {
|
|
await withChangedSource("pdf", (result) => {
|
|
for (const name of ["app", "api"]) {
|
|
for (const task of tasks) {
|
|
const id = `${name}#${task}`;
|
|
expect(result.get(id)?.hash, id).not.toBe(baseline.get(id)?.hash);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
it("keeps cache keys stable when sources are unchanged", () => {
|
|
expect(dryRun()).toEqual(baseline);
|
|
});
|