refactor(stylesheet): move Semantic CSS to the browser (#3329)

This commit is contained in:
Amruth Pillai
2026-08-16 16:50:27 +02:00
committed by GitHub
parent f848e57436
commit 9509b5bc2e
203 changed files with 11838 additions and 14842 deletions
+7 -22
View File
@@ -108,31 +108,16 @@ describe("createResumePdfFile", () => {
);
});
it("returns semantic diagnostics without rendering an invalid applied source", async () => {
it("renders with base styles when the source is fatal", async () => {
const data = structuredClone(sampleResumeData);
const invalid = { languageVersion: 1, text: "@version 1; section { color: ; }" };
data.metadata.stylesheet = { mode: "semantic", source: invalid, applied: invalid };
const { createResumePdfFileResult } = await import("./server");
const result = await createResumePdfFileResult({ data, filename: "resume.pdf" });
expect(result).toMatchObject({
ok: false,
diagnostics: [expect.objectContaining({ severity: "error" })],
});
expect(rendererMock.renderToBuffer).not.toHaveBeenCalled();
});
it("rejects unchecked rendering instead of producing an unstyled PDF for semantic errors", async () => {
const data = structuredClone(sampleResumeData);
const invalid = { languageVersion: 1, text: "@version 1; section { color: ; }" };
data.metadata.stylesheet = { mode: "semantic", source: invalid, applied: invalid };
data.metadata.stylesheet = { mode: "semantic", source: { languageVersion: 2, text: "@version 2;" } };
const { createResumePdfFile } = await import("./server");
await expect(createResumePdfFile({ data, filename: "resume.pdf" })).rejects.toMatchObject({
cause: [expect.objectContaining({ severity: "error" })],
});
expect(rendererMock.renderToBuffer).not.toHaveBeenCalled();
await expect(createResumePdfFile({ data, filename: "resume.pdf" })).resolves.toHaveProperty(
"type",
"application/pdf",
);
expect(rendererMock.renderToBuffer).toHaveBeenCalledTimes(1);
});
it("rejects renderer-unsafe data at the server boundary before React PDF dispatch", async () => {