@@ -17,6 +17,7 @@ import FileTimingsReporter, {
1717 fileRecord ,
1818 judgeRun ,
1919 medianDurations ,
20+ selectRuns ,
2021 summarize ,
2122 readRunReports ,
2223 runDurations ,
@@ -224,6 +225,24 @@ describe('the selector', () => {
224225 expect ( judgeRun ( { jobs : jobs ( [ 'success' , 'success' ] ) , artifacts : artifacts ( 1 ) , shards : 2 } ) . eligible ) . toBe ( false ) ;
225226 expect ( judgeRun ( { jobs : jobs ( [ 'success' , 'success' ] ) , artifacts : [ { name : artifactName ( 1 ) } , { name : artifactName ( 2 ) , expired : true } ] , shards : 2 } ) . eligible ) . toBe ( false ) ;
226227 } ) ;
228+
229+ it ( 'lists schedule runs only, and takes no push run even when one is listed (objectstack#31519)' , async ( ) => {
230+ const routes : string [ ] = [ ] ;
231+ const fetchImpl = ( async ( url : string ) => {
232+ const route = url . replace ( 'https://api.test' , '' ) ;
233+ routes . push ( route ) ;
234+ const body = route . includes ( '/actions/workflows/ci.yml/runs' )
235+ ? { workflow_runs : [ { id : 2 , event : 'push' , head_sha : 'b' . repeat ( 40 ) , created_at : 'x' } , { id : 1 , event : 'schedule' , head_sha : 'a' . repeat ( 40 ) , created_at : 'y' } ] }
236+ : route . includes ( '/jobs' )
237+ ? { jobs : jobs ( [ 'success' , 'success' ] ) }
238+ : { artifacts : artifacts ( 2 ) } ;
239+ return { ok : true , status : 200 , json : async ( ) => body } ;
240+ } ) as unknown as typeof fetch ;
241+ const chosen = await selectRuns ( { shards : 2 , limit : 6 , repository : 'o/r' , token : '' , apiUrl : 'https://api.test' , fetchImpl } ) ;
242+ expect ( routes [ 0 ] ) . toBe ( '/repos/o/r/actions/workflows/ci.yml/runs?branch=main&event=schedule&status=completed&per_page=50' ) ;
243+ expect ( chosen . map ( ( r ) => r . id ) ) . toEqual ( [ 1 ] ) ;
244+ expect ( routes . some ( ( r ) => r . startsWith ( '/repos/o/r/actions/runs/2/' ) ) ) . toBe ( false ) ;
245+ } ) ;
227246} ) ;
228247
229248/** The weekly refresh that drives `select` and `merge`, at the monorepo root. */
0 commit comments