The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 45 lines 1.68 KB
Raw
1 import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2 import * as Cause from "effect/Cause";
3 import { AsyncResult } from "effect/reactivity";
4 import { expect, it } from "vite-plus/test";
5 import { page } from "vite-plus/test/browser";
6
7 import { AppAtomRegistryProvider, appAtomRegistry } from "~/rpc/atomRegistry";
8 import { vcsActionManager } from "~/state/vcs";
9 import { act, render } from "../../test/render";
10 import { PullRequestThreadDialog } from "./PullRequestThreadDialog";
11
12 it("keeps another caller's checkout failure out of the dialog", async () => {
13 const target = { environmentId: EnvironmentId.make("checkout-error-test"), cwd: "/repo" };
14 const failure = AsyncResult.failure(Cause.fail(new Error("Pull request #42 has local changes.")));
15 const reply = Promise.withResolvers<typeof failure>();
16
17 await using _screen = await render(
18 <AppAtomRegistryProvider>
19 <PullRequestThreadDialog
20 {...target}
21 open
22 initialReference={null}
23 threadId={ThreadId.make("checkout-error-test")}
24 onOpenChange={() => {}}
25 onPrepared={() => {}}
26 />
27 </AppAtomRegistryProvider>,
28 );
29
30 const dialog = page.getByRole("dialog");
31 const cancel = dialog.getByRole("button", { name: "Cancel" });
32 const checkout = vcsActionManager.track(
33 appAtomRegistry,
34 target,
35 { operation: "prepare_pull_request_thread", label: "Preparing pull request thread" },
36 () => reply.promise,
37 );
38 await expect.element(cancel).toBeDisabled();
39 await act(async () => {
40 reply.resolve(failure);
41 await checkout;
42 });
43 await expect.element(cancel).toBeEnabled();
44 expect(dialog.getByText(/Failed to prepare .* request thread\./).query()).toBeNull();
45 });