@@ -75,6 +75,7 @@ function createCronContext(currentJob?: CronJob) {
7575 cron : {
7676 add : vi . fn ( async ( ) => ( { id : "cron-1" } ) ) ,
7777 update : vi . fn ( async ( ) => ( { id : "cron-1" } ) ) ,
78+ remove : vi . fn ( async ( ) => ( { ok : true , removed : true } ) ) ,
7879 getDefaultAgentId : vi . fn ( ( ) => "main" ) ,
7980 getJob : vi . fn ( ( ) => currentJob ) ,
8081 wake : vi . fn ( ( ) => ( { ok : true } ) as const ) ,
@@ -129,6 +130,26 @@ async function invokeCronUpdate(params: Record<string, unknown>, currentJob: Cro
129130 return { context, respond } ;
130131}
131132
133+ async function invokeCronRemove (
134+ params : Record < string , unknown > ,
135+ options ?: { removeResult ?: { ok : boolean ; removed : boolean } } ,
136+ ) {
137+ const context = createCronContext ( ) ;
138+ if ( options ?. removeResult ) {
139+ context . cron . remove . mockResolvedValueOnce ( options . removeResult ) ;
140+ }
141+ const respond = vi . fn ( ) ;
142+ await cronHandlers [ "cron.remove" ] ( {
143+ req : { } as never ,
144+ params : params as never ,
145+ respond : respond as never ,
146+ context : context as never ,
147+ client : null ,
148+ isWebchatConnect : ( ) => false ,
149+ } ) ;
150+ return { context, respond } ;
151+ }
152+
132153function createCronJob ( overrides : Partial < CronJob > = { } ) : CronJob {
133154 return {
134155 id : "cron-1" ,
@@ -246,6 +267,17 @@ describe("cron method validation", () => {
246267 expect ( respond ) . toHaveBeenCalledWith ( true , { id : "cron-1" } , undefined ) ;
247268 } ) ;
248269
270+ it ( "returns invalid-request error when cron.remove target id is missing" , async ( ) => {
271+ const { respond } = await invokeCronRemove (
272+ { id : "missing-id" } ,
273+ { removeResult : { ok : true , removed : false } } ,
274+ ) ;
275+ expectResponseError ( respond , {
276+ code : "INVALID_REQUEST" ,
277+ messageIncludes : "invalid cron.remove params: id not found" ,
278+ } ) ;
279+ } ) ;
280+
249281 it ( "returns a single cron job for cron.get" , async ( ) => {
250282 const job = createCronJob ( { id : "cron-42" , name : "single job" } ) ;
251283
0 commit comments