evidence-source/src/browser/view-html.test.ts
tegwick d605bf64be
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 3s
Add browser upload and viewer HTML resolution for HTML/Markdown
ingestHtmlFromFile and ingestMarkdownFromFile store session bytes with
correct content types. resolveDomViewerHtml renders sanitized HTML or
markdown paragraphs for HtmlViewerAdapter (EANCH-WP-0004).
2026-07-09 09:58:41 +02:00

23 lines
No EOL
1,004 B
TypeScript

import { describe, expect, it } from "vitest";
import { createPdfByteStore } from "./byte-store";
import { markdownSourceToViewerHtml, resolveDomViewerHtml } from "./view-html";
import { ingestHtmlFromFile } from "./upload";
const HTML = `<!DOCTYPE html><html><body><p>Hello HTML viewer</p></body></html>`;
describe("resolveDomViewerHtml", () => {
it("returns sanitized HTML for html-dom representations", async () => {
const store = createPdfByteStore();
const file = new File([HTML], "sample.html", { type: "text/html" });
const { document, representation } = await ingestHtmlFromFile(file, store);
const html = resolveDomViewerHtml(document, representation, store);
expect(html).toContain("Hello HTML viewer");
expect(html).not.toMatch(/<script/i);
});
it("renders markdown as paragraph HTML", () => {
const html = markdownSourceToViewerHtml("# Title\n\nBody paragraph.");
expect(html).toContain("<p>");
expect(html).toContain("Body paragraph.");
});
});