@@ -97,14 +97,15 @@ describe("miner CI check-run poller (#2323)", () => {
9797 expect ( fetchFn ) . toHaveBeenCalledTimes ( 3 ) ;
9898 } ) ;
9999
100- it ( "normalizes failed terminal conclusions to failure" , async ( ) => {
100+ it ( "normalizes failed terminal conclusions, including stale, to failure" , async ( ) => {
101101 const fetchFn = vi
102102 . fn ( )
103103 . mockResolvedValueOnce ( prResponse ( ) )
104104 . mockResolvedValueOnce (
105105 checksResponse ( [
106106 checkRun ( "validate" , "completed" , "success" ) ,
107107 checkRun ( "workers" , "completed" , "timed_out" ) ,
108+ checkRun ( "expired" , "completed" , "stale" ) ,
108109 ] ) ,
109110 ) ;
110111
@@ -115,10 +116,31 @@ describe("miner CI check-run poller (#2323)", () => {
115116 checks : [
116117 { name : "validate" , conclusion : "success" } ,
117118 { name : "workers" , conclusion : "failure" } ,
119+ { name : "expired" , conclusion : "failure" } ,
118120 ] ,
119121 } ) ;
120122 } ) ;
121123
124+ it ( "treats a completed stale check run as terminal failure (regression for #2621)" , async ( ) => {
125+ const fetchFn = vi
126+ . fn ( )
127+ . mockResolvedValueOnce ( prResponse ( ) )
128+ . mockResolvedValueOnce ( checksResponse ( [ checkRun ( "github-timeout" , "completed" , "stale" ) ] ) ) ;
129+
130+ await expect (
131+ pollCheckRuns ( "acme/widgets" , 7 , {
132+ apiBaseUrl : API ,
133+ fetchFn,
134+ maxAttempts : 3 ,
135+ sleepFn : vi . fn ( ) ,
136+ } ) ,
137+ ) . resolves . toMatchObject ( {
138+ conclusion : "failure" ,
139+ attempts : 1 ,
140+ checks : [ { name : "github-timeout" , conclusion : "failure" } ] ,
141+ } ) ;
142+ } ) ;
143+
122144 it ( "keeps pending when checks are queued or absent" , async ( ) => {
123145 const queuedFetch = vi
124146 . fn ( )
@@ -201,4 +223,15 @@ describe("miner CI check-run poller (#2323)", () => {
201223 pollCheckRuns ( "acme/widgets" , 11 , { apiBaseUrl : API , fetchFn : missingSha } ) ,
202224 ) . rejects . toThrow ( "github_pr_head_sha_missing" ) ;
203225 } ) ;
226+
227+ it ( "surfaces malformed check-run responses as deterministic errors" , async ( ) => {
228+ const malformedChecks = vi
229+ . fn ( )
230+ . mockResolvedValueOnce ( prResponse ( ) )
231+ . mockResolvedValueOnce ( jsonResponse ( { total_count : 1 , check_runs : null } ) ) ;
232+
233+ await expect (
234+ pollCheckRuns ( "acme/widgets" , 12 , { apiBaseUrl : API , fetchFn : malformedChecks } ) ,
235+ ) . rejects . toThrow ( "github_check_runs_malformed" ) ;
236+ } ) ;
204237} ) ;
0 commit comments