This commit is contained in:
Your Name committed 2026-07-24 20:08:21 -04:00
1 parent ac08f4490b
commit f8da2cceaf
8 files changed
+427 -2

No files matched your search

+25
View File
@@ -23,6 +23,9 @@ const websiteBlockTypes = [
"ARTICLE_FACTS",
"ARTICLE_VIDEO",
"ARTICLE_REFERENCES",
"ARTICLE_TABLE",
"ARTICLE_DOWNLOAD",
"ARTICLE_CTA",
"SCENT_NOTES_BREAKDOWN",
"QUOTE_CALLOUT",
"PRODUCT_CAROUSEL",
@@ -105,6 +108,28 @@ describe("Page Builder block contracts", () => {
expect(result.validationIssues.some((issue) => issue.path === "videoUrl")).toBe(true);
});
test("ARTICLE_TABLE requires every row to match the column count", () => {
const result = validatePayloadAgainstMetadata("ARTICLE_TABLE", {
columns: [{ th: "A" }, { th: "B" }],
rows: [{ label: { th: "Row" }, cells: [{ th: "Only one" }] }],
});
expect(result.valid).toBe(false);
expect(result.validationIssues.some((issue) => issue.path === "rows.0.cells")).toBe(true);
});
test("ARTICLE_CTA requires secondaryLink with secondaryText", () => {
const result = validatePayloadAgainstMetadata("ARTICLE_CTA", {
title: { th: "ติดต่อเรา" },
primaryText: { th: "สอบถาม" },
primaryLink: "/contact",
secondaryText: { th: "สินค้า" },
});
expect(result.valid).toBe(false);
expect(result.validationIssues.some((issue) => issue.path === "secondaryLink")).toBe(true);
});
test("create_page_with_section rejects invalid payloads without calling backend", async () => {
let postCalls = 0;
const api = {