/** * A synthetic institutional donor .docx for the report-renderer tests. * * The real donor in reference/ is gitignored, so tests build a minimal * stand-in that exercises the same parts the renderer touches: a body whose * sectPr references header/footer parts, a header carrying a VML watermark * plus a banner image, a footer, table styles, and media. The renderer must * preserve every part except the body, so the fixture asserts that claim. */ import JSZip from "jszip"; // A 1×1 transparent PNG. const TINY_PNG = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; const CONTENT_TYPES = ` `; const ROOT_RELS = ` `; const DOCUMENT_RELS = ` `; const HEADER_RELS = ` `; const STYLES = ` `; const SETTINGS = ` `; // A header that carries a VML watermark shape (like Word's "Picture Watermark" // feature) and a banner image. Kept deliberately fake but structurally real. const HEADER = ` `; const FOOTER = ` PAGE1 | Page `; const DOCUMENT = ` DONOR BODY TEXT TO BE STRIPPED Second paragraph that must not survive injection. `; /** Build the synthetic donor as a Buffer. */ export async function buildDonor() { const zip = new JSZip(); zip.file("[Content_Types].xml", CONTENT_TYPES); zip.file("_rels/.rels", ROOT_RELS); zip.file("word/document.xml", DOCUMENT); zip.file("word/styles.xml", STYLES); zip.file("word/settings.xml", SETTINGS); zip.file("word/header1.xml", HEADER); zip.file("word/footer1.xml", FOOTER); zip.file("word/_rels/document.xml.rels", DOCUMENT_RELS); zip.file("word/_rels/header1.xml.rels", HEADER_RELS); zip.file("word/media/image1.png", Buffer.from(TINY_PNG, "base64")); zip.file("word/media/image2.png", Buffer.from(TINY_PNG, "base64")); return zip.generateAsync({ type: "nodebuffer", compression: "DEFLATE" }); }