1- import appStoreMock from "../../../../../tests/libs/__mocks__/app-store" ;
21import i18nMock from "../../../../../tests/libs/__mocks__/libServerI18n" ;
32import prismock from "../../../../../tests/libs/__mocks__/prisma" ;
43
@@ -2066,20 +2065,6 @@ export function mockVideoApp({
20662065 default : mockVideoAdapter ,
20672066 } ) ;
20682067
2069- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2070- //@ts -ignore
2071- appStoreMock . default [ appStoreLookupKey as keyof typeof appStoreMock . default ] . mockImplementation ( ( ) => {
2072- return new Promise ( ( resolve ) => {
2073- resolve ( {
2074- lib : {
2075- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2076- //@ts -ignore
2077- VideoApiAdapter : mockVideoAdapter ,
2078- } ,
2079- } ) ;
2080- } ) ;
2081- } ) ;
2082-
20832068 return {
20842069 createMeetingCalls,
20852070 updateMeetingCalls,
@@ -2155,20 +2140,6 @@ export function mockErrorOnVideoMeetingCreation({
21552140 mockVideoAdapterRegistry [ appStoreLookupKey ] = Promise . resolve ( {
21562141 default : mockErrorAdapter ,
21572142 } ) ;
2158-
2159- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2160- //@ts -ignore
2161- appStoreMock . default [ appStoreLookupKey ] . mockImplementation ( ( ) => {
2162- return new Promise ( ( resolve ) => {
2163- resolve ( {
2164- lib : {
2165- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2166- //@ts -ignore
2167- VideoApiAdapter : mockErrorAdapter ,
2168- } ,
2169- } ) ;
2170- } ) ;
2171- } ) ;
21722143}
21732144
21742145export function mockCrmApp (
@@ -2195,42 +2166,49 @@ export function mockCrmApp(
21952166 ownerEmail : string ;
21962167 } [ ] = [ ] ;
21972168 const eventsCreated : boolean [ ] = [ ] ;
2198- const app = appStoreMetadata [ metadataLookupKey as keyof typeof appStoreMetadata ] ;
2199- const appMock = appStoreMock . default [ metadataLookupKey as keyof typeof appStoreMock . default ] ;
2200- appMock &&
2201- `mockResolvedValue` in appMock &&
2202- appMock . mockResolvedValue ( {
2203- lib : {
2204- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2205- //@ts -ignore
2206- CrmService : class {
2207- constructor ( ) {
2208- log . debug ( "Create CrmSerive" ) ;
2209- }
22102169
2211- createContact ( ) {
2212- if ( crmData ?. createContacts ) {
2213- contactsCreated = crmData . createContacts ;
2214- return Promise . resolve ( crmData ?. createContacts ) ;
2215- }
2216- }
2170+ // Mock the CrmServiceMap directly instead of using the old app-store index approach
2171+ vi . doMock ( "@calcom/app-store/crm.apps.generated" , async ( importOriginal ) => {
2172+ const original = await importOriginal < typeof import ( "@calcom/app-store/crm.apps.generated" ) > ( ) ;
22172173
2218- getContacts ( email : string ) {
2219- if ( crmData ?. getContacts ) {
2220- contactsQueried = crmData ?. getContacts ;
2221- const contactsOfEmail = contactsQueried . filter ( ( contact ) => contact . email === email ) ;
2174+ class MockCrmService {
2175+ constructor ( ) {
2176+ log . debug ( "Create CrmService" ) ;
2177+ }
22222178
2223- return Promise . resolve ( contactsOfEmail ) ;
2224- }
2225- }
2179+ createContact ( ) {
2180+ if ( crmData ?. createContacts ) {
2181+ contactsCreated = crmData . createContacts ;
2182+ return Promise . resolve ( crmData ?. createContacts ) ;
2183+ }
2184+ return Promise . resolve ( [ ] ) ;
2185+ }
22262186
2227- createEvent ( ) {
2228- eventsCreated . push ( true ) ;
2229- return Promise . resolve ( { } ) ;
2230- }
2231- } ,
2187+ getContacts ( email : string ) {
2188+ if ( crmData ?. getContacts ) {
2189+ contactsQueried = crmData ?. getContacts ;
2190+ const contactsOfEmail = contactsQueried . filter ( ( contact ) => contact . email === email ) ;
2191+ return Promise . resolve ( contactsOfEmail ) ;
2192+ }
2193+ return Promise . resolve ( [ ] ) ;
2194+ }
2195+
2196+ createEvent ( ) {
2197+ eventsCreated . push ( true ) ;
2198+ return Promise . resolve ( { } ) ;
2199+ }
2200+ }
2201+
2202+ return {
2203+ ...original ,
2204+ CrmServiceMap : {
2205+ ...original . CrmServiceMap ,
2206+ [ metadataLookupKey ] : Promise . resolve ( {
2207+ default : MockCrmService ,
2208+ } ) ,
22322209 } ,
2233- } ) ;
2210+ } ;
2211+ } ) ;
22342212
22352213 return {
22362214 contactsCreated,
0 commit comments