test: Booking flow App failure and ics file tests and improved logging (#11646)
This commit is contained in:
1 parent
07bfaec24e
commit
3ca7456885
17 files changed
+513
-239
No files matched your search
@@ -10,6 +10,7 @@ import { appKeysSchema as calVideoKeysSchema } from "@calcom/app-store/dailyvide
|
||||
import { getEventLocationTypeFromApp, MeetLocationType } from "@calcom/app-store/locations";
|
||||
import getApps from "@calcom/app-store/utils";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getPiiFreeUser } from "@calcom/lib/piiFreeData";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential";
|
||||
@@ -27,6 +28,7 @@ import type {
|
||||
import { createEvent, updateEvent } from "./CalendarManager";
|
||||
import { createMeeting, updateMeeting } from "./videoClient";
|
||||
|
||||
const log = logger.getChildLogger({ prefix: ["EventManager"] });
|
||||
export const isDedicatedIntegration = (location: string): boolean => {
|
||||
return location !== MeetLocationType && location.includes("integrations:");
|
||||
};
|
||||
@@ -81,7 +83,7 @@ export default class EventManager {
|
||||
* @param user
|
||||
*/
|
||||
constructor(user: EventManagerUser) {
|
||||
logger.silly("Initializing EventManager", JSON.stringify({ user }));
|
||||
log.silly("Initializing EventManager", safeStringify({ user: getPiiFreeUser(user) }));
|
||||
const appCredentials = getApps(user.credentials, true).flatMap((app) =>
|
||||
app.credentials.map((creds) => ({ ...creds, appName: app.name }))
|
||||
);
|
||||
@@ -124,6 +126,7 @@ export default class EventManager {
|
||||
const [mainHostDestinationCalendar] =
|
||||
(evt.destinationCalendar as [undefined | NonNullable<typeof evt.destinationCalendar>[number]]) ?? [];
|
||||
if (evt.location === MeetLocationType && mainHostDestinationCalendar?.integration !== "google_calendar") {
|
||||
log.warn("Falling back to Cal Video integration as Google Calendar not installed");
|
||||
evt["location"] = "integrations:daily";
|
||||
}
|
||||
const isDedicated = evt.location ? isDedicatedIntegration(evt.location) : null;
|
||||
@@ -362,7 +365,7 @@ export default class EventManager {
|
||||
[] as DestinationCalendar[]
|
||||
);
|
||||
for (const destination of destinationCalendars) {
|
||||
logger.silly("Creating Calendar event", JSON.stringify({ destination }));
|
||||
log.silly("Creating Calendar event", JSON.stringify({ destination }));
|
||||
if (destination.credentialId) {
|
||||
let credential = this.calendarCredentials.find((c) => c.id === destination.credentialId);
|
||||
if (!credential) {
|
||||
@@ -402,7 +405,7 @@ export default class EventManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.silly(
|
||||
log.silly(
|
||||
"No destination Calendar found, falling back to first connected calendar",
|
||||
safeStringify({
|
||||
calendarCredentials: this.calendarCredentials,
|
||||
@@ -416,7 +419,7 @@ export default class EventManager {
|
||||
const [credential] = this.calendarCredentials.filter((cred) => !cred.type.endsWith("other_calendar"));
|
||||
if (credential) {
|
||||
const createdEvent = await createEvent(credential, event);
|
||||
logger.silly("Created Calendar event", { createdEvent });
|
||||
log.silly("Created Calendar event", safeStringify({ createdEvent }));
|
||||
if (createdEvent) {
|
||||
createdEvents.push(createdEvent);
|
||||
}
|
||||
@@ -465,7 +468,7 @@ export default class EventManager {
|
||||
* @todo remove location from event types that has missing credentials
|
||||
* */
|
||||
if (!videoCredential) {
|
||||
logger.warn(
|
||||
log.warn(
|
||||
'Falling back to "daily" video integration for event with location: ' +
|
||||
event.location +
|
||||
" because credential is missing for the app"
|
||||
@@ -513,7 +516,7 @@ export default class EventManager {
|
||||
): Promise<Array<EventResult<NewCalendarEventType>>> {
|
||||
let calendarReference: PartialReference[] | undefined = undefined,
|
||||
credential;
|
||||
logger.silly("updateAllCalendarEvents", JSON.stringify({ event, booking, newBookingId }));
|
||||
log.silly("updateAllCalendarEvents", JSON.stringify({ event, booking, newBookingId }));
|
||||
try {
|
||||
// If a newBookingId is given, update that calendar event
|
||||
let newBooking;
|
||||
@@ -575,7 +578,7 @@ export default class EventManager {
|
||||
(credential) => credential.type === reference?.type
|
||||
);
|
||||
for (const credential of credentials) {
|
||||
logger.silly("updateAllCalendarEvents-credential", JSON.stringify({ credentials }));
|
||||
log.silly("updateAllCalendarEvents-credential", JSON.stringify({ credentials }));
|
||||
result.push(updateEvent(credential, event, bookingRefUid, calenderExternalId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user