Compare commits

...

14 Commits

Author SHA1 Message Date
GitStart-Cal.com 5e69e7c36b
Merge branch 'main' into regular-datee2e 2024-01-10 07:46:57 +05:45
GitStart-Cal.com 2b63315d04
Update regularBookings.ts 2024-01-09 14:55:17 -03:00
GitStart-Cal.com 44c2cd3fe0
Merge branch 'main' into regular-datee2e 2024-01-09 17:21:34 +05:45
GitStart-Cal.com 86811962ce
Merge branch 'main' into regular-datee2e 2024-01-09 08:43:35 +05:45
GitStart-Cal.com 30694b9444
Merge branch 'main' into regular-datee2e 2023-12-19 00:12:46 +05:45
GitStart-Cal.com 6288df3c7b
Merge branch 'main' into regular-datee2e 2023-12-18 23:52:16 +05:45
gitstart-calcom 9b4d6b04c1 reopening the pr 2023-12-15 11:57:04 +00:00
gitstart-calcom d02e6020dc Merge commit 'b778b2962a57479a6c87bc217baf3211f6230029' into regular-datee2e 2023-12-15 11:56:39 +00:00
gitstart-calcom 8a685f74da Add tests for date 2023-11-21 21:06:47 +00:00
gitstart-calcom 4935269ca5 Add tests for date 2023-11-21 20:59:04 +00:00
gitstart-calcom db778cf2a0 Merge commit '48dde246e92fd2ed94c84bf39389078ab9ec639a' into regular-datee2e 2023-11-21 20:57:41 +00:00
gitstart-calcom 788a088fe0 Create E2E tests to check if we have the correct Date/Time 2023-11-20 22:53:40 +00:00
gitstart-calcom 84ade52dc5 Create E2E tests to check if we have the correct Date/Time 2023-11-20 22:48:20 +00:00
gitstart-calcom 865100a29b Create E2E tests to check if we have the correct Date/Time 2023-11-20 22:42:55 +00:00
2 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,88 @@
import { loginUser } from "../fixtures/regularBookings";
import { test } from "../lib/fixtures";
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
const today = new Date();
function findDaysForTest(today: Date) {
const daysForTest: Date[] = [];
let currentDay = today.getDate() + 1;
const endOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0).getDate();
if (currentDay + 3 > endOfMonth) {
const firstDateOfNextMonth = new Date(today);
firstDateOfNextMonth.setMonth(firstDateOfNextMonth.getMonth() + 2, 1);
currentDay = firstDateOfNextMonth.getDate() + 1;
while (daysForTest.length < 3) {
currentDay++;
const dateForTest = new Date(
firstDateOfNextMonth.getFullYear(),
firstDateOfNextMonth.getMonth(),
currentDay
);
daysForTest.push(dateForTest);
}
return daysForTest;
} else {
while (daysForTest.length < 3) {
currentDay++;
const dateForTest = new Date(today.getFullYear(), today.getMonth(), currentDay);
daysForTest.push(dateForTest);
}
return daysForTest;
}
}
test.describe("Test the date behavior in specific cases", () => {
test.beforeEach(async ({ page, users, bookingPage }) => {
await loginUser(users);
await bookingPage.makeEveryDayAvailable();
await page.goto("/event-types");
});
test("test dates for booking", async ({ page, bookingPage }) => {
const daysForTest = findDaysForTest(today);
for (const day of daysForTest) {
await bookingPage.goToEventType("30 min");
const eventTypePage = await bookingPage.previewEventType();
const currentDayAbbrev = days[day.getDay()];
const currentMonthAbbrev = months[day.getMonth()];
const currentDay = day.getDate();
const currentPage = await bookingPage.createBookingForEachDate({
bookingPage: eventTypePage,
date: currentDay.toString(),
timezone: "America/New York",
isNextMonth: false,
});
const roleName = `${currentDayAbbrev}, ${currentDay} ${currentMonthAbbrev} 9:00am - 9:30am`;
await bookingPage.assertBookingDates(currentPage, roleName);
await page.goto("/event-types");
}
});
test("test dates near end of month for booking", async ({ page, bookingPage }) => {
const dayNearEnd = new Date(today.getFullYear(), 9, 28);
const daysForTest = findDaysForTest(dayNearEnd);
for (const day of daysForTest) {
await bookingPage.goToEventType("30 min");
const eventTypePage = await bookingPage.previewEventType();
const currentDayAbbrev = days[day.getDay()];
const currentMonthAbbrev = months[day.getMonth()];
const currentDay = day.getDate();
const currentPage = await bookingPage.createBookingForEachDate({
bookingPage: eventTypePage,
date: currentDay.toString(),
timezone: "America/New York",
isNextMonth: true,
});
const roleName = `${currentDayAbbrev}, ${currentDay} ${currentMonthAbbrev} 9:00am - 9:30am`;
await bookingPage.assertBookingDates(currentPage, roleName);
await page.goto("/event-types");
}
});
});

View File

@ -238,6 +238,13 @@ export function createBookingPageFixture(page: Page) {
.getByRole("spinbutton")
.fill(maxEvents);
},
makeEveryDayAvailable: async () => {
await page.goto("/availability");
await page.getByTestId("schedules").locator("div").first().click();
await page.locator("label").filter({ hasText: "Sunday" }).getByRole("switch").click();
await page.locator("label").filter({ hasText: "Saturday" }).getByRole("switch").click();
await page.getByRole("button", { name: "Save" }).click();
},
updateEventType: async () => {
await page.getByTestId("update-eventtype").click();
},
@ -246,6 +253,23 @@ export function createBookingPageFixture(page: Page) {
await page.getByTestId("preview-button").click();
return eventtypePromise;
},
createBookingForEachDate: async (options: {
bookingPage: Page;
date: string;
timezone: string;
isNextMonth?: boolean;
}) => {
const { bookingPage, date, isNextMonth } = options;
let { timezone } = options;
isNextMonth && (await bookingPage.getByTestId("incrementMonth").click());
await bookingPage.getByRole("button", { name: date, exact: true }).click();
await bookingPage.locator("span").filter({ hasText: "/" }).locator("svg").first().click();
timezone.includes(" ") && (timezone = timezone.replace(" ", "_"));
await bookingPage.getByTestId(`select-option-${timezone}`).click();
await bookingPage.getByTestId("time").first().click();
await bookingPage.getByTestId("confirm-book-button").click();
return bookingPage;
},
selectTimeSlot: async (eventTypePage: Page) => {
await goToNextMonthIfNoAvailabilities(eventTypePage);
await eventTypePage.getByTestId("time").first().click();
@ -304,6 +328,10 @@ export function createBookingPageFixture(page: Page) {
assertBookingRescheduled: async (page: Page) => {
await expect(page.getByText(scheduleSuccessfullyText)).toBeVisible();
},
assertBookingDates: async (currentPage: Page, roleName: string) => {
await currentPage.getByRole("link", { name: "Back to bookings" }).click();
await expect(currentPage.getByRole("link", { name: roleName })).toBeVisible();
},
assertRepeatEventType: async () => {
await expect(page.getByTestId("repeat-eventtype")).toBeVisible();
@ -387,5 +415,10 @@ export function createBookingPageFixture(page: Page) {
await scheduleSuccessfullyPage.waitFor({ state: "visible" });
await expect(scheduleSuccessfullyPage).toBeVisible();
},
checkUpdateTimezone: async () => {
if (await page.getByRole("button", { name: "Update timezone" }).isVisible()) {
page.getByRole("button", { name: "Update timezone" }).click();
}
},
};
}