Files

82 lines
2.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import {
EXTREME_SCALE_GATES,
satisfiesEngine,
sourceDigest,
vitestCounts,
} from "../../scripts/verify-extreme-scale.ts";
describe("extreme-scale verification runner", () => {
it.each([
["v24.11.0", true],
["24.14.0", true],
["v22.23.2", false],
["24.10.9", false],
["25.0.0", false],
])("checks %s against the repository engine range (%s)", (version, supported) => {
expect(satisfiesEngine(version, ">=24.11.0 <25.0.0")).toBe(supported);
});
it("runs every scale gate and builds before the browser soak tier", () => {
for (const gate of [
"check:types:app",
"check:types:test",
"check:feature-index",
"check:architecture",
"check:app-build-input",
"check:app-build-input:bundle",
"check:request-fanout",
"test:extreme-scale:focused",
"check:topology",
"check:traffic",
"check:observability",
"check:release-coherence",
"check:scale:pr",
"check:scale:main",
"check:scale:nightly",
"check:scale:release",
"check:scale:baseline",
]) {
expect(EXTREME_SCALE_GATES).toContain(gate);
}
expect(EXTREME_SCALE_GATES.indexOf("build")).toBeLessThan(
EXTREME_SCALE_GATES.indexOf("check:scale:nightly"),
);
expect(EXTREME_SCALE_GATES.indexOf("build")).toBeLessThan(
EXTREME_SCALE_GATES.indexOf("check:app-build-input:bundle"),
);
});
});
describe("evidence helpers", () => {
it("sums vitest test counts from coloured multi-run logs", () => {
const esc = String.fromCharCode(27);
const log =
`${esc}[2m Tests ${esc}[22m ${esc}[1m${esc}[32m68 passed${esc}[39m (68)\n` +
" Test Files 3 passed (3)\n" +
" Tests 1 failed | 10 passed | 2 skipped (13)\n";
expect(vitestCounts(log)).toEqual({ passed: 78, failed: 1, skipped: 2, files: 3 });
});
it("changes the source digest when any source file changes", async () => {
const root = await mkdtemp(path.join(tmpdir(), "digest-"));
try {
await mkdir(path.join(root, "src"), { recursive: true });
await writeFile(path.join(root, "src/a.ts"), "export const a = 1;\n");
await writeFile(path.join(root, "package.json"), "{}\n");
const first = await sourceDigest(root);
expect(await sourceDigest(root)).toEqual(first);
await writeFile(path.join(root, "src/a.ts"), "export const a = 2;\n");
expect((await sourceDigest(root)).digest).not.toBe(first.digest);
expect(first.files).toBe(2);
} finally {
await rm(root, { recursive: true, force: true });
}
});
});