From 7582889ce67721de59a22a52e94e27f1473022d6 Mon Sep 17 00:00:00 2001 From: Santino Fuentes Date: Sat, 28 Nov 2026 10:30:33 -0600 Subject: [PATCH] test(mobile): scan nested route folders and top-level tsx screens for a11y (#30) Signed-off-by: Santino Fuentes --- apps/mobile/src/a11y-scan.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/mobile/src/a11y-scan.test.ts b/apps/mobile/src/a11y-scan.test.ts index 941d661..24e5f26 100644 --- a/apps/mobile/src/a11y-scan.test.ts +++ b/apps/mobile/src/a11y-scan.test.ts @@ -9,7 +9,9 @@ import { contrast, stripComments, unlabelledControls } from "./a11y-scan.ts"; import { palettes } from "./theme.ts"; const SRC = new URL(".", import.meta.url).pathname; -const files = ["app", "components"].flatMap((dir) => readdirSync(join(SRC, dir)).filter((f) => f.endsWith(".tsx")).map((f) => join(dir, f))).concat(["app-lock.tsx"]); +const files = ["app", "components"] + .flatMap((dir) => readdirSync(join(SRC, dir), { recursive: true }).map(String).filter((f) => f.endsWith(".tsx")).map((f) => join(dir, f))) + .concat(readdirSync(SRC).filter((f) => f.endsWith(".tsx"))); test("the scanner flags a Pressable without a role or a label", () => { const src = ` go("/x")} style={s}>\n{t("a.b")}`; @@ -36,6 +38,12 @@ test("every control on every screen has a role and a label from copy", () => { assert.deepEqual(found, []); }); +test("the scan includes nested route folders and top-level tsx screens in src", () => { + assert.ok(files.includes(join("app", "oauth", "mcp.tsx"))); + assert.ok(files.includes(join("app", "oauth", "microsoft.tsx"))); + assert.ok(files.includes("app-lock.tsx")); +}); + test("contrast is computed as WCAG defines it", () => { assert.equal(Math.round(contrast("#000000", "#FFFFFF") * 10) / 10, 21); assert.equal(contrast("#777777", "#777777"), 1);