Compare commits

...

4 Commits

Author SHA1 Message Date
Omar López 88125851dd
Merge branch 'main' into 10-26-chore_Adds_dayjs_as_fixture 2023-11-16 14:28:26 -07:00
Keith Williams 7b6ca4b844
Merge branch 'main' into 10-26-chore_Adds_dayjs_as_fixture 2023-11-16 13:31:26 -03:00
Omar López 4f9e890bdb
Update apps/web/playwright/lib/fixtures.ts 2023-10-26 13:02:53 -07:00
zomars a19c5b4af0 chore: Adds dayjs as fixture 2023-10-26 12:45:15 -07:00
6 changed files with 18 additions and 17 deletions

View File

@ -1,7 +1,5 @@
import { expect } from "@playwright/test";
import dayjs from "@calcom/dayjs";
import { test } from "./lib/fixtures";
test.describe.configure({ mode: "parallel" });
@ -19,7 +17,7 @@ test.describe("Availablity tests", () => {
await users.deleteAll();
});
test("Date Overrides", async ({ page }) => {
test("Date Overrides", async ({ page, dayjs }) => {
await test.step("Can add a date override", async () => {
await page.locator('[data-testid="schedules"] > li a').click();
await page.locator('[data-testid="add-override"]').click();

View File

@ -3,18 +3,17 @@ import type { Booking, Prisma } from "@prisma/client";
import short from "short-uuid";
import { v5 as uuidv5 } from "uuid";
import _dayjs from "@calcom/dayjs";
import { prisma } from "@calcom/prisma";
import type { Fixtures } from "../lib/fixtures";
const translator = short();
type BookingFixture = ReturnType<typeof createBookingFixture>;
// We default all dayjs calls to use Europe/London timezone
const dayjs = (...args: Parameters<typeof _dayjs>) => _dayjs(...args).tz("Europe/London");
// creates a user fixture instance and stores the collection
export const createBookingsFixture = (page: Page) => {
export const createBookingsFixture = (args: { page: Page; dayjs: Fixtures["dayjs"] }) => {
const { page, dayjs } = args;
const store = { bookings: [], page } as { bookings: BookingFixture[]; page: typeof page };
return {
create: async (

View File

@ -3,6 +3,8 @@ import { test as base } from "@playwright/test";
import type { API } from "mailhog";
import mailhog from "mailhog";
import type { Dayjs } from "@calcom/dayjs";
import _dayjs from "@calcom/dayjs";
import { IS_MAILHOG_ENABLED } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
@ -28,6 +30,7 @@ export interface Fixtures {
emails?: API;
routingForms: ReturnType<typeof createRoutingFormsFixture>;
bookingPage: ReturnType<typeof createBookingPageFixture>;
dayjs: (...args: Parameters<typeof _dayjs>) => Dayjs;
}
declare global {
@ -58,8 +61,8 @@ export const test = base.extend<Fixtures>({
const usersFixture = createUsersFixture(page, emails, workerInfo);
await use(usersFixture);
},
bookings: async ({ page }, use) => {
const bookingsFixture = createBookingsFixture(page);
bookings: async ({ page, dayjs }, use) => {
const bookingsFixture = createBookingsFixture({ page, dayjs });
await use(bookingsFixture);
},
payments: async ({ page }, use) => {
@ -92,4 +95,9 @@ export const test = base.extend<Fixtures>({
const bookingPage = createBookingPageFixture(page);
await use(bookingPage);
},
dayjs: async ({ timezoneId }, use) => {
// We default all dayjs calls to use the browser configured timezone
const dayjs = (...args: Parameters<typeof _dayjs>) => _dayjs(...args).tz(timezoneId);
await use(dayjs);
},
});

View File

@ -1,6 +1,5 @@
import { expect } from "@playwright/test";
import dayjs from "@calcom/dayjs";
import prisma from "@calcom/prisma";
import { BookingStatus } from "@calcom/prisma/enums";
@ -245,6 +244,7 @@ test.describe("Reschedule Tests", async () => {
page,
users,
bookings,
dayjs,
}) => {
const user = await users.create();
const eventType = user.eventTypes[0];

View File

@ -1,6 +1,5 @@
import { expect } from "@playwright/test";
import _dayjs from "@calcom/dayjs";
import prisma from "@calcom/prisma";
import { test } from "./lib/fixtures";
@ -9,14 +8,12 @@ test.describe.configure({ mode: "parallel" });
test.afterEach(({ users }) => users.deleteAll());
// We default all dayjs calls to use Europe/London timezone
const dayjs = (...args: Parameters<typeof _dayjs>) => _dayjs(...args).tz("Europe/London");
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,
dayjs,
}) => {
const pro = await users.create();
const [eventType] = pro.eventTypes;

View File

@ -1,6 +1,5 @@
import { expect } from "@playwright/test";
import dayjs from "@calcom/dayjs";
import prisma from "@calcom/prisma";
import { WorkflowMethods } from "@calcom/prisma/enums";
@ -14,7 +13,7 @@ test.describe("Workflow tests", () => {
// Fixme: This test is failing because the listing isn't immediately updated after the workflow is created
test.fixme(
"Create default reminder workflow & trigger when event type is booked",
async ({ page, users }) => {
async ({ page, users, dayjs }) => {
const user = await users.create();
const [eventType] = user.eventTypes;
await user.apiLogin();