test: the side panel's focus step is held in its commit; the MenuCheck contract counts chosen roles

This commit is contained in:
2026-09-27 21:56:24 +02:00
parent 25f2d9d0e4
commit 3a9ea9e330
2 changed files with 19 additions and 4 deletions
@@ -7,6 +7,17 @@ const sources = () =>
.filter((f) => f.endsWith(".tsx") && !f.includes(".test."))
.map((f) => ({ f, src: readFileSync(new URL(f.replace(/\\/g, "/"), root), "utf8") }));
/** Checkable menu rows a file renders: a literal `role="menuitemradio"`, and a role CHOSEN by an
* expression that can come out checkable — FilterSelect's and ActionMenu's rows, every filter select
* and checkable action menu in the app, which a literal-only count skipped (round 3). */
function checkableRoles(src: string): number {
const literal = (src.match(/role="menuitem(?:radio|checkbox)"/g) ?? []).length;
const chosen = [...src.matchAll(/role=\{([^{}]*)\}/g)].filter(([, e]) =>
/"menuitem(?:radio|checkbox)"/.test(e!),
).length;
return literal + chosen;
}
// E28 review L2: `ui/MenuCheck` is the ONE drawn check box of a checkable row (S3e3b replaced seven
// hand-drawn copies), yet FilterSelect and Combobox still painted their own — a 14px box beside the
// menus' 16px one. The filled-box paint is the tell: it may live in MenuCheck only.
@@ -25,7 +36,7 @@ describe("the drawn check box", () => {
it("marks every checkable menu row, with no tick of its own beside it", () => {
const offenders = sources()
.filter(({ src }) => {
const checkable = (src.match(/role="menuitem(?:radio|checkbox)"/g) ?? []).length;
const checkable = checkableRoles(src);
const drawn = (src.match(/<MenuCheck\b/g) ?? []).length;
return checkable > drawn || (checkable > 0 && /<Check\b/.test(src));
})