Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

LinkPullRequestDialog.browser.test.tsx

39 lines1.2 KB

1import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2import { expect, it, vi } from "vite-plus/test";
3import { page } from "vite-plus/test/browser";
4​
5vi.mock(import("~/hooks/usePullRequestLinking"), async (original) => ({
6 ...(await original()),
7 usePullRequestLinking: (() => ({
8 mode: "multiple",
9 canLink: () => true,
10 changeLink: vi.fn(),
11 })) as never,
12}));
13vi.mock(import("~/state/entities"), async (original) => ({
14 ...(await original()),
15 useProjects: () => [],
16 useThreadShell: () => null,
17}));
18​
19import { RegistryContext } from "@effect/atom-react";
20​
21import { appAtomRegistry } from "~/rpc/atomRegistry";
22import { act, render } from "../../../test/render";
23import { LinkPullRequestDialogHost, openLinkPullRequestDialog } from "./LinkPullRequestDialog";
24​
25it("focuses the reference input when the dialog opens", async () => {
26 await using _screen = await render(
27 <RegistryContext.Provider value={appAtomRegistry}>
28 <LinkPullRequestDialogHost />
29 </RegistryContext.Provider>,
30 );
31 await act(() =>
32 openLinkPullRequestDialog({
33 environmentId: EnvironmentId.make("environment"),
34 threadId: ThreadId.make("thread"),
35 }),
36 );
37​
38 await expect.element(page.getByPlaceholder("Pull request URL or #42")).toHaveFocus();
39});