@@ -226,27 +226,36 @@ function createCronContext(currentJobs?: CronJob | CronJob[]) {
226226 } ,
227227 ) ,
228228 list : vi . fn ( async ( ) => jobs ) ,
229- listPage : vi . fn ( async ( opts ?: { agentId ?: string ; limit ?: number ; offset ?: number } ) => {
230- const requestedAgentId = opts ?. agentId ?. trim ( ) . toLowerCase ( ) ;
231- const filteredJobs = requestedAgentId
232- ? jobs . filter ( ( job ) => ( job . agentId ?? "main" ) . trim ( ) . toLowerCase ( ) === requestedAgentId )
233- : jobs ;
234- const total = filteredJobs . length ;
235- const offset = Math . max ( 0 , Math . min ( total , Math . floor ( opts ?. offset ?? 0 ) ) ) ;
236- const defaultLimit = total === 0 ? 50 : total ;
237- const limit = Math . max ( 1 , Math . min ( 200 , Math . floor ( opts ?. limit ?? defaultLimit ) ) ) ;
238- const pageJobs = filteredJobs . slice ( offset , offset + limit ) ;
239- const nextOffset = offset + pageJobs . length ;
240- return {
241- jobs : pageJobs ,
242- snapshotRevision : `fixture:${ filteredJobs . map ( ( job ) => job . id ) . join ( "," ) } ` ,
243- total,
244- offset,
245- limit,
246- hasMore : nextOffset < total ,
247- nextOffset : nextOffset < total ? nextOffset : null ,
248- } ;
249- } ) ,
229+ listPage : vi . fn (
230+ async ( opts ?: {
231+ agentId ?: string ;
232+ limit ?: number ;
233+ offset ?: number ;
234+ trigger ?: "all" | "conditional" | "unconditional" ;
235+ } ) => {
236+ const requestedAgentId = opts ?. agentId ?. trim ( ) . toLowerCase ( ) ;
237+ const filteredJobs = requestedAgentId
238+ ? jobs . filter (
239+ ( job ) => ( job . agentId ?? "main" ) . trim ( ) . toLowerCase ( ) === requestedAgentId ,
240+ )
241+ : jobs ;
242+ const total = filteredJobs . length ;
243+ const offset = Math . max ( 0 , Math . min ( total , Math . floor ( opts ?. offset ?? 0 ) ) ) ;
244+ const defaultLimit = total === 0 ? 50 : total ;
245+ const limit = Math . max ( 1 , Math . min ( 200 , Math . floor ( opts ?. limit ?? defaultLimit ) ) ) ;
246+ const pageJobs = filteredJobs . slice ( offset , offset + limit ) ;
247+ const nextOffset = offset + pageJobs . length ;
248+ return {
249+ jobs : pageJobs ,
250+ snapshotRevision : `fixture:${ filteredJobs . map ( ( job ) => job . id ) . join ( "," ) } ` ,
251+ total,
252+ offset,
253+ limit,
254+ hasMore : nextOffset < total ,
255+ nextOffset : nextOffset < total ? nextOffset : null ,
256+ } ;
257+ } ,
258+ ) ,
250259 } ,
251260 logGateway : {
252261 info : vi . fn ( ) ,
@@ -925,13 +934,17 @@ describe("cron method validation", () => {
925934 } ) ;
926935 } ) ;
927936
928- it ( "keeps unscoped cron.list agentId filtering global for operator callers" , async ( ) => {
937+ it ( "forwards unscoped cron.list filters for operator callers" , async ( ) => {
929938 const context = createCronContext ( createCronJob ( { agentId : "worker" } ) ) ;
930939
931- const { respond } = await invokeCron ( "cron.list" , { agentId : "worker" } , { context } ) ;
940+ const { respond } = await invokeCron (
941+ "cron.list" ,
942+ { agentId : "worker" , trigger : "conditional" } ,
943+ { context } ,
944+ ) ;
932945
933946 expect ( context . cron . listPage ) . toHaveBeenCalledWith (
934- expect . objectContaining ( { agentId : "worker" } ) ,
947+ expect . objectContaining ( { agentId : "worker" , trigger : "conditional" } ) ,
935948 ) ;
936949 expect ( respond ) . toHaveBeenCalledWith (
937950 true ,
0 commit comments