Compare commits
14 Commits
main
...
regular-da
Author | SHA1 | Date | |
---|---|---|---|
|
5e69e7c36b | ||
|
2b63315d04 | ||
|
44c2cd3fe0 | ||
|
86811962ce | ||
|
30694b9444 | ||
|
6288df3c7b | ||
|
9b4d6b04c1 | ||
|
d02e6020dc | ||
|
8a685f74da | ||
|
4935269ca5 | ||
|
db778cf2a0 | ||
|
788a088fe0 | ||
|
84ade52dc5 | ||
|
865100a29b |
|
@ -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");
|
||||
}
|
||||
});
|
||||
});
|
|
@ -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();
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user