Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,31 @@ jobs:
- name: Setup Vite+
uses: ./.github/actions/setup-ci-deps

# The browser project runs React tests in headless Chromium. Same cache key as
# test_server, so both jobs share one downloaded browser.
- name: Resolve Playwright version
id: playwright_version
run: echo "version=$(node -p "require('./apps/web/node_modules/playwright/package.json').version")" >> "$GITHUB_OUTPUT"

- name: Cache Chromium
id: chromium_cache
uses: actions/cache@v6
with:
path: ~/.cache/ms-playwright
key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}

- name: Install Chromium for web browser tests
if: steps.chromium_cache.outputs.cache-hit != 'true'
run: node apps/web/node_modules/playwright/cli.js install --only-shell chromium

- name: Install missing Chromium system dependencies
run: |
browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
test -n "$browser"
if ldd "$browser" | grep '=> not found'; then
node apps/web/node_modules/playwright/cli.js install-deps chromium
fi
- name: Test
run: vp run --filter @t3tools/web test

Expand Down
4 changes: 3 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "vp build",
"preview": "vp preview",
"typecheck": "tsc-rs --noEmit",
"test": "vp test run --passWithNoTests --project unit"
"test": "vp test run --passWithNoTests --project unit --project browser"
},
"dependencies": {
"@base-ui/react": "^1.4.1",
Expand Down Expand Up @@ -86,9 +86,11 @@
"@types/react-test-renderer": "19.1.0",
"@vercel/config": "^0.3.0",
"@vitejs/plugin-react": "^6.1.2",
"@vitest/browser-playwright": "5.0.1",
"compression": "^1.8.2",
"jsdom": "^30.0.1",
"oxc-transform-react": "~0.152.0",
"playwright": "1.60.0",
"react-test-renderer": "19.2.6",
"tailwindcss": "^4.0.0",
"unified": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import type { Editor } from "@tiptap/core";
import { TextSelection } from "@tiptap/pm/state";
import { act, createRef } from "react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { act, type ComponentProps } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { act, useLayoutEffect } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { act } from "react";
import { createRoot } from "react-dom/client";
import { expect, it, vi } from "vite-plus/test";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { act } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { act } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @vitest-environment jsdom
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
import { readThreadFindPosition } from "./threadFindPosition";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { describe, expect, it, vi } from "vite-plus/test";

import { forwardWheelToTimeline } from "./timelineMinimapWheel";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import type { LegendListRef } from "@legendapp/list/react";
import { act, type ComponentProps } from "react";
import { createRoot, type Root } from "react-dom/client";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @vitest-environment jsdom
import { act } from "react";
import { createRoot, type Root } from "react-dom/client";
import { EnvironmentId, ProjectId } from "@t3tools/contracts";
Expand Down Expand Up @@ -52,7 +51,10 @@ vi.mock("../../state/server", () => ({
refreshProviders: "refresh",
},
}));
vi.mock("@effect/atom-react", () => ({ useAtomValue: (value: unknown) => value }));
vi.mock("@effect/atom-react", async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useAtomValue: (value: unknown) => value,
}));
vi.mock("../../onboarding/useProjectScans", () => ({
useProjectScans: () => [
{
Expand Down
35 changes: 0 additions & 35 deletions apps/web/src/components/ui/alert-dialog.test.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions apps/web/src/components/ui/qr-code.test.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { act, useState } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { Editor } from "@tiptap/core";
import { TaskList } from "@tiptap/extension-task-list";
import { TextSelection } from "@tiptap/pm/state";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @vitest-environment jsdom
import * as Schema from "effect/Schema";
import { act, createElement, useEffect } from "react";
import { createRoot, type Root } from "react-dom/client";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { afterEach, describe, expect, it } from "vite-plus/test";

import { isEditableFocused } from "./editableFocus";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @vitest-environment jsdom

import { act, createElement } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
Expand Down
23 changes: 22 additions & 1 deletion apps/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as NodeZlib from "node:zlib";
import react from "@vitejs/plugin-react";
import { tanstackRouter } from "@tanstack/router-plugin/vite";
import compression from "compression";
import { playwright } from "vite-plus/test/browser-playwright";
import { defineProject, type TestProjectInlineConfiguration } from "vite-plus/test/config";
import "vite-plus/test/config";
import { defineConfig, type Connect, type Plugin } from "vite-plus";
Expand Down Expand Up @@ -70,12 +71,32 @@ const unitTestProject = {
test: {
name: "unit",
include: ["src/**/*.test.{ts,tsx}"],
exclude: ["src/**/*.browser.test.{ts,tsx}"],
hookTimeout: 15_000,
testTimeout: 15_000,
setupFiles: ["../../packages/shared/src/testing/longTempDir.ts"],
},
} satisfies TestProjectInlineConfiguration;

// Anything that renders React or touches the DOM is named *.browser.test.{ts,tsx} and runs
// in headless Chromium through the same plugins as the app, so it exercises compiled code.
const browserTestProject = {
extends: true,
test: {
name: "browser",
include: ["src/**/*.browser.test.{ts,tsx}"],
hookTimeout: 15_000,
testTimeout: 15_000,
browser: {
enabled: true,
headless: true,
provider: playwright(),
instances: [{ browser: "chromium" }],
screenshotFailures: false,
},
},
} satisfies TestProjectInlineConfiguration;

function resolveDevProxyTarget(
backendPort: string | undefined,
wsUrl: string | undefined,
Expand Down Expand Up @@ -248,7 +269,7 @@ export default defineConfig(() => {
sourcemap: buildSourcemap,
},
test: {
projects: [defineProject(unitTestProject)],
projects: [defineProject(unitTestProject), defineProject(browserTestProject)],
},
};
});
Loading
Loading