import assert from "node:assert/strict"; import { dirname, join } from "node:path"; import { test } from "node:test"; import { fileURLToPath } from "node:url"; import * as ejs from "ejs"; const field = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "views", "partials", "field.ejs"); const render = (data: Record = {}): Promise => ejs.renderFile(field, data); const flat = (s: string): string => s.replace(/>\s+<").replace(/\s+/g, " ").trim(); test("field renders label, icon input, hint, inline link/optional, and a server-driven error", async () => { // Error field: aria-invalid + aria-describedby wiring, icon, error markup with raw HTML. const errored = flat(await render({ id: "reg-email", name: "email", label: "Email", type: "email", autocomplete: "email", placeholder: "you@company.com", required: true, icon: "i-mail", error: { html: 'Already used. Sign in.' }, })); assert.match(errored, /