2022-05-14 03:02:10 +00:00
|
|
|
import { expect } from "@playwright/test";
|
2022-04-06 17:20:30 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
import { test } from "./lib/fixtures";
|
2022-04-06 17:20:30 +00:00
|
|
|
import {
|
|
|
|
bookTimeSlot,
|
|
|
|
selectFirstAvailableTimeSlotNextMonth,
|
|
|
|
selectSecondAvailableTimeSlotNextMonth,
|
|
|
|
} from "./lib/testUtils";
|
|
|
|
|
2022-09-12 20:26:42 +00:00
|
|
|
test("dynamic booking", async ({ page, users }) => {
|
|
|
|
const pro = await users.create();
|
|
|
|
await pro.login();
|
|
|
|
const free = await users.create({ plan: "FREE" });
|
|
|
|
await page.goto(`/${pro.username}+${free.username}`);
|
2022-05-11 20:36:38 +00:00
|
|
|
|
2022-09-12 20:26:42 +00:00
|
|
|
await test.step("book an event first day in next month", async () => {
|
2022-04-06 17:20:30 +00:00
|
|
|
// Click first event type
|
|
|
|
await page.click('[data-testid="event-type-link"]');
|
|
|
|
await selectFirstAvailableTimeSlotNextMonth(page);
|
|
|
|
await bookTimeSlot(page);
|
2022-05-11 04:46:22 +00:00
|
|
|
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
2022-04-06 17:20:30 +00:00
|
|
|
});
|
|
|
|
|
2022-09-12 20:26:42 +00:00
|
|
|
await test.step("can reschedule a booking", async () => {
|
2022-04-06 17:20:30 +00:00
|
|
|
// Logged in
|
|
|
|
await page.goto("/bookings/upcoming");
|
2022-05-27 23:27:41 +00:00
|
|
|
await page.locator('[data-testid="edit_booking"]').nth(0).click();
|
|
|
|
await page.locator('[data-testid="reschedule"]').click();
|
2022-04-06 17:20:30 +00:00
|
|
|
await page.waitForNavigation({
|
|
|
|
url: (url) => {
|
|
|
|
const bookingId = url.searchParams.get("rescheduleUid");
|
|
|
|
return !!bookingId;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
await selectSecondAvailableTimeSlotNextMonth(page);
|
|
|
|
// --- fill form
|
|
|
|
await page.locator('[data-testid="confirm-reschedule-button"]').click();
|
|
|
|
await page.waitForNavigation({
|
|
|
|
url(url) {
|
2022-11-15 19:00:02 +00:00
|
|
|
return url.pathname === "/success";
|
2022-04-06 17:20:30 +00:00
|
|
|
},
|
|
|
|
});
|
2022-05-11 04:46:22 +00:00
|
|
|
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
2022-04-06 17:20:30 +00:00
|
|
|
});
|
|
|
|
|
2022-09-12 20:26:42 +00:00
|
|
|
await test.step("Can cancel the recently created booking", async () => {
|
2022-04-06 17:20:30 +00:00
|
|
|
await page.goto("/bookings/upcoming");
|
|
|
|
await page.locator('[data-testid="cancel"]').first().click();
|
|
|
|
await page.waitForNavigation({
|
|
|
|
url: (url) => {
|
2022-11-16 19:48:17 +00:00
|
|
|
return url.pathname.startsWith("/success");
|
2022-04-06 17:20:30 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
// --- fill form
|
|
|
|
await page.locator('[data-testid="cancel"]').click();
|
2022-11-25 14:49:59 +00:00
|
|
|
|
2022-11-28 15:27:07 +00:00
|
|
|
const cancelledHeadline = await page.locator('[data-testid="cancelled-headline"]').innerText();
|
2022-11-25 14:49:59 +00:00
|
|
|
|
2022-11-28 15:27:07 +00:00
|
|
|
await expect(cancelledHeadline).toBe("This event is cancelled");
|
2022-04-06 17:20:30 +00:00
|
|
|
});
|
2022-09-12 20:26:42 +00:00
|
|
|
|
|
|
|
await users.deleteAll();
|
2022-04-06 17:20:30 +00:00
|
|
|
});
|