import { describe, expect, it } from "bun:test"; import { createElement } from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { Controls } from "./controls"; import { AuthoredContent, callouts } from "./authored-content"; import { Foundations } from "./foundations"; import { AUDIT_INVENTORY } from "./inventory"; import { Surfaces } from "./surfaces"; describe("design audit specimens", () => { it("renders every foundation family with a visible label", () => { let markup = renderToStaticMarkup(createElement(Foundations)); for (let id of ["colours", "typography", "spacing", "radii", "shadows", "icons"]) { expect(markup).toContain(`data-audit-item="${id}"`); } expect(markup).toContain("Consolidated exact duplicate"); expect(markup).toContain("Strong resting"); for ( let measurement of [ "13px / 20px line-height", "15px / 22px line-height", "17px / 27px line-height", "24px / 30px line-height", "32px / 38px line-height", ] ) expect(markup).toContain(measurement); }); it("renders controls with their native accessibility states", () => { let markup = renderToStaticMarkup(createElement(Controls)); for ( let id of [ "buttons", "icon-buttons", "links", "fields", "selections", "tabs", "menus", "dropdowns", ] ) { expect(markup).toContain(`data-audit-item="${id}"`); } expect(markup).toContain('aria-label="Add document"'); expect(markup).toContain("disabled"); expect(markup).toContain('aria-selected="true"'); expect(markup).toContain('role="menu"'); }); it("renders every application surface and its meaningful states", () => { let markup = renderToStaticMarkup(createElement(Surfaces)); for (let item of AUDIT_INVENTORY.find(group => group.id === "surfaces")!.items) { expect(markup).toContain(`data-audit-item="${item.id}"`); } expect(markup).toContain('role="dialog"'); expect(markup).toContain('aria-current="page"'); expect(markup).toContain('aria-label="Compact workspace view"'); expect(markup).toContain('data-chat-entry="true"'); expect(markup).toContain("Avatar image loading"); expect(markup).toContain("Editing this question"); expect(markup).toContain('role="alert"'); }); it("renders every authored-content family through the static editor or record card", () => { let markup = renderToStaticMarkup(createElement(AuthoredContent)); for (let item of AUDIT_INVENTORY.find(group => group.id === "authored-content")!.items) { expect(markup).toContain(`data-audit-item="${item.id}"`); } expect(markup).toContain('role="document"'); for (let type of ["note", "tip", "important", "warning", "danger"]) { expect(callouts).toContain(`type="${type}"`); } expect(markup).toContain("Research question"); expect(markup).toContain("Research ready"); }); });