@@ -60,7 +60,7 @@ const noRemarks: ReadonlyArray<PullRequestComment> = [];
6060describe ( "evaluatePullRequestWatch" , ( ) => {
6161 it . each ( [ false , true ] ) ( "baselines already-passed checks (required: %s)" , ( required ) => {
6262 const green = detail ( { checks : [ { ...check ( "test" , "success" ) , required } ] } ) ;
63- const baseline = evaluatePullRequestWatch ( watch ( { awaitingBaseline : true } ) , green , noRemarks ) ;
63+ const baseline = evaluatePullRequestWatch ( watch ( { awaitingBaseline : "all" } ) , green , noRemarks ) ;
6464 assert . deepEqual ( baseline . changes , [ ] ) ;
6565 assert . equal ( baseline . next . headSha , green . headSha ) ;
6666 assert . isTrue ( baseline . next . passed ) ;
@@ -93,7 +93,11 @@ describe("evaluatePullRequestWatch", () => {
9393 checks : [ check ( "lint" , "failure" ) , check ( "test" , "pending" ) ] ,
9494 mergeability : "conflicting" ,
9595 } ) ;
96- const baseline = evaluatePullRequestWatch ( watch ( { awaitingBaseline : true } ) , broken , noRemarks ) ;
96+ const baseline = evaluatePullRequestWatch (
97+ watch ( { awaitingBaseline : "all" } ) ,
98+ broken ,
99+ noRemarks ,
100+ ) ;
97101 assert . deepEqual ( baseline . changes , [ ] ) ;
98102 assert . deepEqual ( baseline . next . failedChecks , [ "lint" ] ) ;
99103 assert . isFalse ( baseline . next . passed ) ;
@@ -125,7 +129,7 @@ describe("evaluatePullRequestWatch", () => {
125129 remark ( "reviewer" , "2026-10-02T11:00:00Z" ) ,
126130 remark ( "reviewer" , "2026-10-02T12:06:00Z" ) ,
127131 ] ;
128- const baseline = evaluatePullRequestWatch ( watch ( { awaitingBaseline : true } ) , green , comments ) ;
132+ const baseline = evaluatePullRequestWatch ( watch ( { awaitingBaseline : "all" } ) , green , comments ) ;
129133 assert . deepEqual ( baseline . changes , [ { kind : "remarks" , remarks : [ comments [ 1 ] ! ] } ] ) ;
130134 assert . isTrue ( baseline . next . passed ) ;
131135 assert . isTrue ( baseline . next . conflicting ) ;
@@ -135,7 +139,11 @@ describe("evaluatePullRequestWatch", () => {
135139
136140 it ( "keeps reporting check changes when the host omits the head SHA" , ( ) => {
137141 const pending = detail ( { headSha : undefined , checks : [ check ( "test" , "pending" ) ] } ) ;
138- const waiting = evaluatePullRequestWatch ( watch ( { awaitingBaseline : true } ) , pending , noRemarks ) ;
142+ const waiting = evaluatePullRequestWatch (
143+ watch ( { awaitingBaseline : "all" } ) ,
144+ pending ,
145+ noRemarks ,
146+ ) ;
139147 assert . deepEqual ( waiting . changes , [ ] ) ;
140148 const failed = evaluatePullRequestWatch (
141149 waiting . next ,
@@ -157,7 +165,7 @@ describe("evaluatePullRequestWatch", () => {
157165
158166 it ( "reports a failure once the head SHA appears after a baseline without one" , ( ) => {
159167 const waiting = evaluatePullRequestWatch (
160- watch ( { awaitingBaseline : true } ) ,
168+ watch ( { awaitingBaseline : "all" } ) ,
161169 detail ( { headSha : undefined , checks : [ check ( "test" , "pending" ) ] } ) ,
162170 noRemarks ,
163171 ) ;
@@ -175,7 +183,7 @@ describe("evaluatePullRequestWatch", () => {
175183 it ( "keeps a baseline taken without a head SHA once the SHA appears" , ( ) => {
176184 const green = detail ( { checks : [ check ( "test" , "success" ) ] } ) ;
177185 const baseline = evaluatePullRequestWatch (
178- watch ( { awaitingBaseline : true } ) ,
186+ watch ( { awaitingBaseline : "all" } ) ,
179187 { ...green , headSha : undefined } ,
180188 noRemarks ,
181189 ) ;
@@ -195,6 +203,30 @@ describe("evaluatePullRequestWatch", () => {
195203 ) ;
196204 } ) ;
197205
206+ it ( "takes the check baseline from the first read that lists checks" , ( ) => {
207+ const empty = evaluatePullRequestWatch (
208+ watch ( { awaitingBaseline : "all" } ) ,
209+ detail ( { checks : [ ] } ) ,
210+ noRemarks ,
211+ ) ;
212+ assert . deepEqual ( empty . changes , [ ] ) ;
213+ assert . equal ( empty . next . awaitingBaseline , "checks" ) ;
214+
215+ const failing = detail ( { checks : [ check ( "lint" , "failure" ) ] , mergeability : "conflicting" } ) ;
216+ const listed = evaluatePullRequestWatch ( empty . next , failing , noRemarks ) ;
217+ // The conflict is new since the first read; the failure may predate the watch.
218+ assert . deepEqual ( listed . changes , [ { kind : "conflicting" } ] ) ;
219+ assert . isUndefined ( listed . next . awaitingBaseline ) ;
220+ assert . deepEqual (
221+ evaluatePullRequestWatch (
222+ listed . next ,
223+ { ...failing , checks : [ check ( "lint" , "failure" ) , check ( "test" , "failure" ) ] } ,
224+ noRemarks ,
225+ ) . changes ,
226+ [ { kind : "checks-failed" , failed : [ check ( "test" , "failure" ) ] } ] ,
227+ ) ;
228+ } ) ;
229+
198230 it ( "reports each failure at once, even while another check never finishes" , ( ) => {
199231 const bot = check ( "CodeRabbit" , "pending" ) ;
200232 const first = detail ( { checks : [ check ( "lint" , "failure" ) , check ( "test" , "pending" ) , bot ] } ) ;
0 commit comments