@@ -66,6 +66,7 @@ type InputUser = Omit<typeof TestData.users.example, "defaultScheduleId"> & {
66
66
id : number ;
67
67
defaultScheduleId ?: number | null ;
68
68
credentials ?: InputCredential [ ] ;
69
+ organizationId ?: number | null ;
69
70
selectedCalendars ?: InputSelectedCalendar [ ] ;
70
71
schedules : {
71
72
// Allows giving id in the input directly so that it can be referenced somewhere else as well
@@ -264,8 +265,21 @@ async function addBookingsToDb(
264
265
} ) [ ]
265
266
) {
266
267
log . silly ( "TestData: Creating Bookings" , JSON . stringify ( bookings ) ) ;
268
+
269
+ function getDateObj ( time : string | Date ) {
270
+ return time instanceof Date ? time : new Date ( time ) ;
271
+ }
272
+
273
+ // Make sure that we store the date in Date object always. This is to ensure consistency which Prisma does but not prismock
274
+ log . silly ( "Handling Prismock bug-3" ) ;
275
+ const fixedBookings = bookings . map ( ( booking ) => {
276
+ const startTime = getDateObj ( booking . startTime ) ;
277
+ const endTime = getDateObj ( booking . endTime ) ;
278
+ return { ...booking , startTime, endTime } ;
279
+ } ) ;
280
+
267
281
await prismock . booking . createMany ( {
268
- data : bookings ,
282
+ data : fixedBookings ,
269
283
} ) ;
270
284
log . silly (
271
285
"TestData: Bookings as in DB" ,
@@ -406,6 +420,7 @@ async function addUsers(users: InputUser[]) {
406
420
} ,
407
421
} ;
408
422
}
423
+
409
424
return newUser ;
410
425
} ) ;
411
426
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -446,6 +461,16 @@ export async function createBookingScenario(data: ScenarioData) {
446
461
} ;
447
462
}
448
463
464
+ export async function createOrganization ( orgData : { name : string ; slug : string } ) {
465
+ const org = await prismock . team . create ( {
466
+ data : {
467
+ name : orgData . name ,
468
+ slug : orgData . slug ,
469
+ } ,
470
+ } ) ;
471
+ return org ;
472
+ }
473
+
449
474
// async function addPaymentsToDb(payments: Prisma.PaymentCreateInput[]) {
450
475
// await prismaMock.payment.createMany({
451
476
// data: payments,
@@ -722,6 +747,7 @@ export function getOrganizer({
722
747
} ) {
723
748
return {
724
749
...TestData . users . example ,
750
+ organizationId : null as null | number ,
725
751
name,
726
752
email,
727
753
id,
@@ -733,24 +759,33 @@ export function getOrganizer({
733
759
} ;
734
760
}
735
761
736
- export function getScenarioData ( {
737
- organizer,
738
- eventTypes,
739
- usersApartFromOrganizer = [ ] ,
740
- apps = [ ] ,
741
- webhooks,
742
- bookings,
743
- } : // hosts = [],
744
- {
745
- organizer : ReturnType < typeof getOrganizer > ;
746
- eventTypes : ScenarioData [ "eventTypes" ] ;
747
- apps ?: ScenarioData [ "apps" ] ;
748
- usersApartFromOrganizer ?: ScenarioData [ "users" ] ;
749
- webhooks ?: ScenarioData [ "webhooks" ] ;
750
- bookings ?: ScenarioData [ "bookings" ] ;
751
- // hosts?: ScenarioData["hosts"];
752
- } ) {
762
+ export function getScenarioData (
763
+ {
764
+ organizer,
765
+ eventTypes,
766
+ usersApartFromOrganizer = [ ] ,
767
+ apps = [ ] ,
768
+ webhooks,
769
+ bookings,
770
+ } : // hosts = [],
771
+ {
772
+ organizer : ReturnType < typeof getOrganizer > ;
773
+ eventTypes : ScenarioData [ "eventTypes" ] ;
774
+ apps ?: ScenarioData [ "apps" ] ;
775
+ usersApartFromOrganizer ?: ScenarioData [ "users" ] ;
776
+ webhooks ?: ScenarioData [ "webhooks" ] ;
777
+ bookings ?: ScenarioData [ "bookings" ] ;
778
+ // hosts?: ScenarioData["hosts"];
779
+ } ,
780
+ org ?: { id : number | null } | undefined | null
781
+ ) {
753
782
const users = [ organizer , ...usersApartFromOrganizer ] ;
783
+ if ( org ) {
784
+ users . forEach ( ( user ) => {
785
+ user . organizationId = org . id ;
786
+ } ) ;
787
+ }
788
+
754
789
eventTypes . forEach ( ( eventType ) => {
755
790
if (
756
791
eventType . users ?. filter ( ( eventTypeUser ) => {
@@ -897,6 +932,7 @@ export function mockCalendar(
897
932
url : "https://UNUSED_URL" ,
898
933
} ) ;
899
934
} ,
935
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
900
936
deleteEvent : async ( ...rest : any [ ] ) => {
901
937
log . silly ( "mockCalendar.deleteEvent" , JSON . stringify ( { rest } ) ) ;
902
938
// eslint-disable-next-line prefer-rest-params
@@ -1021,6 +1057,7 @@ export function mockVideoApp({
1021
1057
...videoMeetingData ,
1022
1058
} ) ;
1023
1059
} ,
1060
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1024
1061
deleteMeeting : async ( ...rest : any [ ] ) => {
1025
1062
log . silly ( "MockVideoApiAdapter.deleteMeeting" , JSON . stringify ( rest ) ) ;
1026
1063
deleteMeetingCalls . push ( {
@@ -1153,7 +1190,6 @@ export async function mockPaymentSuccessWebhookFromStripe({ externalId }: { exte
1153
1190
await handleStripePaymentSuccess ( getMockedStripePaymentEvent ( { paymentIntentId : externalId } ) ) ;
1154
1191
} catch ( e ) {
1155
1192
log . silly ( "mockPaymentSuccessWebhookFromStripe:catch" , JSON . stringify ( e ) ) ;
1156
-
1157
1193
webhookResponse = e as HttpError ;
1158
1194
}
1159
1195
return { webhookResponse } ;
0 commit comments