Skip to content

Commit e313990

Browse files
author
Asif Ansari
committed
test(e2e): add a package smoke suite that installs the packed tarball
scripts/smoke.mjs builds and packs the library, installs the tarball into strict-TypeScript React 19 and React 18 consumer apps (e2e/fixtures), builds them with skipLibCheck off and runs Playwright Test in Chromium, Firefox and WebKit against vite preview. Scenarios cover sorting, quick filter, selection, pagination, a 50k-row grid filling a flex shell without a height prop, grouping with aggregation and CSV/XLSX/PDF downloads, editors, pinning, column groups, colSpan, detail panels and the dark theme. Any console error or warning fails a test. Fixtures are excluded from the root lint, typecheck and Vitest runs; e2e specs get their own tsconfig in npm run typecheck.
1 parent 4d126a9 commit e313990

41 files changed

Lines changed: 7587 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ __screenshots__/
3737

3838
# Vitest browser-mode attachments
3939
.vitest-attachments/
40+
41+
# Package smoke suite (npm run test:smoke)
42+
.pack/
43+
e2e/fixtures/*/node_modules
44+
e2e/fixtures/*/dist
45+
test-results/
46+
playwright-report/

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55

66
---
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
12+
- **Boolean editor in Safari** — clicking the edit checkbox closed the editor without toggling the value. Safari does not focus a checkbox on click, so mousedown moved focus to the cell and the blur committed the unchanged value before the click arrived. The checkbox now keeps focus on mousedown. Found by the new package smoke suite (WebKit).
13+
14+
### Internal
15+
16+
- **Package smoke suite** (`npm run test:smoke`) — packs the library and installs the tarball into strict-TypeScript React 19 and React 18 apps (`e2e/fixtures/`), builds them and runs Playwright Test in Chromium, Firefox and WebKit: rendering, sorting, quick filter, selection, pagination, a 50,000-row grid filling a flex app shell without a `height` prop, row grouping with aggregation, CSV / XLSX / PDF downloads, editors, pinning, column groups, detail panels and the dark theme. Runs in the new `ci.yml` workflow (pull requests), before `npm publish`, and weekly against the newest dependency versions. See `docs/contributing/testing.md`.
17+
818
## [3.2.0] — 2026-09-29
919

1020
### Added

‎CLAUDE.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Full doc: `docs/architecture/grid-row-meta.md`
123123
- 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
124124
- 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`
125125
- 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
126+
- **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`)
127+
- Smoke suite: `scripts/smoke.mjs` builds + packs to `.pack/`, `npm ci`s each fixture in `e2e/fixtures/{react19,react18}` 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. Fixtures are outside root lint/typecheck/vitest; their lockfiles must not carry `integrity` for the tarball entry. Guide: `docs/contributing/testing.md`
126128
- 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
127129

128130
---

‎README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,18 @@ Most React grids gatekeep essential features like **Row Grouping**, **Excel Expo
547547

548548
---
549549

