diff --git a/src/__tests__/table-scroll-container-guard.test.ts b/src/__tests__/table-scroll-container-guard.test.ts new file mode 100644 index 000000000..f5470e2da --- /dev/null +++ b/src/__tests__/table-scroll-container-guard.test.ts @@ -0,0 +1,66 @@ +/** + * A sideways-scrolling table wrapper is a positioned box. + * + * Screen-reader text (`sr-only`) is absolutely positioned. Inside a scroll + * container that is not positioned, its containing block is an ancestor + * outside the container, so it escapes the container's clipping, and a cell + * panned past the phone's edge widens the whole page: the admin login + * overview scrolled sideways at 390 px once its IP button gained screen-reader + * text. Every `overflow-x-auto` wrapper around a table therefore carries + * `relative`, which makes it the containing block of what it scrolls. + */ +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; + +import { readSourceText, walkSourceFiles } from "./helpers/source-files"; + +const SRC = join(process.cwd(), "src"); + +/** `file:line` of each table wrapper that scrolls without being positioned. */ +function offenders(rel: string, text: string): string[] { + if (!text.includes("