refactor(create): DRY rule export media + TextBlock row view

This commit is contained in:
adilallo
2026-05-08 21:40:43 -06:00
parent 89fd5f3ade
commit 4595e2648a
4 changed files with 112 additions and 58 deletions
+39
View File
@@ -95,6 +95,45 @@ describe("ruleExport", () => {
expect(csv).toContain(",Title,,My Rule");
});
it("sectionsToMarkdown, sectionsToCsv, and printable HTML include imageUrl and fileUrl blocks", () => {
const sections: CommunityRuleSection[] = [
{
categoryName: "Values",
entries: [
{
title: "Entry",
body: "",
blocks: [
{
label: "Photo",
body: "Caption",
imageUrl: "https://cdn.example.com/pic.jpg",
},
{
label: "Handbook",
body: "Download",
fileUrl: "https://cdn.example.com/guidance.pdf",
},
],
},
],
},
];
const md = sectionsToMarkdown("Rule", null, sections);
expect(md).toContain("![Caption](https://cdn.example.com/pic.jpg)");
expect(md).toContain("[Download](https://cdn.example.com/guidance.pdf)");
const csv = sectionsToCsv("Rule", null, sections);
expect(csv).toContain("Caption\nhttps://cdn.example.com/pic.jpg");
expect(csv).toContain("Download\nhttps://cdn.example.com/guidance.pdf");
const html = buildPrintableRuleHtmlDocument("Rule", null, sections);
expect(html).toContain('src="https://cdn.example.com/pic.jpg"');
expect(html).toContain("Caption");
expect(html).toContain('href="https://cdn.example.com/guidance.pdf"');
expect(html).toContain("Download");
});
it("buildPrintableRuleHtmlDocument escapes HTML in user content", () => {
const sections: CommunityRuleSection[] = [
{