Skip to content
Source
Sign inSign up
pingdotgg/t3code

test(web): every React test runs in a real browser #20944

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/20944/headmerged by juliusmarminge View on GitHub

Showing 13 changed files with 133 additions and 1 deletion (loading 10).

x
0 of 13 viewed, 13 left
1 addition and 1 deletionapps/web/src/components/chat/WorkLog.browser.test.tsxModified
View file
@@ -3,7 +3,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
import { WorkLogDetails } from "./WorkLog";
​
-// jsdom has no layout, so the scroller's geometry is simulated: a 384px
+// The scroller's geometry is simulated so the test controls it: a 384px
// viewport over content whose height the test grows like a streamed trace.
const VIEWPORT = 384;
let contentHeight = 0;
132 additions and 0 deletionsapps/web/src/components/BranchToolbar.panel.browser.test.tsxAdded
View file
@@ -0,0 +1,132 @@
+import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
+import { act, type ComponentProps } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
+import { page, userEvent } from "vite-plus/test/browser";
+​
+import "~/index.css";
+​
+const state = vi.hoisted(() => ({
+ worktreePath: "/tmp/worktree" as string | null,
+ showContextMenu: vi.fn(),
+ writeTextToClipboard: vi.fn(),
+}));
+​
+vi.mock(import("../localApi"), async (original) => ({
+ ...(await original()),
+ readLocalApi: (() => ({ contextMenu: { show: state.showContextMenu } })) as never,