Apply suggestions from code review

pull/11044/head
Hariom Balhara 2023-09-02 14:30:33 +05:30
parent e457c13906
commit eb35edce74
6 changed files with 13 additions and 13 deletions

View File

@ -14,6 +14,7 @@ import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
import logger from "@calcom/lib/logger";
import type { SchedulingType } from "@calcom/prisma/enums";
import type { BookingStatus } from "@calcom/prisma/enums";
import type { EventBusyDate } from "@calcom/types/Calendar";
import type { Fixtures } from "@calcom/web/test/fixtures/fixtures";
import appStoreMock from "../../../../tests/libs/__mocks__/app-store";
@ -568,8 +569,9 @@ export function mockNoTranslations() {
});
}
export function mockCalendarToHaveNoBusySlots(metadataLookupKey: string) {
appStoreMock.default[metadataLookupKey].mockResolvedValue({
export function mockCalendarToHaveNoBusySlots(metadataLookupKey: keyof typeof appStoreMetadata) {
const appStoreLookupKey = metadataLookupKey;
appStoreMock.default[appStoreLookupKey as keyof typeof appStoreMock.default].mockResolvedValue({
lib: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
@ -583,7 +585,7 @@ export function mockCalendarToHaveNoBusySlots(metadataLookupKey: string) {
url: "http://dailyvideo.example.com",
});
},
getAvailability: (...args): Promise<EventBusyDate[]> => {
getAvailability: (): Promise<EventBusyDate[]> => {
return new Promise((resolve) => {
resolve([]);
});
@ -612,7 +614,6 @@ export function mockSuccessfulVideoMeetingCreation({
//@ts-ignore
VideoApiAdapter: () => ({
createMeeting: () => {
console.log("CALLING MOCKED DAILY");
return Promise.resolve({
type: appStoreMetadata[metadataLookupKey as keyof typeof appStoreMetadata].type,
id: "MOCK_ID",
@ -658,7 +659,7 @@ export function expectWebhookToHaveBeenCalledWith(
subscriberUrl: string,
data: {
triggerEvent: WebhookTriggerEvents;
payload: { metadata: any; responses: any };
payload: { metadata: Record<string, unknown>; responses: Record<string, unknown> };
}
) {
const fetchCalls = fetchMock.mock.calls;

View File

@ -10,7 +10,6 @@ import { appKeysSchema as calVideoKeysSchema } from "@calcom/app-store/dailyvide
import { getEventLocationTypeFromApp } from "@calcom/app-store/locations";
import { MeetLocationType } from "@calcom/app-store/locations";
import getApps from "@calcom/app-store/utils";
import logger from "@calcom/lib/logger";
import prisma from "@calcom/prisma";
import { createdEventSchema } from "@calcom/prisma/zod-utils";
import type { NewCalendarEventType } from "@calcom/types/Calendar";
@ -121,13 +120,13 @@ export default class EventManager {
evt["location"] = "integrations:daily";
}
const isDedicated = evt.location ? isDedicatedIntegration(evt.location) : null;
const results: Array<EventResult<Exclude<Event, AdditionalInformation>>> = [];
// If and only if event type is a dedicated meeting, create a dedicated video meeting.
if (isDedicated) {
const result = await this.createVideoEvent(evt);
if (result?.createdEvent) {
evt.videoCallData = result.createdEvent;
evt.location = result.originalEvent.location;

View File

@ -27,6 +27,7 @@ const getVideoAdapters = async (withCredentials: CredentialPayload[]): Promise<V
// Static Link Video Apps don't exist in packages/app-store/index.ts(it's manually maintained at the moment) and they aren't needed there anyway.
const app = appImportFn ? await appImportFn() : null;
if (!app) {
log.error(`Couldn't get adapter for ${appName}`);
continue;
@ -95,6 +96,7 @@ const createMeeting = async (credential: CredentialWithAppName, calEvent: Calend
} catch (err) {
await sendBrokenIntegrationEmail(calEvent, "video");
console.error("createMeeting failed", err, calEvent);
// Default to calVideo
const defaultMeeting = await createMeetingWithCalVideo(calEvent);
if (defaultMeeting) {

View File

@ -42,7 +42,7 @@ export default class BaseEmail {
console.log(
"Skipped Sending Email as process.env.NEXT_PUBLIC_UNIT_TESTS is set. Emails are available in globalThis.testEmails"
);
return new Promise((r) => r("Skipped sendEmail for E2E"));
return new Promise((r) => r("Skipped sendEmail for Unit Tests"));
}
const payload = this.getNodeMailerPayload();

View File

@ -983,9 +983,6 @@ async function handler(
}
: getLocationValueForDB(locationBodyString, eventType.locations);
console.log("handleNewBooking", {
bookingLocation,
});
const customInputs = getCustomInputsResponses(reqBody, eventType.customInputs);
const teamDestinationCalendars: DestinationCalendar[] = [];

View File

@ -309,6 +309,7 @@
"ZOHOCRM_CLIENT_ID",
"ZOHOCRM_CLIENT_SECRET",
"ZOOM_CLIENT_ID",
"ZOOM_CLIENT_SECRET"
"ZOOM_CLIENT_SECRET",
"NEXT_PUBLIC_UNIT_TESTS"
]
}