Scheduling infrastructure for absolutely everyone.
fix: multiple organizer address bug (#11299)
Udit Takkar9eb3698ea596
diff --git a/apps/web/pages/booking/[uid].tsx b/apps/web/pages/booking/[uid].tsxindex a77dc76965f..9d1e163c9bd 100644--- a/apps/web/pages/booking/[uid].tsx+++ b/apps/web/pages/booking/[uid].tsx@@ -461,7 +461,7 @@ export default function Success(props: SuccessProps) {{locationToDisplay && !isCancelled && (<><div className="mt-3 font-medium">{t("where")}</div>- <div className="col-span-2 mt-3">+ <div className="col-span-2 mt-3" data-testid="where">{locationToDisplay.startsWith("http") ? (<ahref={locationToDisplay}diff --git a/apps/web/playwright/event-types.e2e.ts b/apps/web/playwright/event-types.e2e.tsindex 8851a3c859b..a5af946dda3 100644--- a/apps/web/playwright/event-types.e2e.ts+++ b/apps/web/playwright/event-types.e2e.ts@@ -142,17 +142,25 @@ test.describe("Event Types tests", () => {.first().getAttribute("href");+ /**+ * Verify first organizer address+ */await page.goto(previewLink ?? "");-await selectFirstAvailableTimeSlotNextMonth(page);-- for (const location of locationData) {- await page.locator(`span:has-text("${location}")`).click();- }-+ await page.locator(`span:has-text("${locationData[0]}")`).click();await bookTimeSlot(page);+ await expect(page.locator("[data-testid=success-page]")).toBeVisible();+ await expect(page.locator(`[data-testid="where"]`)).toHaveText(locationData[0]);+ /**+ * Verify second organizer address+ */+ await page.goto(previewLink ?? "");+ await selectFirstAvailableTimeSlotNextMonth(page);+ await page.locator(`span:has-text("${locationData[1]}")`).click();+ await bookTimeSlot(page);await expect(page.locator("[data-testid=success-page]")).toBeVisible();+ await expect(page.locator(`[data-testid="where"]`)).toHaveText(locationData[1]);});test.describe("Different Locations Tests", () => {diff --git a/packages/features/bookings/lib/handleNewBooking.test.ts b/packages/features/bookings/lib/handleNewBooking.test.tsindex a2fb67a0ea5..3832ea172c4 100644--- a/packages/features/bookings/lib/handleNewBooking.test.ts+++ b/packages/features/bookings/lib/handleNewBooking.test.ts@@ -470,6 +470,128 @@ describe.sequential("handleNewBooking", () => {},timeout);+ test(+ `should create a successful booking when location is provided as label of an option(Done for Organizer Address)+ 1. Should create a booking in the database+ 2. Should send emails to the booker as well as organizer+ 3. Should trigger BOOKING_CREATED webhook+ `,+ async ({ emails }) => {+ const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;+ const booker = getBooker({+ email: "[email protected]",+ name: "Booker",+ });++ const organizer = getOrganizer({+ name: "Organizer",+ email: "[email protected]",+ id: 101,+ schedules: [TestData.schedules.IstWorkHours],+ credentials: [getGoogleCalendarCredential()],+ selectedCalendars: [TestData.selectedCalendars.google],+ });++ const mockBookingData = getMockRequestDataForBooking({+ data: {+ eventTypeId: 1,+ responses: {+ email: booker.email,+ name: booker.name,+ location: { optionValue: "", value: "New York" },+ },+ },+ });++ const { req } = createMockNextJsRequest({+ method: "POST",+ body: mockBookingData,+ });++ const scenarioData = getScenarioData({+ webhooks: [+ {+ userId: organizer.id,+ eventTriggers: ["BOOKING_CREATED"],+ subscriberUrl: "http://my-webhook.example.com",+ active: true,+ eventTypeId: 1,+ appId: null,+ },+ ],+ eventTypes: [+ {+ id: 1,+ slotInterval: 45,+ length: 45,+ users: [+ {+ id: 101,+ },+ ],+ },+ ],+ organizer,+ apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]],+ });++ mockCalendarToHaveNoBusySlots("googlecalendar");+ createBookingScenario(scenarioData);++ const createdBooking = await handleNewBooking(req);+ expect(createdBooking.responses).toContain({+ email: booker.email,+ name: booker.name,+ });++ expect(createdBooking).toContain({+ location: "New York",+ });++ expectBookingToBeInDatabase({+ description: "",+ eventType: {+ connect: {+ id: mockBookingData.eventTypeId,+ },+ },+ status: BookingStatus.ACCEPTED,+ });++ expectWorkflowToBeTriggered();++ const testEmails = emails.get();+ expect(testEmails[0]).toHaveEmail({+ htmlToContain: "<title>confirmed_event_type_subject</title>",+ to: `${organizer.email}`,+ });+ expect(testEmails[1]).toHaveEmail({+ htmlToContain: "<title>confirmed_event_type_subject</title>",+ to: `${booker.name} <${booker.email}>`,+ });+ expect(testEmails[1].html).toContain("<title>confirmed_event_type_subject</title>");+ expectWebhookToHaveBeenCalledWith("http://my-webhook.example.com", {+ triggerEvent: "BOOKING_CREATED",+ payload: {+ metadata: {+ },+ responses: {+ name: { label: "your_name", value: "Booker" },+ email: { label: "email_address", value: "[email protected]" },+ location: {+ label: "location",+ value: { optionValue: "", value: "New York" },+ },+ title: { label: "what_is_this_meeting_about" },+ notes: { label: "additional_notes" },+ guests: { label: "additional_guests" },+ rescheduleReason: { label: "reason_for_reschedule" },+ },+ },+ });+ },+ timeout+ );});});diff --git a/packages/features/form-builder/FormBuilderField.tsx b/packages/features/form-builder/FormBuilderField.tsxindex f75f876611d..e311713620a 100644--- a/packages/features/form-builder/FormBuilderField.tsx+++ b/packages/features/form-builder/FormBuilderField.tsx@@ -311,6 +311,10 @@ export const ComponentForField = ({if (!field.optionsInputs) {throw new Error("Field optionsInputs is not defined");}+ const options = field.options.map((field) => {+ return { ...field, value: field.value === "inPerson" ? field.label : field.value };+ });+return field.options.length ? (<WithLabel field={field} readOnly={readOnly}><componentConfig.factory@@ -320,7 +324,7 @@ export const ComponentForField = ({value={value as { value: string; optionValue: string }}setValue={setValue as (arg: typeof value) => void}optionsInputs={field.optionsInputs}- options={field.options}+ options={options}required={field.required}/></WithLabel>