61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import { expect } from "@playwright/test";
|
|
|
|
import { test } from "./lib/fixtures";
|
|
import {
|
|
bookTimeSlot,
|
|
selectFirstAvailableTimeSlotNextMonth,
|
|
selectSecondAvailableTimeSlotNextMonth,
|
|
} from "./lib/testUtils";
|
|
|
|
test.afterEach(({ users }) => users.deleteAll());
|
|
|
|
test("dynamic booking", async ({ page, users }) => {
|
|
const pro = await users.create();
|
|
await pro.apiLogin();
|
|
|
|
const free = await users.create({ username: "free.example" });
|
|
await page.goto(`/${pro.username}+${free.username}`);
|
|
|
|
await test.step("book an event first day in next month", async () => {
|
|
await selectFirstAvailableTimeSlotNextMonth(page);
|
|
|
|
// Fill what is this meeting about? title
|
|
await page.locator('[name="title"]').fill("Test meeting");
|
|
|
|
await bookTimeSlot(page);
|
|
|
|
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
|
});
|
|
|
|
await test.step("can reschedule a booking", async () => {
|
|
// Logged in
|
|
await page.goto("/bookings/upcoming");
|
|
await page.locator('[data-testid="edit_booking"]').nth(0).click();
|
|
await page.locator('[data-testid="reschedule"]').click();
|
|
await page.waitForURL((url) => {
|
|
const bookingId = url.searchParams.get("rescheduleUid");
|
|
return !!bookingId;
|
|
});
|
|
await selectSecondAvailableTimeSlotNextMonth(page);
|
|
|
|
// No need to fill fields since they should be already filled
|
|
await page.locator('[data-testid="confirm-reschedule-button"]').click();
|
|
await page.waitForURL((url) => {
|
|
return url.pathname.startsWith("/booking");
|
|
});
|
|
await expect(page.locator("[data-testid=success-page]")).toBeVisible();
|
|
});
|
|
|
|
await test.step("Can cancel the recently created booking", async () => {
|
|
await page.goto("/bookings/upcoming");
|
|
await page.locator('[data-testid="cancel"]').click();
|
|
await page.waitForURL((url) => {
|
|
return url.pathname.startsWith("/booking");
|
|
});
|
|
await page.locator('[data-testid="confirm_cancel"]').click();
|
|
|
|
const cancelledHeadline = page.locator('[data-testid="cancelled-headline"]');
|
|
await expect(cancelledHeadline).toBeVisible();
|
|
});
|
|
});
|