feat: release design system engine, studio and component contracts

This commit is contained in:
Clintchiz committed 2026-10-19 13:09:03 +05:30
1 parent ff1065fb27
commit 3943b946d6
693 files changed
+175546 -3894

No files matched your search

@@ -2,7 +2,37 @@ import { expect, test } from "bun:test";
import type { BlockDocument, BlockNode } from "@wrnexus/blocks";
import { renderEmail, importMjml } from "../src/index.ts";
const documentFor = (decorative: boolean): BlockDocument => ({ schemaVersion: 1, kind: "email", meta: { subject: "Images" }, theme: { tokens: {} }, root: { id: "root", type: "layout.email-document", version: 1, props: { width: "600" }, styles: {}, slots: { content: [{ id: "image", type: "content.image", version: 1, props: { src: "https://example.com/image.png", alt: "Accessible & descriptive", width: "320", height: "180", decorative }, styles: {}, slots: {} }] } } });
const documentFor = (decorative: boolean): BlockDocument => ({
schemaVersion: 1,
kind: "email",
meta: { subject: "Images" },
theme: { tokens: {} },
root: {
id: "root",
type: "layout.email-document",
version: 1,
props: { width: "600" },
styles: {},
slots: {
content: [
{
id: "image",
type: "content.image",
version: 1,
props: {
src: "https://example.com/image.png",
alt: "Accessible & descriptive",
width: "320",
height: "180",
decorative,
},
styles: {},
slots: {},
},
],
},
},
});
test("decorative image descriptions stay omitted across HTML text and MJML", async () => {
const rendered = await renderEmail(documentFor(true), { mjml: true });
@@ -23,7 +53,8 @@ test("meaningful image alt and explicit dimensions survive MJML round trip", asy
let id = 0;
const imported = importMjml(rendered.value.exports!.mjml!, { id: () => `n${++id}` });
if (!imported.ok) throw new Error("Import failed");
const find = (node: BlockNode): BlockNode | undefined => node.type === "content.image" ? node : Object.values(node.slots).flat().map(find).find(Boolean);
const find = (node: BlockNode): BlockNode | undefined =>
node.type === "content.image" ? node : Object.values(node.slots).flat().map(find).find(Boolean);
expect(find(imported.value.root)!.props.width).toBe("320");
expect(find(imported.value.root)!.props.height).toBe("180");
expect(find(imported.value.root)!.props.alt).toBe("Accessible & descriptive");