Skip to content

Commit 1c027dc

Browse files
t3dotggclaude
andcommitted
test(web): watched rows in the details card can stop their watch
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 6cae38a commit 1c027dc

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

‎apps/web/src/components/chat/ThreadDetailsPrRows.test.tsx‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,26 @@ import { act } from "react";
33
import { create, type ReactTestRenderer } from "react-test-renderer";
44
import { afterEach, expect, it, vi } from "vite-plus/test";
55

6+
const watchCommand = vi.hoisted(() => vi.fn());
7+
68
vi.mock("./ThreadDetailsPrRow", () => ({
7-
ThreadDetailsPrRow: ({ number }: { number: number }) => <span data-row={String(number)} />,
9+
ThreadDetailsPrRow: ({
10+
number,
11+
onStopWatching,
12+
}: {
13+
number: number;
14+
onStopWatching?: () => void;
15+
}) => (
16+
<span
17+
data-row={String(number)}
18+
data-watched={onStopWatching ? "" : undefined}
19+
onClick={onStopWatching}
20+
/>
21+
),
822
}));
923
vi.mock("~/state/entities", () => ({ useProjects: () => [] }));
1024
vi.mock("~/state/threads", () => ({ threadEnvironment: {} }));
11-
vi.mock("~/state/use-atom-command", () => ({ useAtomCommand: () => vi.fn() }));
25+
vi.mock("~/state/use-atom-command", () => ({ useAtomCommand: () => watchCommand }));
1226
vi.mock("~/lib/openPullRequestLink", () => ({
1327
parseChangeRequestUrl: () => null,
1428
findProjectOnChangeRequestHost: () => undefined,
@@ -111,3 +125,40 @@ it("keeps the single row untouched when the thread links one pull request", () =
111125
expect(rows()).toEqual(["1"]);
112126
expect(toggleLabel()).toBeUndefined();
113127
});
128+
129+
it("lets only watched pull requests stop their watch", () => {
130+
const watched: ThreadPullRequestLink = {
131+
...bottom,
132+
watch: {
133+
startedAt: "2026-01-01T00:00:30.000Z",
134+
headSha: null,
135+
failedChecks: [],
136+
passed: false,
137+
passedChecks: [],
138+
remarksThrough: "2026-01-01T00:00:30.000Z",
139+
remarkIds: [],
140+
conflicting: false,
141+
wakes: 0,
142+
},
143+
};
144+
render([other, watched, top], top);
145+
toggle();
146+
const spans = renderer.root.findAllByType("span");
147+
expect(
148+
spans
149+
.filter((node) => node.props["data-watched"] !== undefined)
150+
.map((node) => node.props["data-row"]),
151+
).toEqual(["1"]);
152+
153+
act(() => spans.find((node) => node.props["data-row"] === "1")!.props.onClick());
154+
expect(watchCommand).toHaveBeenCalledWith({
155+
environmentId: EnvironmentId.make("environment"),
156+
input: {
157+
threadId: ThreadId.make("thread"),
158+
host: "github.com",
159+
repository: "pingdotgg/t3code",
160+
number: 1,
161+
watching: false,
162+
},
163+
});
164+
});

0 commit comments

Comments
 (0)