mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-10-03 18:23: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.
55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
import { fileURLToPath } from "node:url";
|
|
import { expect, it } from "vitest";
|
|
import { compileStylesheet } from "@reactive-resume/resume/stylesheet";
|
|
import { buildGeneratedDocumentation } from "./generate-reference";
|
|
|
|
const defaultDocumentationPaths = {
|
|
jsonSchemaGuide: fileURLToPath(new URL("../../docs/guides/json-resume-schema.mdx", import.meta.url)),
|
|
skillSchemaReference: fileURLToPath(new URL("../../skills/resume-builder/references/schema.md", import.meta.url)),
|
|
};
|
|
const applyingCustomStylesGuide = fileURLToPath(new URL("../../docs/applying-custom-styles.mdx", import.meta.url));
|
|
|
|
type SemanticCssExample = { label: string; source: string };
|
|
|
|
const readTargets = (paths: typeof defaultDocumentationPaths) =>
|
|
Promise.all(Object.values(paths).map((path) => readFile(path, "utf8")));
|
|
|
|
function extractSemanticCssExamples(source: string): SemanticCssExample[] {
|
|
const examples: SemanticCssExample[] = [];
|
|
// A fence inside a list item is indented; its content and closing fence share the opening fence's indent.
|
|
const matches = source.matchAll(/^([ \t]*)```css\r?\n([\s\S]*?)\r?\n\1```/gm);
|
|
|
|
for (const [, indent = "", example] of matches) {
|
|
if (!example) throw new Error("Invalid Semantic CSS example.");
|
|
const text = example.replace(new RegExp(`^${indent}`, "gm"), "");
|
|
examples.push({ label: `example ${examples.length + 1}`, source: text });
|
|
}
|
|
|
|
return examples;
|
|
}
|
|
|
|
it("keeps every committed generated document synchronized", async () => {
|
|
const [jsonSchemaGuide, skillSchemaReference] = await readTargets(defaultDocumentationPaths);
|
|
|
|
expect(await buildGeneratedDocumentation(defaultDocumentationPaths)).toEqual({
|
|
jsonSchemaGuide,
|
|
skillSchemaReference,
|
|
});
|
|
});
|
|
|
|
it("compiles every Semantic CSS example in the public guide", async () => {
|
|
const source = await readFile(applyingCustomStylesGuide, "utf8");
|
|
const examples = extractSemanticCssExamples(source);
|
|
expect(examples).not.toEqual([]);
|
|
|
|
for (const example of examples) {
|
|
const result = compileStylesheet({ languageVersion: 1, text: example.source });
|
|
expect(result.program, example.label).not.toBeNull();
|
|
expect(
|
|
result.diagnostics.filter(({ severity }) => severity === "error"),
|
|
example.label,
|
|
).toEqual([]);
|
|
}
|
|
});
|