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