@@ -19,6 +19,7 @@ const watch = (overrides: Partial<ThreadPullRequestWatch> = {}): ThreadPullReque
1919 headSha : null ,
2020 failedChecks : [ ] ,
2121 passed : false ,
22+ passedChecks : [ ] ,
2223 remarksThrough : STARTED ,
2324 remarkIds : [ ] ,
2425 conflicting : false ,
@@ -100,6 +101,61 @@ describe("evaluatePullRequestWatch", () => {
100101 assert . deepEqual ( evaluatePullRequestWatch ( watch ( ) , plain , noRemarks ) . changes , [ ] ) ;
101102 } ) ;
102103
104+ it ( "reports passed again when a required check shows up already passed" , ( ) => {
105+ const required = ( name : string , status : PullRequestCheck [ "status" ] ) => ( {
106+ ...check ( name , status ) ,
107+ required : true ,
108+ } ) ;
109+ const tests = detail ( {
110+ checks : [ required ( "Tests" , "success" ) , check ( "Smoke Tests" , "pending" ) ] ,
111+ } ) ;
112+ const first = evaluatePullRequestWatch ( watch ( ) , tests , noRemarks ) ;
113+ assert . deepEqual ( first . changes , [ { kind : "checks-passed" , count : 1 , required : true } ] ) ;
114+
115+ // The gate job was created and finished between two passes, so it was never seen pending.
116+ const gated = detail ( {
117+ checks : [
118+ required ( "Tests" , "success" ) ,
119+ check ( "Smoke Tests" , "success" ) ,
120+ required ( "Smoke Tests Gate" , "success" ) ,
121+ ] ,
122+ } ) ;
123+ const second = evaluatePullRequestWatch ( first . next , gated , noRemarks ) ;
124+ assert . deepEqual ( second . changes , [ { kind : "checks-passed" , count : 2 , required : true } ] ) ;
125+ assert . deepEqual ( evaluatePullRequestWatch ( second . next , gated , noRemarks ) . changes , [ ] ) ;
126+
127+ // Seen pending first, the gate is reported once it passes, as before.
128+ const pending = detail ( {
129+ checks : [ required ( "Tests" , "success" ) , required ( "Smoke Tests Gate" , "pending" ) ] ,
130+ } ) ;
131+ const waiting = evaluatePullRequestWatch ( first . next , pending , noRemarks ) ;
132+ assert . deepEqual ( waiting . changes , [ ] ) ;
133+ assert . deepEqual ( evaluatePullRequestWatch ( waiting . next , gated , noRemarks ) . changes , [
134+ { kind : "checks-passed" , count : 2 , required : true } ,
135+ ] ) ;
136+ } ) ;
137+
138+ it ( "reports passed again when a check shows up already passed where none is required" , ( ) => {
139+ const first = evaluatePullRequestWatch (
140+ watch ( ) ,
141+ detail ( { checks : [ check ( "test" , "success" ) ] } ) ,
142+ noRemarks ,
143+ ) ;
144+ assert . deepEqual ( first . changes , [ { kind : "checks-passed" , count : 1 , required : false } ] ) ;
145+ const both = detail ( { checks : [ check ( "test" , "success" ) , check ( "lint" , "success" ) ] } ) ;
146+ assert . deepEqual ( evaluatePullRequestWatch ( first . next , both , noRemarks ) . changes , [
147+ { kind : "checks-passed" , count : 2 , required : false } ,
148+ ] ) ;
149+ } ) ;
150+
151+ it ( "does not wake a watch saved before passed checks were recorded" , ( ) => {
152+ const green = detail ( { checks : [ { ...check ( "test" , "success" ) , required : true } ] } ) ;
153+ const told = watch ( { headSha : "aaaaaaaaaa" , passed : true } ) ;
154+ const saved = evaluatePullRequestWatch ( told , green , noRemarks ) ;
155+ assert . deepEqual ( saved . changes , [ ] ) ;
156+ assert . deepEqual ( saved . next . passedChecks , [ "test" ] ) ;
157+ } ) ;
158+
103159 it ( "keeps remarks for a later pass when the conversation was not read whole" , ( ) => {
104160 const comments = [ remark ( "reviewer" , "2026-10-02T12:06:00Z" ) ] ;
105161 const partial = evaluatePullRequestWatch ( watch ( ) , detail ( ) , null ) ;
0 commit comments