2022-06-10 19:16:10 +00:00
|
|
|
import { expect } from "@playwright/test";
|
|
|
|
|
2022-06-28 20:40:58 +00:00
|
|
|
import dayjs from "@calcom/dayjs";
|
2022-06-10 19:16:10 +00:00
|
|
|
import prisma from "@calcom/prisma";
|
|
|
|
|
2022-07-24 20:18:36 +00:00
|
|
|
import { test } from "./lib/fixtures";
|
2022-06-10 19:16:10 +00:00
|
|
|
|
|
|
|
test.describe.configure({ mode: "parallel" });
|
|
|
|
|
2023-03-01 20:18:51 +00:00
|
|
|
test.afterEach(({ users }) => users.deleteAll());
|
|
|
|
|
2022-06-10 19:16:10 +00:00
|
|
|
test.describe("Wipe my Cal App Test", () => {
|
|
|
|
test("Browse upcoming bookings and validate button shows and triggering wipe my cal button", async ({
|
|
|
|
page,
|
|
|
|
users,
|
|
|
|
bookings,
|
|
|
|
}) => {
|
|
|
|
const pro = await users.create();
|
|
|
|
const [eventType] = pro.eventTypes;
|
|
|
|
await prisma.credential.create({
|
|
|
|
data: {
|
|
|
|
key: {},
|
|
|
|
type: "wipemycal_other",
|
|
|
|
userId: pro.id,
|
|
|
|
appId: "wipe-my-cal",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
await bookings.create(
|
|
|
|
pro.id,
|
|
|
|
pro.username,
|
|
|
|
eventType.id,
|
|
|
|
{},
|
|
|
|
dayjs().endOf("day").subtract(29, "minutes").toDate(),
|
|
|
|
dayjs().endOf("day").toDate()
|
|
|
|
);
|
|
|
|
await bookings.create(pro.id, pro.username, eventType.id, {});
|
|
|
|
await bookings.create(pro.id, pro.username, eventType.id, {});
|
|
|
|
await pro.login();
|
|
|
|
await page.goto("/bookings/upcoming");
|
|
|
|
await expect(page.locator("data-testid=wipe-today-button")).toBeVisible();
|
|
|
|
|
2022-09-15 16:59:48 +00:00
|
|
|
const $openBookingCount = await page.locator('[data-testid="bookings"] > *').count();
|
2023-02-03 22:03:35 +00:00
|
|
|
const $todayBookingCount = await page.locator('[data-testid="today-bookings"] > *').count();
|
|
|
|
expect($openBookingCount + $todayBookingCount).toBe(3);
|
2022-09-15 16:59:48 +00:00
|
|
|
|
2022-06-10 19:16:10 +00:00
|
|
|
await page.locator("data-testid=wipe-today-button").click();
|
2022-09-15 16:59:48 +00:00
|
|
|
|
2022-11-10 07:45:10 +00:00
|
|
|
// Don't await send_request click, otherwise mutation can possibly occur before observer is attached
|
|
|
|
page.locator("data-testid=send_request").click();
|
2023-02-03 22:03:35 +00:00
|
|
|
// There will not be any today-bookings
|
|
|
|
await expect(page.locator('[data-testid="today-bookings"]')).toBeHidden();
|
2022-06-10 19:16:10 +00:00
|
|
|
});
|
|
|
|
});
|