Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rescheduling daily #13736

Merged
merged 36 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8037bc4
fix: rescheduling daily
Udit-takkar Feb 16, 2024
b47a858
fix: e2e test
Udit-takkar Feb 19, 2024
9128688
Merge branch 'main' into fix/reschedule
CarinaWolli Feb 19, 2024
48221a8
Merge branch 'main' into fix/reschedule
Udit-takkar Feb 20, 2024
4196e7c
Merge branch 'main' into fix/reschedule
Udit-takkar Feb 20, 2024
c93d7e3
Merge branch 'main' into fix/reschedule
keithwillcode Feb 20, 2024
1d02921
Merge branch 'main' into fix/reschedule
Udit-takkar Feb 21, 2024
c486010
Merge branch 'main' into fix/reschedule
CarinaWolli Feb 21, 2024
dcfe9ec
Merge branch 'main' into fix/reschedule
Udit-takkar Feb 22, 2024
d3a049d
Merge branch 'main' into fix/reschedule
Udit-takkar Feb 22, 2024
4cbe0ba
Merge branch 'main' into fix/reschedule
CarinaWolli Feb 26, 2024
14fa4d7
Merge branch 'main' into fix/reschedule
keithwillcode Feb 27, 2024
58cf39f
Merge branch 'main' into fix/reschedule
Udit-takkar Feb 28, 2024
bf24bbd
chore: test
Udit-takkar Feb 28, 2024
b5d7709
Merge branch 'main' into fix/reschedule
Udit-takkar Feb 28, 2024
eab6618
Merge branch 'main' into fix/reschedule
CarinaWolli Feb 28, 2024
cb07be5
add location to default event type
Feb 28, 2024
3bab50c
Merge branch 'main' into fix/reschedule
CarinaWolli Feb 29, 2024
0dfe92d
revert fix
Feb 29, 2024
1732da5
chore: add env variable
Udit-takkar Feb 29, 2024
0913194
Merge branch 'main' into fix/reschedule
keithwillcode Feb 29, 2024
a638f51
fix: sort alphabetically
Udit-takkar Mar 1, 2024
c86455a
test: checking
Udit-takkar Mar 1, 2024
8dab87c
chore: use another user
Udit-takkar Mar 1, 2024
1dce2e3
Merge branch 'main' into fix/reschedule
Udit-takkar Mar 14, 2024
1ce64c5
chore: try adding location
Udit-takkar Mar 14, 2024
d9f572c
chore: undo
Udit-takkar Mar 14, 2024
020047c
Merge branch 'main' into fix/reschedule
Udit-takkar Mar 15, 2024
2edd434
chore: add variable
Udit-takkar Mar 15, 2024
7c9bca7
Merge branch 'main' into fix/reschedule
zomars Mar 15, 2024
f20bf06
Merge branch 'main' into fix/reschedule
Udit-takkar Apr 13, 2024
cff0bff
chore: commented
Udit-takkar Apr 13, 2024
d0bb068
F
Udit-takkar Apr 13, 2024
e727a1d
chore: comment
Udit-takkar Apr 13, 2024
b676e80
test: add unit test
Udit-takkar Apr 13, 2024
f22d6e3
fix: type err
Udit-takkar Apr 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e-app-store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
env:
ALLOWED_HOSTNAMES: ${{ vars.CI_ALLOWED_HOSTNAMES }}
CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}
DAILY_API_KEY: ${{ secrets.CI_DAILY_API_KEY }}
DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}
DATABASE_DIRECT_URL: ${{ secrets.CI_DATABASE_URL }}
DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-embed-react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
env:
ALLOWED_HOSTNAMES: ${{ vars.CI_ALLOWED_HOSTNAMES }}
CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}
DAILY_API_KEY: ${{ secrets.CI_DAILY_API_KEY }}
DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}
DATABASE_DIRECT_URL: ${{ secrets.CI_DATABASE_URL }}
DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-embed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
env:
ALLOWED_HOSTNAMES: ${{ vars.CI_ALLOWED_HOSTNAMES }}
CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}
DAILY_API_KEY: ${{ secrets.CI_DAILY_API_KEY }}
DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}
DATABASE_DIRECT_URL: ${{ secrets.CI_DATABASE_URL }}
DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
env:
ALLOWED_HOSTNAMES: ${{ vars.CI_ALLOWED_HOSTNAMES }}
CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}
DAILY_API_KEY: ${{ secrets.CI_DAILY_API_KEY }}
DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}
DATABASE_DIRECT_URL: ${{ secrets.CI_DATABASE_URL }}
DEPLOYSENTINEL_API_KEY: ${{ secrets.DEPLOYSENTINEL_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/production-build-without-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
env:
ALLOWED_HOSTNAMES: ${{ vars.CI_ALLOWED_HOSTNAMES }}
CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}
DAILY_API_KEY: ${{ secrets.CI_DAILY_API_KEY }}
DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}
DATABASE_DIRECT_URL: ${{ secrets.CI_DATABASE_URL }}
E2E_TEST_APPLE_CALENDAR_EMAIL: ${{ secrets.E2E_TEST_APPLE_CALENDAR_EMAIL }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/production-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
env:
ALLOWED_HOSTNAMES: ${{ vars.CI_ALLOWED_HOSTNAMES }}
CALENDSO_ENCRYPTION_KEY: ${{ secrets.CI_CALENDSO_ENCRYPTION_KEY }}
DAILY_API_KEY: ${{ secrets.CI_DAILY_API_KEY }}
DATABASE_URL: ${{ secrets.CI_DATABASE_URL }}
DATABASE_DIRECT_URL: ${{ secrets.CI_DATABASE_URL }}
E2E_TEST_APPLE_CALENDAR_EMAIL: ${{ secrets.E2E_TEST_APPLE_CALENDAR_EMAIL }}
Expand Down
10 changes: 5 additions & 5 deletions apps/web/pages/auth/verify-email-change.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ function VerifyEmailChange(props: PageProps) {
const router = useRouter();

useEffect(() => {
async function updateSession() {
async function updateSessionAndDisplayToast() {
await update({ email: props.updatedEmail });
router.push("/event-types");
}
if (props.updateSession) {
updateSession();
if (isLocaleReady) {
showToast(t("verify_email_change_success_toast", { email: props.updatedEmail }), "success");
}
router.push("/event-types");
}
if (props.updateSession) {
updateSessionAndDisplayToast();
} else {
if (isLocaleReady) {
showToast(t("verify_email_change_failure_toast"), "error");
Expand Down
8 changes: 1 addition & 7 deletions apps/web/playwright/booking-pages.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
bookFirstEvent,
bookOptinEvent,
bookTimeSlot,
expectEmailsToHaveSubject,
selectFirstAvailableTimeSlotNextMonth,
testEmail,
testName,
Expand Down Expand Up @@ -62,6 +61,7 @@ testBothFutureAndLegacyRoutes.describe("free user", () => {

test("cannot book same slot multiple times", async ({ page, users, emails }) => {
const [user] = users.get();

const bookerObj = {
email: users.trackEmail({ username: "testEmail", domain: "example.com" }),
name: "testBooker",
Expand All @@ -80,12 +80,6 @@ testBothFutureAndLegacyRoutes.describe("free user", () => {
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
const { title: eventTitle } = await user.getFirstEventAsOwner();

await expectEmailsToHaveSubject({
emails,
organizer: user,
booker: bookerObj,
eventTitle,
});
Comment on lines -83 to -88
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works fine locally but fails on CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a new unit test instead "cannot book same slot multiple times" in fresh-booking to make sure which would check the email has been delivered to both booker and organizer

await page.goto(bookingUrl);

// book same time spot again
Expand Down
6 changes: 6 additions & 0 deletions packages/app-store/locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export const getLocationValueForDB = (
) => {
let bookingLocation = bookingLocationTypeOrValue;
let conferenceCredentialId = undefined;

eventLocations.forEach((location) => {
if (location.type === bookingLocationTypeOrValue) {
const eventLocationType = getEventLocationType(bookingLocationTypeOrValue);
Expand All @@ -362,6 +363,11 @@ export const getLocationValueForDB = (
bookingLocation = location[eventLocationType.defaultValueVariable] || bookingLocation;
}
});

if (bookingLocation.trim().length === 0) {
bookingLocation = DailyLocationType;
}

return { bookingLocation, conferenceCredentialId };
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,150 @@ describe("handleNewBooking", () => {
},
timeout
);
test(
`cannot book same slot multiple times `,
async ({ emails }) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
});

const organizerOtherEmail = "organizer2@example.com";
const organizerDestinationCalendarEmailOnEventType = "organizerEventTypeEmail@example.com";

const organizer = getOrganizer({
name: "Organizer",
email: "organizer@example.com",
id: 101,
schedules: [TestData.schedules.IstWorkHours],
credentials: [getGoogleCalendarCredential()],
selectedCalendars: [TestData.selectedCalendars.google],
destinationCalendar: {
integration: "google_calendar",
externalId: "organizer@google-calendar.com",
primaryEmail: organizerOtherEmail,
},
});

await createBookingScenario(
getScenarioData({
eventTypes: [
{
id: 1,
slotInterval: 30,
length: 30,
useEventTypeDestinationCalendarEmail: true,
users: [
{
id: 101,
},
],
destinationCalendar: {
integration: "google_calendar",
externalId: "event-type-1@google-calendar.com",
primaryEmail: organizerDestinationCalendarEmailOnEventType,
},
},
],
organizer,
apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]],
})
);

mockSuccessfulVideoMeetingCreation({
metadataLookupKey: "dailyvideo",
videoMeetingData: {
id: "MOCK_ID",
password: "MOCK_PASS",
url: `http://mock-dailyvideo.example.com/meeting-1`,
},
});

const calendarMock = mockCalendarToHaveNoBusySlots("googlecalendar", {
create: {
id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID",
},
});

const mockBookingData = getMockRequestDataForBooking({
data: {
user: organizer.username,
eventTypeId: 1,
responses: {
email: booker.email,
name: booker.name,
location: { optionValue: "", value: BookingLocations.CalVideo },
},
},
});

const { req } = createMockNextJsRequest({
method: "POST",
body: mockBookingData,
});

const createdBooking = await handleNewBooking(req);

expect(createdBooking.responses).toContain({
email: booker.email,
name: booker.name,
});

expect(createdBooking).toContain({
location: BookingLocations.CalVideo,
});

await expectBookingToBeInDatabase({
description: "",
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
uid: createdBooking.uid!,
eventTypeId: mockBookingData.eventTypeId,
status: BookingStatus.ACCEPTED,
references: [
{
type: appStoreMetadata.dailyvideo.type,
uid: "MOCK_ID",
meetingId: "MOCK_ID",
meetingPassword: "MOCK_PASS",
meetingUrl: "http://mock-dailyvideo.example.com/meeting-1",
},
{
type: appStoreMetadata.googlecalendar.type,
uid: "MOCKED_GOOGLE_CALENDAR_EVENT_ID",
meetingId: "MOCKED_GOOGLE_CALENDAR_EVENT_ID",
meetingPassword: "MOCK_PASSWORD",
meetingUrl: "https://UNUSED_URL",
},
],
iCalUID: createdBooking.iCalUID,
});

expectSuccessfulCalendarEventCreationInCalendar(calendarMock, {
calendarId: "event-type-1@google-calendar.com",
videoCallUrl: "http://mock-dailyvideo.example.com/meeting-1",
});

const iCalUID = expectICalUIDAsString(createdBooking.iCalUID);

expectSuccessfulBookingCreationEmails({
booking: {
uid: createdBooking.uid!,
urlOrigin: WEBSITE_URL,
},
booker,
organizer,
emails,
iCalUID,
destinationEmail: organizerDestinationCalendarEmailOnEventType,
});

await expect(async () => await handleNewBooking(req)).rejects.toThrowError(
ErrorCode.NoAvailableUsersFound
);
},
timeout
);
});
});

Expand Down