mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-24 23:32:19 +10:00
refactor(stylesheet): move Semantic CSS to the browser (#3329)
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user