@@ -5,20 +5,23 @@ test('Sends cron check-in envelope for successful cron job', async ({ request })
55 const inProgressEnvelopePromise = waitForEnvelopeItem ( 'nextjs-15' , envelope => {
66 return (
77 envelope [ 0 ] . type === 'check_in' &&
8+ // @ts -expect-error envelope[1] is untyped
89 envelope [ 1 ] [ 'monitor_slug' ] === '/api/cron-test' &&
10+ // @ts -expect-error envelope[1] is untyped
911 envelope [ 1 ] [ 'status' ] === 'in_progress'
1012 ) ;
1113 } ) ;
1214
1315 const okEnvelopePromise = waitForEnvelopeItem ( 'nextjs-15' , envelope => {
1416 return (
1517 envelope [ 0 ] . type === 'check_in' &&
18+ // @ts -expect-error envelope[1] is untyped
1619 envelope [ 1 ] [ 'monitor_slug' ] === '/api/cron-test' &&
20+ // @ts -expect-error envelope[1] is untyped
1721 envelope [ 1 ] [ 'status' ] === 'ok'
1822 ) ;
1923 } ) ;
2024
21- // Simulate Vercel cron request with the special user agent
2225 const response = await request . get ( '/api/cron-test' , {
2326 headers : {
2427 'User-Agent' : 'vercel-cron/1.0' ,
@@ -54,29 +57,31 @@ test('Sends cron check-in envelope for successful cron job', async ({ request })
5457 duration : expect . any ( Number ) ,
5558 } ) ,
5659 ) ;
57-
58- // Check-in IDs should match
60+ // @ts -expect-error envelope[1] is untyped
5961 expect ( okEnvelope [ 1 ] [ 'check_in_id' ] ) . toBe ( inProgressEnvelope [ 1 ] [ 'check_in_id' ] ) ;
6062} ) ;
6163
6264test ( 'Sends cron check-in envelope with error status for failed cron job' , async ( { request } ) => {
6365 const inProgressEnvelopePromise = waitForEnvelopeItem ( 'nextjs-15' , envelope => {
6466 return (
6567 envelope [ 0 ] . type === 'check_in' &&
68+ // @ts -expect-error envelope[1] is untyped
6669 envelope [ 1 ] [ 'monitor_slug' ] === '/api/cron-test-error' &&
70+ // @ts -expect-error envelope[1] is untyped
6771 envelope [ 1 ] [ 'status' ] === 'in_progress'
6872 ) ;
6973 } ) ;
7074
7175 const errorEnvelopePromise = waitForEnvelopeItem ( 'nextjs-15' , envelope => {
7276 return (
7377 envelope [ 0 ] . type === 'check_in' &&
78+ // @ts -expect-error envelope[1] is untyped
7479 envelope [ 1 ] [ 'monitor_slug' ] === '/api/cron-test-error' &&
80+ // @ts -expect-error envelope[1] is untyped
7581 envelope [ 1 ] [ 'status' ] === 'error'
7682 ) ;
7783 } ) ;
7884
79- // Simulate Vercel cron request with the special user agent
8085 await request . get ( '/api/cron-test-error' , {
8186 headers : {
8287 'User-Agent' : 'vercel-cron/1.0' ,
@@ -110,29 +115,31 @@ test('Sends cron check-in envelope with error status for failed cron job', async
110115 } ) ,
111116 ) ;
112117
113- // Check-in IDs should match
118+ // @ts -expect-error envelope[1] is untyped
114119 expect ( errorEnvelope [ 1 ] [ 'check_in_id' ] ) . toBe ( inProgressEnvelope [ 1 ] [ 'check_in_id' ] ) ;
115120} ) ;
116121
117- test ( 'Does not send cron check-in envelope for regular requests without vercel-cron user agent' , async ( { request } ) => {
118- // Use a flag to track if any check-in envelope is received
122+ test ( 'Does not send cron check-in envelope for regular requests without vercel-cron user agent' , async ( {
123+ request,
124+ } ) => {
119125 let checkInReceived = false ;
120126
121- const checkInPromise = waitForEnvelopeItem ( 'nextjs-15' , envelope => {
122- if ( envelope [ 0 ] . type === 'check_in' && envelope [ 1 ] [ 'monitor_slug' ] === '/api/cron-test' ) {
127+ waitForEnvelopeItem ( 'nextjs-15' , envelope => {
128+ if (
129+ envelope [ 0 ] . type === 'check_in' && // @ts -expect-error envelope[1] is untyped
130+ envelope [ 1 ] [ 'monitor_slug' ] === '/api/cron-test'
131+ ) {
123132 checkInReceived = true ;
124133 return true ;
125134 }
126135 return false ;
127136 } ) ;
128137
129- // Make a regular request without the vercel-cron user agent
130138 const response = await request . get ( '/api/cron-test' ) ;
131139
132140 expect ( response . status ( ) ) . toBe ( 200 ) ;
133141 expect ( await response . json ( ) ) . toStrictEqual ( { message : 'Cron job executed successfully' } ) ;
134142
135- // Wait a bit to ensure no check-in is sent
136143 await new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ;
137144
138145 expect ( checkInReceived ) . toBe ( false ) ;
0 commit comments