Skip to content

Commit 144aae4

Browse files
test(web): React tests run compiled in a real browser (#20797)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 73d70a4 commit 144aae4

21 files changed

Lines changed: 538 additions & 200 deletions

‎.github/workflows/ci.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,31 @@ jobs:
268268
- name: Setup Vite+
269269
uses: ./.github/actions/setup-ci-deps
270270

271+
# The browser project runs React tests in headless Chromium. Same cache key as
272+
# test_server, so both jobs share one downloaded browser.
273+
- name: Resolve Playwright version
274+
id: playwright_version
275+
run: echo "version=$(node -p "require('./apps/web/node_modules/playwright/package.json').version")" >> "$GITHUB_OUTPUT"
276+
277+
- name: Cache Chromium
278+
id: chromium_cache
279+
uses: actions/cache@v6
280+
with:
281+
path: ~/.cache/ms-playwright
282+
key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}
283+
284+
- name: Install Chromium for web browser tests
285+
if: steps.chromium_cache.outputs.cache-hit != 'true'
286+
run: node apps/web/node_modules/playwright/cli.js install --only-shell chromium
287+
288+
- name: Install missing Chromium system dependencies
289+
run: |
290+
browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
291+
test -n "$browser"
292+
if ldd "$browser" | grep '=> not found'; then
293+
node apps/web/node_modules/playwright/cli.js install-deps chromium
294+
fi
295+
271296
- name: Test
272297
run: vp run --filter @t3tools/web test
273298

‎apps/web/package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build": "vp build",
1010
"preview": "vp preview",
1111
"typecheck": "tsc-rs --noEmit",
12-
"test": "vp test run --passWithNoTests --project unit"
12+
"test": "vp test run --passWithNoTests --project unit --project browser"
1313
},
1414
"dependencies": {
1515
"@base-ui/react": "^1.4.1",
@@ -86,9 +86,11 @@
8686
"@types/react-test-renderer": "19.1.0",
8787
"@vercel/config": "^0.3.0",
8888
"@vitejs/plugin-react": "^6.1.2",
89+
"@vitest/browser-playwright": "5.0.1",
8990
"compression": "^1.8.2",
9091
"jsdom": "^30.0.1",
9192
"oxc-transform-react": "~0.152.0",
93+
"playwright": "1.60.0",
9294
"react-test-renderer": "19.2.6",
9395
"tailwindcss": "^4.0.0",
9496
"unified": "catalog:",

apps/web/src/components/ComposerPromptEditorTiptap.navigation.test.tsx renamed to apps/web/src/components/ComposerPromptEditorTiptap.navigation.browser.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @vitest-environment jsdom
2-
31
import type { Editor } from "@tiptap/core";
42
import { TextSelection } from "@tiptap/pm/state";
53
import { act, createRef } from "react";

apps/web/src/components/RightPanelTabs.keyboard.test.tsx renamed to apps/web/src/components/RightPanelTabs.keyboard.browser.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @vitest-environment jsdom
2-
31
import { act, type ComponentProps } from "react";
42
import { createRoot, type Root } from "react-dom/client";
53
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";

apps/web/src/components/chat/ChatCanvas.test.tsx renamed to apps/web/src/components/chat/ChatCanvas.browser.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @vitest-environment jsdom
2-
31
import { act, useLayoutEffect } from "react";
42
import { createRoot, type Root } from "react-dom/client";
53
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";

apps/web/src/components/chat/ThreadDetailsControl.test.tsx renamed to apps/web/src/components/chat/ThreadDetailsControl.browser.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @vitest-environment jsdom
2-
31
import { act } from "react";
42
import { createRoot } from "react-dom/client";
53
import { expect, it, vi } from "vite-plus/test";

apps/web/src/components/chat/WorkLog.test.tsx renamed to apps/web/src/components/chat/WorkLog.browser.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @vitest-environment jsdom
2-
31
import { act } from "react";
42
import { createRoot, type Root } from "react-dom/client";
53
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";

apps/web/src/components/chat/threadFindHighlights.test.tsx renamed to apps/web/src/components/chat/threadFindHighlights.browser.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @vitest-environment jsdom
2-
31
import { act } from "react";
42
import { createRoot, type Root } from "react-dom/client";
53
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";

apps/web/src/components/chat/threadFindPosition.test.ts renamed to apps/web/src/components/chat/threadFindPosition.browser.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @vitest-environment jsdom
21
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
32
import { readThreadFindPosition } from "./threadFindPosition";
43

apps/web/src/components/chat/timelineMinimapWheel.test.ts renamed to apps/web/src/components/chat/timelineMinimapWheel.browser.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @vitest-environment jsdom
2-
31
import { describe, expect, it, vi } from "vite-plus/test";
42

53
import { forwardWheelToTimeline } from "./timelineMinimapWheel";

0 commit comments

Comments
 (0)