Skip to content

Commit afb654c

Browse files
committed
test(e2e): Vite host and Playwright harness (CL-9126)
bun run test:e2e packs the package, installs it into tests/e2e/host, typechecks the host, and runs Playwright against one route per scenario. A smoke spec covers the harness. bun test is rooted at src/ so it skips the specs. CI installs Chromium and runs the e2e suite.
1 parent a3e263e commit afb654c

15 files changed

Lines changed: 120 additions & 4 deletions

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches: [main]
66
pull_request:
7-
branches: [main]
87

98
jobs:
109
verify:
@@ -26,3 +25,5 @@ jobs:
2625
- run: bun run dep-guard
2726
- run: bun test
2827
- run: bun run build
28+
- run: bunx playwright install --with-deps chromium
29+
- run: bun run test:e2e

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ scratch/
99
build/
1010
.worktrees/
1111
.agent-state/
12+
tests/e2e/host/bun.lock
13+
test-results/
14+
playwright-report/

‎CONTRIBUTING.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ bun run build # generate → SWC → tsc → Tailwind → the contrast
2222
bun run typecheck # tsc --noEmit
2323
bun run lint # eslint .
2424
bun run dep-guard # forbidden-import checks over src/
25+
bun run test:e2e # pack, install into tests/e2e/host, run Playwright
2526
```
2627

27-
All four must be clean before a change lands. There is no CI in this repository yet, so
28-
running them locally is the only thing standing between a change and a release.
28+
`test:e2e` needs Chromium once: `bunx playwright install chromium`. Each scenario is a
29+
route in `tests/e2e/host/src/scenarios.tsx`, rendered against the packed tarball.
30+
31+
All five must be clean before a change lands; CI runs them on every pull request.
2932
`typecheck` is not negotiable and `any` is not a way past it: the escapes that exist each
3033
carry a comment explaining why the type system leaves no alternative, and a new one needs
3134
the same.

‎bun.lock‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bunfig.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
[test]
2+
# Playwright specs under tests/ also match bun's *.spec.* pattern.
3+
root = "./src"
24
preload = ["./scripts/test-dom-setup.ts"]

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"build:css": "tailwindcss -i src/styles.css -o dist/styles.css && cp src/theme.css dist/theme.css",
3636
"typecheck": "tsc --noEmit",
3737
"test": "bun test",
38+
"test:e2e": "bun pm pack --quiet --filename tests/e2e/host/react-ui.tgz && playwright test -c tests/e2e",
3839
"lint": "eslint .",
3940
"dep-guard": "node scripts/dep-guard.mjs",
4041
"contrast-test": "node scripts/contrast-test.mjs",
@@ -62,6 +63,7 @@
6263
"@eslint/js": "^9.39.1",
6364
"@happy-dom/global-registrator": "^20.11.2",
6465
"@ladle/react": "^5.1.1",
66+
"@playwright/test": "^1.63.0",
6567
"@radix-ui/react-dialog": "^1.1.15",
6668
"@radix-ui/react-dropdown-menu": "^2.1.16",
6769
"@radix-ui/react-slot": "^1.2.3",

‎tests/e2e/host/index.html‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>react-ui e2e host</title>
6+
</head>
7+
<body>
8+
<div id="root"></div>
9+
<script type="module" src="/src/main.tsx"></script>
10+
</body>
11+
</html>

‎tests/e2e/host/package.json‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "react-ui-e2e-host",
3+
"description": "Vite app that renders @corbits/react-ui scenarios for the Playwright suite",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"typecheck": "tsc --noEmit"
9+
},
10+
"dependencies": {
11+
"@corbits/react-ui": "file:./react-ui.tgz",
12+
"@radix-ui/react-slot": "1.3.3",
13+
"lucide-react": "1.48.0",
14+
"react": "19.3.0",
15+
"react-dom": "19.3.0"
16+
},
17+
"devDependencies": {
18+
"@types/react": "19.3.0",
19+
"@types/react-dom": "19.3.0",
20+
"typescript": "5.9.3",
21+
"vite": "6.4.3"
22+
}
23+
}

‎tests/e2e/host/src/main.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import "@corbits/react-ui/styles.css";
2+
3+
import { StrictMode } from "react";
4+
import { createRoot } from "react-dom/client";
5+
6+
import { scenarios } from "./scenarios.js";
7+
8+
const name = window.location.pathname.slice(1);
9+
const Scenario = scenarios[name];
10+
11+
createRoot(document.getElementById("root")!).render(
12+
<StrictMode>{Scenario ? <Scenario /> : <p>Unknown scenario: {name}</p>}</StrictMode>,
13+
);

‎tests/e2e/host/src/scenarios.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ReactNode } from "react";
2+
3+
import { Button } from "@corbits/react-ui";
4+
5+
export const scenarios: Record<string, () => ReactNode> = {
6+
smoke: () => <Button>Ready</Button>,
7+
};

0 commit comments

Comments
 (0)