Skip to content

Commit 9e593a3

Browse files
committed
ci: check lib/types exports and time-limit the Playwright install
- publicApi.test.ts: every type declared in lib/types/* must be exported from lib/index.ts (GridAi*/GridAgent* from /ai), except an explicit INTERNAL_TYPES list, which must itself name existing types. - ci.yml: timeout-minutes 10 on the Playwright browser install, so a stalled download fails fast instead of holding the job for 40 minutes.
1 parent 8c80a72 commit 9e593a3

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ jobs:
6363

6464
- name: Install Playwright browsers
6565
if: steps.playwright-cache.outputs.cache-hit != 'true'
66+
# A stalled download otherwise holds the job until its 40-minute timeout (seen on PR #15).
67+
timeout-minutes: 10
6668
run: npx playwright install --with-deps chromium firefox webkit
6769

6870
- name: Install Playwright system dependencies

‎CLAUDE.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ Full doc: `docs/architecture/grid-row-meta.md`
127127
- Anything that depends on layout, `ResizeObserver`, or scrolling (virtualization, container height, drag) must be a `*.browser.test.tsx` — jsdom has no layout engine and reports a 0px viewport (the grid falls back to 600px), so such bugs are invisible there
128128
- Browser tests run in Chromium, Firefox and WebKit: `npx playwright install chromium firefox webkit` once. One engine only: `npx vitest run --project browser --browser.name=firefox`
129129
- Browser test files run one at a time (`fileParallelism: false`): several test pages open at once in one Firefox steal focus and pointer input from each other
130+
- `lib/publicApi.test.ts` fails when a type declared in `lib/types/*` is not exported from `lib/index.ts` (`GridAi*` / `GridAgent*` from `/ai`). A type that is internal on purpose goes in `INTERNAL_TYPES` with a comment
130131
- **Vitest vs Playwright Test:** render `<DataGrid>` with props and assert → Vitest (`*.test.tsx`, or `*.browser.test.tsx` for layout). Needs the built package, a real app, a dev/preview server or a file download → the e2e package smoke suite (`e2e/`, `npm run test:smoke`). Vitest aliases the package to `lib/`, so only the smoke suite catches packaging bugs (bundled `react/jsx-runtime`, missing CSS in `dist/`, `.d.ts` that fails `skipLibCheck: false`)
131132
- Smoke suite: `scripts/smoke.mjs` builds + packs to `.pack/`, `npm ci`s each fixture in `e2e/fixtures/{react19,react18,nopeers,nextjs}` and unpacks the tarball there, builds them (strict tsc + vite), then runs `e2e/smoke.spec.ts` in Chromium/Firefox/WebKit × both fixtures against `vite preview`. Scenarios via `?scenario=` (`basic`, `flex`, `grouping`, `editing`; React 19 also `pinned`, `dark`). Any console error/warning fails a test. `nopeers` is a webpack 5 app without `exceljs`/`jspdf` (`nopeers.spec.ts`, port 4321): every optional-peer `import()` must stay inside a `try` block, which webpack and Turbopack treat as optional (Vite tolerates a missing peer anyway, so the Vite fixtures cannot catch this). `nextjs` is a Next.js 16 App Router app (Turbopack, `next build` + `next start`, port 4323, `e2e/nextjs.spec.ts`): Server Component → `'use client'` grid, stylesheet in the layout, no optional peers, no aliases; its `next.config.ts` only pins `turbopack.root` to the fixture so the repo's own `exceljs` is not found. A specifier hidden in a variable (`import(name)`) builds but breaks apps that do install the peers: browsers cannot resolve bare specifiers, and Vite's lib build strips `webpackIgnore` / `@vite-ignore` comments. Fixtures are outside root lint/typecheck/vitest; their lockfiles must not carry `integrity` for the tarball entry. Guide: `docs/contributing/testing.md`
132133
- Keep browser tests engine-neutral: no CDP (`cdp()` is Chromium-only; use a Playwright-backed command such as `commands.setColorScheme` from `vitest.config.ts`), Tab-order anchors are text inputs (WebKit on macOS skips buttons on Tab), compare scroll positions with what the browser actually took (Firefox snaps them to device pixels), and wait for CSS animations to finish before measuring. Skip an engine only with `it.skipIf(server.browser === '...')` (`server` from `vitest/browser`) and a comment saying why

‎lib/publicApi.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,25 @@ function readEntryExports(program: ts.Program, file: string = LIB_INDEX): Set<st
146146
*/
147147
const AI_TYPE_NAME = /^Grid(?:Ai|Agent)[A-Z]/;
148148

149+
const TYPES_DIR = path.join(ROOT, 'lib', 'types');
150+
151+
/** Types declared in lib/types that are internal on purpose: store shapes, not part of any public signature. */
152+
const INTERNAL_TYPES = new Set([
153+
'GridInternalState',
154+
'GridPinnedColumns', // store shape of pinned columns; the prop is GridColumnPinning
155+
'GridPinnedRows', // store shape of pinned rows; the prop is GridRowPinning
156+
]);
157+
158+
/** Every name a domain file under lib/types exports, with the file that declares it. */
159+
function declaredTypeNames(program: ts.Program): Map<string, string> {
160+
const found = new Map<string, string>();
161+
for (const file of fs.readdirSync(TYPES_DIR)) {
162+
if (!file.endsWith('.ts') || file === 'index.ts' || file.includes('.test.')) continue;
163+
for (const name of readEntryExports(program, path.join(TYPES_DIR, file))) found.set(name, `lib/types/${file}`);
164+
}
165+
return found;
166+
}
167+
149168
const readDoc = (file: string) => fs.readFileSync(file, 'utf8');
150169
const componentDocs = fs.readdirSync(COMPONENT_DOCS_DIR)
151170
.filter((f) => f.endsWith('.md'))
@@ -224,6 +243,17 @@ describe('public API matches the reference docs', () => {
224243
expect(missing).toEqual([]);
225244
});
226245

246+
it('exports every type declared in lib/types from its entry point, unless it is internal', () => {
247+
const declared = declaredTypeNames(program);
248+
expect(declared.size).toBeGreaterThan(50);
249+
const missing = [...declared]
250+
.filter(([name]) => !INTERNAL_TYPES.has(name))
251+
.filter(([name]) => !(AI_TYPE_NAME.test(name) ? aiExports : rootExports).has(name))
252+
.map(([name, file]) => `${name} (${file})`);
253+
expect(missing).toEqual([]);
254+
expect([...INTERNAL_TYPES].filter((name) => !declared.has(name))).toEqual([]);
255+
});
256+
227257
it('exports every name the docs import from the ai entry point, and the root does not', () => {
228258
const imports = documentedImports('/ai');
229259
expect(imports.size).toBeGreaterThan(1);

0 commit comments

Comments
 (0)