Skip to content

Commit 460f478

Browse files
committed
test(web): click the parent once after the late read settles
1 parent 9e215f4 commit 460f478

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎apps/web/src/components/chat/ThreadRelationshipsControl.remote-parent.browser.test.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EnvironmentId, ThreadId, type OrchestrationV2ThreadShell } from "@t3too
22
import * as Cause from "effect/Cause";
33
import { expect, it, vi } from "vite-plus/test";
44

5-
import { render, type Screen } from "../../../test/render";
5+
import { act, render, type Screen } from "../../../test/render";
66

77
const { read, toast } = vi.hoisted(() => ({
88
read: vi.fn<(input: unknown) => Promise<unknown>>(),
@@ -114,12 +114,14 @@ it("leaves the user where they went when the parent read answers late", async ()
114114
await using screen = await renderChild(late, deleted);
115115
await parentRow(screen).click();
116116
await screen.router?.navigate({ to: "/new" });
117-
answerLate(live);
118-
// The row takes a second click only after the first one has finished.
119-
await vi.waitFor(async () => {
120-
await parentRow(screen).click();
121-
expect(read).toHaveBeenCalledTimes(2);
117+
await act(async () => {
118+
answerLate(live);
119+
await late;
122120
});
121+
expect(toast).not.toHaveBeenCalled();
122+
expect(screen.router?.latestLocation.pathname).toBe("/new");
123+
await parentRow(screen).click();
124+
await vi.waitFor(() => expect(read).toHaveBeenCalledTimes(2));
123125
await vi.waitFor(() => expect(toast).toHaveBeenCalledOnce());
124126
expect(screen.router?.latestLocation.pathname).toBe("/new");
125127
});

0 commit comments

Comments
 (0)