550+
## 🧪 Testing (contributors)
551+
552+
```bash
553+
npm test # unit tests (jsdom)
554+
npm run test:browser # real Chromium, Firefox and WebKit
555+
npm run test:smoke # pack the library, install it into React 18/19 apps, run Playwright
556+
```
557+
558+
Which layer to use, and how the package smoke suite works: [docs/contributing/testing.md](https://github.com/OpenCoreStack/OpenGridX/blob/main/docs/contributing/testing.md).
559+
560+
---
561+
550562
## 📝 License
551563

552564
MIT © 2026 Open Core Stack

‎docs/contributing/testing.md‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Testing
2+
3+
Three layers, from fastest to closest to a real consumer.
4+
5+
| Command | What runs | Where the tests live |
6+
| :--- | :--- | :--- |
7+
| `npm test` | Vitest unit tests in jsdom | `lib/**/*.test.ts(x)` |
8+
| `npm run test:browser` | Vitest browser mode in real Chromium, Firefox and WebKit | `lib/**/*.browser.test.ts(x)` |
9+
| `npm run test:smoke` | Package smoke suite: Playwright Test against apps that installed the packed tarball | `e2e/` |
10+
11+
Other gates: `npm run lint`, `npm run typecheck` (lib, tests, demo, e2e), `npm run build:lib` (also checks that React stays external).
12+
13+
One-time setup for the browser and smoke suites:
14+
15+
```bash
16+
npx playwright install chromium firefox webkit
17+
```
18+
19+
## Which one do I write?
20+
21+
- **Render `<DataGrid>` with props and assert on it → Vitest.** Pure logic and hooks in `*.test.ts(x)`; anything that needs layout, `ResizeObserver`, scrolling or focus in `*.browser.test.tsx`.
22+
- **Needs the built package, a real app, a dev/preview server or a file download → e2e smoke.** Examples: the published `.d.ts` compiles in a strict consumer, the bundle works under React 18, the stylesheet sizes the grid inside an app shell, optional peers (`exceljs`, `jspdf`) load from the consumer's `node_modules`.
23+
24+
Vitest tests import `lib/` source directly, so they cannot catch packaging mistakes (bundled `react/jsx-runtime`, a missing CSS rule in `dist/`, broken `exports`). That is what the smoke suite is for; keep it small.
25+
26+
## The package smoke suite
27+
28+
`npm run test:smoke` (`scripts/smoke.mjs`):
29+
30+
1. `npm run build:lib`, then `npm pack` into `.pack/opencorestack-opengridx.tgz`.
31+
2. For each fixture in `e2e/fixtures/` (`react19`, `react18`): `npm ci` from its committed lockfile (skipped while the lockfile is unchanged), then unpack the fresh tarball into its `node_modules`.
32+
3. Build each fixture: `tsc` in strict mode with `skipLibCheck: false` against the shipped types, then `vite build`. The build is itself a typing test.
33+
4. `playwright test` (`e2e/playwright.config.ts`): Chromium, Firefox and WebKit against `vite preview` of each fixture (ports 4319 and 4318).
34+
35+
Scenarios are selected with `?scenario=`: `basic`, `flex`, `grouping`, `editing` (both fixtures), `pinned`, `dark` (React 19 only). Every test fails on any console error or warning.
36+
37+
Useful variants:
38+
39+
```bash
40+
npm run test:smoke -- --skip-lib # reuse dist/ from a previous build:lib
41+
npm run test:smoke -- --skip-tests # pack, install and build the fixtures only
42+
npm run test:smoke -- -- --project=chromium-react18 # pass arguments to playwright test
43+
npx playwright test --config e2e/playwright.config.ts # rerun tests against the current fixture builds
44+
npx playwright show-report playwright-report # HTML report, traces of failed tests
45+
```
46+
47+
`--fresh` ignores the fixture lockfiles and installs the newest versions in range (used by the weekly workflow).
48+
49+
### Fixtures
50+
51+
The fixtures are separate npm projects: they are not part of the root lint, typecheck or Vitest runs and install into their own `node_modules`. When you change a fixture's dependencies, run `npm install` in it and then delete the `integrity` field from the `node_modules/@opencorestack/opengridx` entry of its `package-lock.json` (the tarball changes on every build; the script refuses a lockfile that pins it).
52+
53+
## CI
54+
55+
- `.github/workflows/ci.yml` (pull requests and pushes to branches other than `main`): lint, typecheck, unit, browser tests, `build:lib`, smoke suite. Playwright reports and traces are uploaded when a step fails.
56+
- `npm-publish.yml` runs the smoke suite after `build:lib` and before `npm publish`.
57+
- `nightly.yml` runs weekly: all Vitest projects and the smoke suite with `--fresh`.

‎e2e/fixtures/react18/index.html‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>OpenGridX smoke</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/main.tsx"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)