test: Booking flow App failure and ics file tests and improved logging (#11646)

This commit is contained in:
Hariom Balhara authored and GitHub committed 2023-10-02 16:21:04 +05:30
1 parent 07bfaec24e
commit 3ca7456885
17 files changed
+513 -239

No files matched your search

+51 -5
View File
@@ -1,5 +1,6 @@
import type { Credential, SelectedCalendar } from "@prisma/client";
import type { Credential, SelectedCalendar, DestinationCalendar } from "@prisma/client";
import type { EventType } from "@calcom/prisma/client";
import type { CalendarEvent } from "@calcom/types/Calendar";
export function getPiiFreeCalendarEvent(calEvent: CalendarEvent) {
@@ -15,6 +16,7 @@ export function getPiiFreeCalendarEvent(calEvent: CalendarEvent) {
recurrence: calEvent.recurrence,
requiresConfirmation: calEvent.requiresConfirmation,
uid: calEvent.uid,
iCalUID: calEvent.iCalUID,
/**
* Let's just get a boolean value for PII sensitive fields so that we atleast know if it's present or not
*/
@@ -66,10 +68,54 @@ export function getPiiFreeSelectedCalendar(selectedCalendar: Partial<SelectedCal
return {
integration: selectedCalendar.integration,
userId: selectedCalendar.userId,
/**
* Let's just get a boolean value for PII sensitive fields so that we atleast know if it's present or not
*/
externalId: !!selectedCalendar.externalId,
// Get first 3 characters of externalId, so that we know what it could be but not the full value
externalId: selectedCalendar.externalId?.slice(0, 3),
credentialId: !!selectedCalendar.credentialId,
};
}
export function getPiiFreeDestinationCalendar(destinationCalendar: Partial<DestinationCalendar>) {
return {
integration: destinationCalendar.integration,
userId: destinationCalendar.userId,
/**
* Let's just get a boolean value for PII sensitive fields so that we atleast know if it's present or not
*/
externalId: !!destinationCalendar.externalId,
credentialId: !!destinationCalendar.credentialId,
};
}
export function getPiiFreeEventType(eventType: Partial<Omit<EventType, "recurringEvent">>) {
return {
id: eventType.id,
schedulingType: eventType.schedulingType,
seatsPerTimeSlot: eventType.seatsPerTimeSlot,
};
}
export function getPiiFreeUser(user: {
id?: number;
username?: string | null;
isFixed?: boolean;
timeZone?: string;
allowDynamicBooking?: boolean | null;
defaultScheduleId?: number | null;
organizationId?: number | null;
credentials?: Credential[];
destinationCalendar?: DestinationCalendar | null;
}) {
return {
id: user.id,
username: user.username,
isFixed: user.isFixed,
timeZone: user.timeZone,
allowDynamicBooking: user.allowDynamicBooking,
defaultScheduleId: user.defaultScheduleId,
organizationId: user.organizationId,
credentials: user.credentials?.map(getPiiFreeCredential),
destinationCalendar: user.destinationCalendar
? getPiiFreeDestinationCalendar(user.destinationCalendar)
: user.destinationCalendar,
};
}
+10 -9
View File
@@ -1,6 +1,7 @@
import logger from "@calcom/lib/logger";
import type { MembershipRole } from "@calcom/prisma/enums";
import { safeStringify } from "../safeStringify";
import type { ConsoleUserInfoType, TeamInfoType, WebUserInfoType } from "./ISyncService";
import services from "./services";
import CloseComService from "./services/CloseComService";
@@ -9,7 +10,7 @@ const log = logger.getChildLogger({ prefix: [`[[SyncServiceManager] `] });
export const createConsoleUser = async (user: ConsoleUserInfoType | null | undefined) => {
if (user) {
log.debug("createConsoleUser", { user });
log.debug("createConsoleUser", safeStringify({ user }));
try {
Promise.all(
services.map(async (serviceClass) => {
@@ -24,16 +25,16 @@ export const createConsoleUser = async (user: ConsoleUserInfoType | null | undef
})
);
} catch (e) {
log.warn("createConsoleUser", e);
log.warn("createConsoleUser", safeStringify({ error: e }));
}
} else {
log.warn("createConsoleUser:noUser", { user });
log.warn("createConsoleUser:noUser", safeStringify({ user }));
}
};
export const createWebUser = async (user: WebUserInfoType | null | undefined) => {
if (user) {
log.debug("createWebUser", { user });
log.debug("createWebUser", safeStringify({ user }));
try {
Promise.all(
services.map(async (serviceClass) => {
@@ -48,16 +49,16 @@ export const createWebUser = async (user: WebUserInfoType | null | undefined) =>
})
);
} catch (e) {
log.warn("createWebUser", e);
log.warn("createWebUser", safeStringify({ error: e }));
}
} else {
log.warn("createWebUser:noUser", { user });
log.warn("createWebUser:noUser", safeStringify({ user }));
}
};
export const updateWebUser = async (user: WebUserInfoType | null | undefined) => {
if (user) {
log.debug("updateWebUser", { user });
log.debug("updateWebUser", safeStringify({ user }));
try {
Promise.all(
services.map(async (serviceClass) => {
@@ -72,10 +73,10 @@ export const updateWebUser = async (user: WebUserInfoType | null | undefined) =>
})
);
} catch (e) {
log.warn("updateWebUser", e);
log.warn("updateWebUser", safeStringify({ error: e }));
}
} else {
log.warn("updateWebUser:noUser", { user });
log.warn("updateWebUser:noUser", safeStringify({ user }));
}
};
+4
View File
@@ -1,6 +1,10 @@
declare global {
// eslint-disable-next-line no-var
var testEmails: {
icalEvent?: {
filename: string;
content: string;
};
to: string;
from: string;
subject: string;