// The components' markup, rendered on the server the way a page renders it: what a screen reader and // a keyboard user get is in the HTML, so the accessibility basics are asserted there -- a name for // every control, a caption and scoped headers for every table, a status that says what a colour would. import { buildRegistry } from "@conusai-kit/core" import { createI18n } from "@conusai-kit/i18n" import { TransportProvider } from "@conusai-kit/ui" import { renderToStaticMarkup } from "react-dom/server" import { describe, expect, it } from "vitest" import { appModules } from "../../index.js" import type { NoteView } from "../contract/index.js" import { Attachments, attachmentLabels, createFormLabels, DeleteNote, deleteLabels, editFormLabels, listLabels, NoteForm, NoteList, sizeLabel, } from "../ui/index.js" const catalogues = buildRegistry([...appModules]).catalogues const i18n = createI18n("en", { en: { notes: catalogues.en?.notes ?? {} } }) const t = (key: string, values?: Record) => i18n.message(`notes.${key}`, values) const slugs = { org: "acme", workspace: "ws", project: "p" } const failed = "That did not work: {detail}" const inProvider = (node: React.ReactNode) => renderToStaticMarkup( undefined} describe={() => "x"}> {node} , ) const note = (over: Partial = {}): NoteView => ({ noteId: "n1", title: "Kick-off", body: "Agenda", version: 3, createdBy: "u1", createdAt: "2026-04-01T08:00:00.000Z", updatedAt: "2026-04-02T08:00:00.000Z", attachmentCount: 2, ...over, }) describe("the note list", () => { const html = renderToStaticMarkup( `/acme/ws/p/notes/${id}`} labels={listLabels(t)} formatDate={(iso) => iso.slice(0, 10)} />, ) it("is a table with a caption and a scoped header for every column", () => { expect(html).toContain("Notes") expect(html.match(//g)).toHaveLength(3) expect(html).toContain('') }) it("names each link by its note, so a list of links is not a list of the same word", () => { expect(html).toContain('aria-label="Open Kick-off"') expect(html).toContain('aria-label="Open Retro"') expect(html).toContain('href="/acme/ws/p/notes/n1"') }) it("says so in words when there is nothing to list", () => { const empty = renderToStaticMarkup( ""} labels={listLabels(t)} formatDate={() => ""} />, ) expect(empty).toBe('

No notes yet.

') }) }) describe("the note form", () => { const html = inProvider( , ) it("labels every field", () => { for (const name of ["title", "body"]) { const id = new RegExp(`<(?:input|textarea) [^>]*\\bid="([^"]+)"[^>]*\\bname="${name}"`).exec(html)?.[1] expect(id, name).toBeTruthy() expect(html).toMatch(new RegExp(`