11import { afterAll , beforeAll , describe , expect , it } from 'vitest'
2- import { ORG_ID , getSupabaseClient , getCronPlanQueueCount , getLatestCronPlanMessage , cleanupPostgresClient } from './test-utils.ts'
2+ import { cleanupPostgresClient , getCronPlanQueueCount , getLatestCronPlanMessage , getSupabaseClient , ORG_ID } from './test-utils.ts'
33
44describe ( '[Function] queue_cron_plan_for_org' , ( ) => {
55 let testCustomerId : string | null = null
@@ -16,7 +16,8 @@ describe('[Function] queue_cron_plan_for_org', () => {
1616
1717 if ( orgData ?. customer_id ) {
1818 testCustomerId = orgData . customer_id
19- } else {
19+ }
20+ else {
2021 // Fallback: get any existing stripe_info record
2122 const { data : stripeData } = await supabase
2223 . from ( 'stripe_info' )
@@ -54,7 +55,7 @@ describe('[Function] queue_cron_plan_for_org', () => {
5455 // Call the function
5556 const { error } = await supabase . rpc ( 'queue_cron_stat_org_for_org' , {
5657 org_id : ORG_ID ,
57- customer_id : testCustomerId
58+ customer_id : testCustomerId ,
5859 } )
5960
6061 expect ( error ) . toBeNull ( )
@@ -70,8 +71,8 @@ describe('[Function] queue_cron_plan_for_org', () => {
7071 function_type : 'cloudflare' ,
7172 payload : {
7273 orgId : ORG_ID ,
73- customerId : testCustomerId
74- }
74+ customerId : testCustomerId ,
75+ } ,
7576 } )
7677 } )
7778
@@ -97,7 +98,7 @@ describe('[Function] queue_cron_plan_for_org', () => {
9798 // Call the function
9899 const { error } = await supabase . rpc ( 'queue_cron_stat_org_for_org' , {
99100 org_id : ORG_ID ,
100- customer_id : testCustomerId
101+ customer_id : testCustomerId ,
101102 } )
102103
103104 expect ( error ) . toBeNull ( )
@@ -114,7 +115,7 @@ describe('[Function] queue_cron_plan_for_org', () => {
114115 . single ( )
115116 . throwOnError ( )
116117
117- const actualTimestamp = new Date ( stripeInfo ?. plan_calculated_at ! ) . getTime ( )
118+ const actualTimestamp = new Date ( stripeInfo ?. plan_calculated_at ?? 0 ) . getTime ( )
118119 const expectedTimestamp = thirtyMinutesAgo . getTime ( )
119120
120121 // Should be within 1 second of the original timestamp (rate limiting prevented update)
@@ -143,7 +144,7 @@ describe('[Function] queue_cron_plan_for_org', () => {
143144 // Call the function
144145 const { error } = await supabase . rpc ( 'queue_cron_stat_org_for_org' , {
145146 org_id : ORG_ID ,
146- customer_id : testCustomerId
147+ customer_id : testCustomerId ,
147148 } )
148149
149150 expect ( error ) . toBeNull ( )
@@ -159,8 +160,8 @@ describe('[Function] queue_cron_plan_for_org', () => {
159160 function_type : 'cloudflare' ,
160161 payload : {
161162 orgId : ORG_ID ,
162- customerId : testCustomerId
163- }
163+ customerId : testCustomerId ,
164+ } ,
164165 } )
165166 } )
166167
@@ -170,7 +171,7 @@ describe('[Function] queue_cron_plan_for_org', () => {
170171 // Call with non-existent customer_id
171172 const { error } = await supabase . rpc ( 'queue_cron_stat_org_for_org' , {
172173 org_id : ORG_ID ,
173- customer_id : 'non_existent_customer'
174+ customer_id : 'non_existent_customer' ,
174175 } )
175176
176177 expect ( error ) . toBeNull ( )
@@ -189,7 +190,7 @@ describe('[Function] queue_cron_plan_for_org', () => {
189190
190191 const { error } = await supabase . rpc ( 'queue_cron_stat_org_for_org' , {
191192 org_id : ORG_ID ,
192- customer_id : testCustomerId
193+ customer_id : testCustomerId ,
193194 } )
194195
195196 expect ( error ) . toBeNull ( )
0 commit comments