2022-05-14 03:02:10 +00:00
|
|
|
import { expect } from "@playwright/test";
|
2021-10-13 13:26:56 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
import { test } from "./lib/fixtures";
|
2022-03-24 17:32:28 +00:00
|
|
|
import {
|
2022-04-06 17:20:30 +00:00
|
|
|
bookFirstEvent,
|
2022-10-27 09:34:34 +00:00
|
|
|
bookOptinEvent,
|
2022-04-06 17:20:30 +00:00
|
|
|
bookTimeSlot,
|
2022-03-24 17:32:28 +00:00
|
|
|
selectFirstAvailableTimeSlotNextMonth,
|
|
|
|
selectSecondAvailableTimeSlotNextMonth,
|
|
|
|
} from "./lib/testUtils";
|
|
|
|
|
2022-05-11 18:03:22 +00:00
|
|
|
test.describe.configure({ mode: "parallel" });
|
|
|
|
|
2021-12-15 16:25:49 +00:00
|
|
|
test.describe("free user", () => {
|
2022-05-14 03:02:10 +00:00
|
|
|
test.beforeEach(async ({ page, users }) => {
|
|
|
|
const free = await users.create({ plan: "FREE" });
|
|
|
|
await page.goto(`/${free.username}`);
|
2021-12-15 16:25:49 +00:00
|
|
|
});
|
2022-05-14 03:02:10 +00:00
|
|
|
test.afterEach(async ({ users }) => {
|
|
|
|
await users.deleteAll();
|
2022-03-07 17:55:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("cannot book same slot multiple times", async ({ page }) => {
|
|
|
|
// Click first event type
|
|
|
|
await page.click('[data-testid="event-type-link"]');
|
2022-03-08 22:40:31 +00:00
|
|
|
|
|
|
|
await selectFirstAvailableTimeSlotNextMonth(page);
|
2022-03-07 17:55:24 +00:00
|
|
|
|
|
|
|
// Navigate to book page
|
|
|
|
await page.waitForNavigation({
|
|
|
|
url(url) {
|
|
|
|
return url.pathname.endsWith("/book");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// save booking url
|
|
|
|
const bookingUrl: string = page.url();
|
|
|
|
|
|
|
|
// book same time spot twice
|
2022-03-23 22:00:30 +00:00
|
|
|
await bookTimeSlot(page);
|
2022-03-07 17:55:24 +00:00
|
|
|
|
|
|
|
// Make sure we're navigated to the success page
|
2022-05-11 16:46:52 +00:00
|
|
|
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
2022-03-07 17:55:24 +00:00
|
|
|
|
|
|
|
// return to same time spot booking page
|
|
|
|
await page.goto(bookingUrl);
|
|
|
|
|
|
|
|
// book same time spot again
|
2022-03-23 22:00:30 +00:00
|
|
|
await bookTimeSlot(page);
|
2022-03-07 17:55:24 +00:00
|
|
|
|
|
|
|
// check for error message
|
|
|
|
await expect(page.locator("[data-testid=booking-fail]")).toBeVisible();
|
|
|
|
});
|
2021-10-13 13:26:56 +00:00
|
|
|
});
|
|
|
|
|
2021-12-15 16:25:49 +00:00
|
|
|
test.describe("pro user", () => {
|
2022-05-14 03:02:10 +00:00
|
|
|
test.beforeEach(async ({ page, users }) => {
|
|
|
|
const pro = await users.create();
|
|
|
|
await page.goto(`/${pro.username}`);
|
2021-12-15 16:25:49 +00:00
|
|
|
});
|
2022-05-14 03:02:10 +00:00
|
|
|
test.afterEach(async ({ users }) => {
|
|
|
|
await users.deleteAll();
|
2022-03-07 17:55:24 +00:00
|
|
|
});
|
|
|
|
|
2021-12-15 16:25:49 +00:00
|
|
|
test("pro user's page has at least 2 visible events", async ({ page }) => {
|
2022-03-17 19:36:11 +00:00
|
|
|
// await page.pause();
|
2022-05-11 20:36:38 +00:00
|
|
|
const $eventTypes = page.locator("[data-testid=event-types] > *");
|
2022-03-17 19:36:11 +00:00
|
|
|
expect(await $eventTypes.count()).toBeGreaterThanOrEqual(2);
|
2021-10-13 13:26:56 +00:00
|
|
|
});
|
|
|
|
|
2021-12-15 16:25:49 +00:00
|
|
|
test("book an event first day in next month", async ({ page }) => {
|
2022-05-12 03:07:22 +00:00
|
|
|
await bookFirstEvent(page);
|
2021-11-15 15:03:04 +00:00
|
|
|
});
|
2022-05-12 03:07:22 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
test("can reschedule a booking", async ({ page, users, bookings }) => {
|
|
|
|
const [pro] = users.get();
|
|
|
|
const [eventType] = pro.eventTypes;
|
|
|
|
await bookings.create(pro.id, pro.username, eventType.id);
|
2022-03-24 17:32:28 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
await pro.login();
|
2022-03-24 17:32:28 +00:00
|
|
|
await page.goto("/bookings/upcoming");
|
2022-11-26 13:41:24 +00:00
|
|
|
await page.waitForSelector('[data-testid="bookings"]');
|
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-03-24 17:32:28 +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-29 20:27:29 +00:00
|
|
|
return url.pathname.startsWith("/booking");
|
2022-03-24 17:32:28 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2021-12-13 23:10:10 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
test("Can cancel the recently created booking and rebook the same timeslot", async ({ page, users }) => {
|
2022-03-24 17:32:28 +00:00
|
|
|
await bookFirstEvent(page);
|
2021-12-13 23:10:10 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
const [pro] = users.get();
|
|
|
|
await pro.login();
|
|
|
|
|
2022-03-24 17:32:28 +00:00
|
|
|
await page.goto("/bookings/upcoming");
|
2022-04-05 08:05:40 +00:00
|
|
|
await page.locator('[data-testid="cancel"]').first().click();
|
2022-03-24 17:32:28 +00:00
|
|
|
await page.waitForNavigation({
|
|
|
|
url: (url) => {
|
2022-11-29 20:27:29 +00:00
|
|
|
return url.pathname.startsWith("/booking");
|
2022-03-24 17:32:28 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
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-11-25 14:49:59 +00:00
|
|
|
|
2022-05-14 03:02:10 +00:00
|
|
|
await page.goto(`/${pro.username}`);
|
2022-04-14 15:01:38 +00:00
|
|
|
await bookFirstEvent(page);
|
2022-03-24 17:32:28 +00:00
|
|
|
});
|
2022-10-27 09:34:34 +00:00
|
|
|
|
|
|
|
test("can book an event that requires confirmation and then that booking can be accepted by organizer", async ({
|
|
|
|
page,
|
|
|
|
users,
|
|
|
|
}) => {
|
|
|
|
await bookOptinEvent(page);
|
|
|
|
const [pro] = users.get();
|
|
|
|
await pro.login();
|
|
|
|
|
|
|
|
await page.goto("/bookings/unconfirmed");
|
|
|
|
await Promise.all([
|
|
|
|
page.click('[data-testid="confirm"]'),
|
|
|
|
page.waitForResponse((response) => response.url().includes("/api/trpc/viewer.bookings.confirm")),
|
|
|
|
]);
|
|
|
|
// This is the only booking in there that needed confirmation and now it should be empty screen
|
|
|
|
await expect(page.locator('[data-testid="empty-screen"]')).toBeVisible();
|
|
|
|
});
|
2021-10-13 13:26:56 +00:00
|
|
|
});
|