Pin the chrome's locale carrying in unit tests; keep one carrier list
CI / full-gate (push) Successful in 2m36s

This commit is contained in:
2026-08-03 23:25:54 +02:00
parent b3df7084c4
commit 2b20497785
4 changed files with 24 additions and 7 deletions
+8
View File
@@ -52,3 +52,11 @@ test("field defaults to a bare text input, escapes a string error, and never thr
assert.match(stringErr, /<span>&lt;b&gt;Required&lt;\/b&gt;\.<\/span>/); // string error is escaped
assert.match(stringErr, /aria-describedby="x-err"/);
});
test("an inline field link carries the visitor's language", async () => {
const html = await ejs.renderFile(field, {
...ENGLISH_LOCALS, localeHref: (href: string) => `${href}?locale=sv-SE`,
id: "password", label: "Password", link: { href: "/recovery", label: "Forgot password?" }, name: "password",
});
assert.match(html, /href="\/recovery\?locale=sv-SE"/);
});
+9
View File
@@ -5,6 +5,9 @@ import { fileURLToPath } from "node:url";
import ejs from "ejs";
import { ENGLISH_LOCALS } from "../i18n/view-locals.ts";
// A localeHref that marks what it touches, so a raw href in the chrome is visible to a test.
const CARRYING = { ...ENGLISH_LOCALS, localeHref: (href: string) => `${href}?locale=sv-SE` };
const shell = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "views", "partials", "shell.ejs");
const render = (data: Record<string, unknown> = {}): Promise<string> => ejs.renderFile(shell, { ...ENGLISH_LOCALS, ...data });
@@ -107,3 +110,9 @@ test("app shell escapes text but passes slot HTML through, and renders with defa
assert.match(bare, /<aside class="sidebar"/);
assert.match(bare, /<main class="content"/);
});
test("the chrome carries the visitor's language: breadcrumb links go through localeHref", async () => {
const html = await ejs.renderFile(shell, { ...CARRYING, breadcrumbs: [{ href: "/admin/users", label: "Users" }, { label: "Ada" }], title: "Ada" });
assert.match(html, /<a href="\/admin\/users\?locale=sv-SE">Users<\/a>/);
assert.match(html, /<span>Ada<\/span>/); // the current crumb has no href to carry
});