@@ -11,7 +11,7 @@ const STARTED = "2026-10-02T12:00:00.000Z";
1111
1212const watch = ( overrides : Partial < ThreadPullRequestWatch > = { } ) : ThreadPullRequestWatch => ( {
1313 startedAt : STARTED ,
14- headSha : "aaaaaaaaaa" ,
14+ headSha : null ,
1515 failedChecks : [ ] ,
1616 passed : false ,
1717 passedChecks : [ ] ,
@@ -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 ( { headSha : null } ) , green , noRemarks ) ;
63+ const baseline = evaluatePullRequestWatch ( watch ( { awaitingBaseline : true } ) , green , noRemarks ) ;
6464 assert . deepEqual ( baseline . changes , [ ] ) ;
6565 assert . equal ( baseline . next . headSha , green . headSha ) ;
6666 assert . isTrue ( baseline . next . passed ) ;
@@ -93,7 +93,7 @@ describe("evaluatePullRequestWatch", () => {
9393 checks : [ check ( "lint" , "failure" ) , check ( "test" , "pending" ) ] ,
9494 mergeability : "conflicting" ,
9595 } ) ;
96- const baseline = evaluatePullRequestWatch ( watch ( { headSha : null } ) , broken , noRemarks ) ;
96+ const baseline = evaluatePullRequestWatch ( watch ( { awaitingBaseline : true } ) , broken , noRemarks ) ;
9797 assert . deepEqual ( baseline . changes , [ ] ) ;
9898 assert . deepEqual ( baseline . next . failedChecks , [ "lint" ] ) ;
9999 assert . isFalse ( baseline . next . passed ) ;
@@ -125,7 +125,7 @@ describe("evaluatePullRequestWatch", () => {
125125 remark ( "reviewer" , "2026-10-02T11:00:00Z" ) ,
126126 remark ( "reviewer" , "2026-10-02T12:06:00Z" ) ,
127127 ] ;
128- const baseline = evaluatePullRequestWatch ( watch ( { headSha : null } ) , green , comments ) ;
128+ const baseline = evaluatePullRequestWatch ( watch ( { awaitingBaseline : true } ) , green , comments ) ;
129129 assert . deepEqual ( baseline . changes , [ { kind : "remarks" , remarks : [ comments [ 1 ] ! ] } ] ) ;
130130 assert . isTrue ( baseline . next . passed ) ;
131131 assert . isTrue ( baseline . next . conflicting ) ;
@@ -135,7 +135,7 @@ describe("evaluatePullRequestWatch", () => {
135135
136136 it ( "keeps reporting check changes when the host omits the head SHA" , ( ) => {
137137 const pending = detail ( { headSha : undefined , checks : [ check ( "test" , "pending" ) ] } ) ;
138- const waiting = evaluatePullRequestWatch ( watch ( { headSha : null } ) , pending , noRemarks ) ;
138+ const waiting = evaluatePullRequestWatch ( watch ( { awaitingBaseline : true } ) , pending , noRemarks ) ;
139139 assert . deepEqual ( waiting . changes , [ ] ) ;
140140 const failed = evaluatePullRequestWatch (
141141 waiting . next ,
@@ -155,6 +155,23 @@ describe("evaluatePullRequestWatch", () => {
155155 ) ;
156156 } ) ;
157157
158+ it ( "reports a failure once the head SHA appears after a baseline without one" , ( ) => {
159+ const waiting = evaluatePullRequestWatch (
160+ watch ( { awaitingBaseline : true } ) ,
161+ detail ( { headSha : undefined , checks : [ check ( "test" , "pending" ) ] } ) ,
162+ noRemarks ,
163+ ) ;
164+ assert . deepEqual ( waiting . changes , [ ] ) ;
165+ const failed = evaluatePullRequestWatch (
166+ waiting . next ,
167+ detail ( { checks : [ check ( "test" , "failure" ) ] } ) ,
168+ noRemarks ,
169+ ) ;
170+ assert . deepEqual ( failed . changes , [
171+ { kind : "checks-failed" , failed : [ check ( "test" , "failure" ) ] } ,
172+ ] ) ;
173+ } ) ;
174+
158175 it ( "reports each failure at once, even while another check never finishes" , ( ) => {
159176 const bot = check ( "CodeRabbit" , "pending" ) ;
160177 const first = detail ( { checks : [ check ( "lint" , "failure" ) , check ( "test" , "pending" ) , bot ] } ) ;
0 commit comments