Skip to content

Commit ebd8545

Browse files
committed
ci: add docs hydration smoke test + prod uptime monitor
A hydration crash white-screens the docs while the SSR'd HTML still returns 200 (regressed by #177), so it slips past CI and any HTTP probe; catching it needs a browser that runs the page and watches for the throw. Kept in its own Playwright config so it does not disturb the library's file-input/DnD e2e. Assisted-by: Claude:claude-opus-4-8
1 parent db0b8d9 commit ebd8545

5 files changed

Lines changed: 149 additions & 1 deletion

File tree

‎.github/workflows/docs-monitor.yml‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Docs uptime monitor
2+
3+
# Runs the same browser smoke test against the LIVE docs site on a schedule, so a
4+
# broken production deploy (e.g. a dependency resolved differently on the host) is
5+
# caught even when no PR triggered it. A failed run notifies repo admins via GitHub's
6+
# default scheduled-workflow-failure email, and opens/updates an issue.
7+
on:
8+
schedule:
9+
- cron: "0 */6 * * *" # every 6 hours
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
issues: write
15+
16+
jobs:
17+
monitor:
18+
name: Smoke-test live docs site
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v7
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version: 24
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Install Playwright Chromium
34+
run: npx playwright install --with-deps chromium
35+
36+
# DOCS_BASE_URL is the origin; the smoke test's routes carry the /file-selector basePath.
37+
- name: Smoke-test the live docs site
38+
run: npx playwright test -c playwright.docs.config.ts
39+
env:
40+
DOCS_BASE_URL: https://react-dropzone.github.io
41+
42+
- name: Open an issue if the live site is down
43+
if: failure()
44+
uses: actions/github-script@v7
45+
with:
46+
script: |
47+
const title = "Docs site smoke test failing";
48+
const body = `The scheduled docs smoke test failed against https://react-dropzone.github.io/file-selector/.\n\nRun: ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
49+
const existing = await github.rest.issues.listForRepo({
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
state: "open",
53+
labels: "docs-monitor"
54+
});
55+
if (existing.data.length === 0) {
56+
await github.rest.issues.create({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
title,
60+
body,
61+
labels: ["docs-monitor"]
62+
});
63+
}

‎.github/workflows/test.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,25 @@ jobs:
114114

115115
- name: Run e2e tests
116116
run: npm run test:e2e
117+
118+
docs-e2e:
119+
name: Docs smoke test (browser)
120+
runs-on: ubuntu-latest
121+
122+
steps:
123+
- name: Checkout repository
124+
uses: actions/checkout@v7
125+
126+
- name: Setup Node.js
127+
uses: actions/setup-node@v6
128+
with:
129+
node-version: 24
130+
131+
- name: Install dependencies
132+
run: npm ci
133+
134+
- name: Install Playwright Chromium
135+
run: npx playwright install --with-deps chromium
136+
137+
- name: Build docs and smoke-test hydration
138+
run: npm run test:docs:e2e

‎e2e-docs/docs-smoke.e2e.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {expect, test} from "@playwright/test";
2+
3+
// Routes (carrying the /file-selector basePath) that must survive client-side hydration, not
4+
// merely return 200 HTML. A dependency bump can white-screen these while the SSR'd markup still
5+
// looks fine to a plain HTTP probe: waku beta.9 dropped the router `unstable_events` API that
6+
// vocs' ScrollRestoration calls `.on()` on, throwing during hydration and blanking the page.
7+
const routes = ["/file-selector/", "/file-selector/getting-started", "/file-selector/api"];
8+
9+
for (const route of routes) {
10+
test(`docs page hydrates without errors: ${route}`, async ({page}) => {
11+
const errors: string[] = [];
12+
// Uncaught exceptions thrown during hydration - the failure mode above.
13+
page.on("pageerror", err => errors.push(`pageerror: ${err.message}`));
14+
15+
await page.goto(route, {waitUntil: "networkidle"});
16+
17+
// Primary, precise signal: no uncaught exception escaped during hydration.
18+
expect(errors, `unexpected errors on ${route}:\n${errors.join("\n")}`).toEqual([]);
19+
20+
// Secondary blank-screen guard: the app unmounts to an empty page when hydration throws,
21+
// so the main content region must exist and be non-empty afterwards.
22+
const content = page.locator("#vocs-content");
23+
await expect(content).toBeVisible();
24+
await expect(content).not.toBeEmpty();
25+
});
26+
}

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@
6868
"size": "size-limit",
6969
"docs:dev": "vocs dev",
7070
"docs:build": "vocs build",
71-
"docs:preview": "vocs preview"
71+
"docs:preview": "vocs preview",
72+
"pretest:docs:e2e": "npm run docs:build",
73+
"test:docs:e2e": "playwright test -c playwright.docs.config.ts"
7274
},
7375
"devDependencies": {
7476
"@playwright/test": "^1.62.1",

‎playwright.docs.config.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {defineConfig} from "@playwright/test";
2+
3+
// Smoke-tests the docs site in real Chromium so a hydration crash (blank page) fails CI
4+
// instead of shipping silently - the SSR'd HTML still returns 200, so a plain HTTP probe
5+
// cannot see it. Kept separate from playwright.config.ts (the library's file-input and
6+
// drag-and-drop e2e) because it needs its own web server and base URL.
7+
//
8+
// Modes:
9+
// - PR gate / local: build the docs (pretest:docs:e2e) and serve site/ via `vocs preview`.
10+
// - Scheduled prod monitor: set DOCS_BASE_URL to the live origin; no build/preview.
11+
// The docs are served under the `/file-selector` basePath (a GitHub Pages project site), so
12+
// the routes carry that prefix and DOCS_BASE_URL is just the origin.
13+
const PORT = 4321;
14+
const baseURL = process.env.DOCS_BASE_URL ?? `http://localhost:${PORT}`;
15+
16+
export default defineConfig({
17+
testDir: "./e2e-docs",
18+
testMatch: "**/*.e2e.ts",
19+
fullyParallel: true,
20+
forbidOnly: !!process.env.CI,
21+
reporter: "list",
22+
use: {
23+
baseURL,
24+
browserName: "chromium",
25+
headless: true
26+
},
27+
webServer: process.env.DOCS_BASE_URL
28+
? undefined
29+
: {
30+
command: `PORT=${PORT} npm run docs:preview`,
31+
url: `http://localhost:${PORT}/file-selector/`,
32+
reuseExistingServer: !process.env.CI,
33+
timeout: 120000
34+
}
35+
});

0 commit comments

Comments
 (0)