@@ -3,12 +3,26 @@ import { act } from "react";
33import { create , type ReactTestRenderer } from "react-test-renderer" ;
44import { afterEach , expect , it , vi } from "vite-plus/test" ;
55
6+ const watchCommand = vi . hoisted ( ( ) => vi . fn ( ) ) ;
7+
68vi . 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} ) ) ;
923vi . mock ( "~/state/entities" , ( ) => ( { useProjects : ( ) => [ ] } ) ) ;
1024vi . mock ( "~/state/threads" , ( ) => ( { threadEnvironment : { } } ) ) ;
11- vi . mock ( "~/state/use-atom-command" , ( ) => ( { useAtomCommand : ( ) => vi . fn ( ) } ) ) ;
25+ vi . mock ( "~/state/use-atom-command" , ( ) => ( { useAtomCommand : ( ) => watchCommand } ) ) ;
1226vi . 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