Open History to see the last commit
1import { EnvironmentId, ThreadId } from "@t3tools/contracts";
2import { expect, it } from "vite-plus/test";
3
4import { appAtomRegistry } from "~/rpc/atomRegistry";
5import {
6 closeThreadWorkspaceDialog,
7 openThreadWorkspaceDialog,
8 threadWorkspaceDialogAtom,
9} from "./threadWorkspace";
10
11it("closes the workspace dialog only while it still shows the request that asks", () => {
12 appAtomRegistry.reset();
13 const thread = {
14 environmentId: EnvironmentId.make("environment"),
15 threadId: ThreadId.make("thread"),
16 };
17 openThreadWorkspaceDialog(thread, "project");
18 const first = appAtomRegistry.get(threadWorkspaceDialogAtom);
19 openThreadWorkspaceDialog(thread, "project");
20 const second = appAtomRegistry.get(threadWorkspaceDialogAtom);
21 if (first === null || second === null) throw new Error("dialog did not open");
22
23 closeThreadWorkspaceDialog(first);
24 expect(appAtomRegistry.get(threadWorkspaceDialogAtom)).toBe(second);
25
26 closeThreadWorkspaceDialog(second);
27 expect(appAtomRegistry.get(threadWorkspaceDialogAtom)).toBeNull();
28 appAtomRegistry.reset();
29});