diff --git a/apps/web/package.json b/apps/web/package.json index 295d247737..327f6f798a 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -144,7 +144,7 @@ "@calcom/config": "*", "@calcom/types": "*", "@microsoft/microsoft-graph-types-beta": "0.15.0-preview", - "@playwright/test": "^1.31.2", + "@playwright/test": "^1.45.3", "@testing-library/react": "^13.3.0", "@types/accept-language-parser": "1.5.2", "@types/async": "^3.2.15", diff --git a/apps/web/playwright/booking-pages.e2e.ts b/apps/web/playwright/booking-pages.e2e.ts index 371cc49f7f..a592d69ae1 100644 --- a/apps/web/playwright/booking-pages.e2e.ts +++ b/apps/web/playwright/booking-pages.e2e.ts @@ -6,7 +6,7 @@ import { randomString } from "@calcom/lib/random"; import { SchedulingType } from "@calcom/prisma/client"; import type { Schedule, TimeRange } from "@calcom/types/schedule"; -import { test } from "./lib/fixtures"; +import { test, todo } from "./lib/fixtures"; import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes"; import { bookFirstEvent, @@ -15,7 +15,6 @@ import { selectFirstAvailableTimeSlotNextMonth, testEmail, testName, - todo, } from "./lib/testUtils"; const freeUserObj = { name: `Free-user-${randomString(3)}` }; diff --git a/apps/web/playwright/impersonation.e2e.ts b/apps/web/playwright/impersonation.e2e.ts index 41c162acff..29d024c34f 100644 --- a/apps/web/playwright/impersonation.e2e.ts +++ b/apps/web/playwright/impersonation.e2e.ts @@ -5,7 +5,7 @@ import { test } from "./lib/fixtures"; test.describe.configure({ mode: "parallel" }); test.describe("Users can impersonate", async () => { - test.afterAll(async ({ users }) => { + test.afterEach(async ({ users }) => { await users.deleteAll(); }); test("App Admin can impersonate users with impersonation enabled", async ({ page, users }) => { diff --git a/apps/web/playwright/insights.e2e.ts b/apps/web/playwright/insights.e2e.ts index 0a3d996763..4b561957fb 100644 --- a/apps/web/playwright/insights.e2e.ts +++ b/apps/web/playwright/insights.e2e.ts @@ -61,7 +61,7 @@ const createTeamsAndMembership = async (userIdOne: number, userIdTwo: number) => return { teamOne, teamTwo }; }; -test.afterAll(async ({ users }) => { +test.afterEach(async ({ users }) => { await users.deleteAll(); }); diff --git a/apps/web/playwright/integrations-stripe.e2e.ts b/apps/web/playwright/integrations-stripe.e2e.ts index ca8d35e193..c527e85202 100644 --- a/apps/web/playwright/integrations-stripe.e2e.ts +++ b/apps/web/playwright/integrations-stripe.e2e.ts @@ -5,9 +5,9 @@ import prisma from "@calcom/prisma"; import { SchedulingType } from "@calcom/prisma/enums"; import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils"; -import { test } from "./lib/fixtures"; +import { test, todo } from "./lib/fixtures"; import type { Fixtures } from "./lib/fixtures"; -import { todo, selectFirstAvailableTimeSlotNextMonth } from "./lib/testUtils"; +import { selectFirstAvailableTimeSlotNextMonth } from "./lib/testUtils"; test.describe.configure({ mode: "parallel" }); test.afterEach(({ users }) => users.deleteAll()); diff --git a/apps/web/playwright/integrations.e2e.ts b/apps/web/playwright/integrations.e2e.ts index 4f58b9ac77..657f0d0aab 100644 --- a/apps/web/playwright/integrations.e2e.ts +++ b/apps/web/playwright/integrations.e2e.ts @@ -7,8 +7,7 @@ import { v4 as uuidv4 } from "uuid"; import { prisma } from "@calcom/prisma"; -import { test } from "./lib/fixtures"; -import { todo } from "./lib/testUtils"; +import { test, todo } from "./lib/fixtures"; declare let global: { E2E_EMAILS?: ({ text: string } | Record)[]; diff --git a/apps/web/playwright/lib/fixtures.ts b/apps/web/playwright/lib/fixtures.ts index 91e811e478..7ed8bdc8bc 100644 --- a/apps/web/playwright/lib/fixtures.ts +++ b/apps/web/playwright/lib/fixtures.ts @@ -1,5 +1,7 @@ import type { Page } from "@playwright/test"; import { test as base } from "@playwright/test"; +// eslint-disable-next-line no-restricted-imports +import { noop } from "lodash"; import prisma from "@calcom/prisma"; @@ -117,3 +119,8 @@ export const test = base.extend({ await use(webhooks); }, }); + +export function todo(title: string) { + // eslint-disable-next-line playwright/no-skipped-test + test.skip(title, noop); +} diff --git a/apps/web/playwright/lib/loadJSON.ts b/apps/web/playwright/lib/loadJSON.ts new file mode 100644 index 0000000000..8228253b23 --- /dev/null +++ b/apps/web/playwright/lib/loadJSON.ts @@ -0,0 +1,9 @@ +import fs from "fs"; +import path from "path"; + +/** + * Simple utility to load JSON files from the file system. Needed to avoid certain errors with: + * `TypeError: Module "*" needs an import attribute of type "json"` + * @see https://stackoverflow.com/a/73747606 + */ +export const loadJSON = (file: string) => JSON.parse(fs.readFileSync(path.join(__dirname, file)).toString()); diff --git a/apps/web/playwright/lib/testUtils.ts b/apps/web/playwright/lib/testUtils.ts index e018639de4..503eb59e4b 100644 --- a/apps/web/playwright/lib/testUtils.ts +++ b/apps/web/playwright/lib/testUtils.ts @@ -1,11 +1,10 @@ -import { expect } from "@playwright/test"; import type { Frame, Page, Request as PlaywrightRequest } from "@playwright/test"; +import { expect } from "@playwright/test"; import { createHash } from "crypto"; import EventEmitter from "events"; import type { IncomingMessage, ServerResponse } from "http"; import { createServer } from "http"; // eslint-disable-next-line no-restricted-imports -import { noop } from "lodash"; import type { Messages } from "mailhog"; import { totp } from "otplib"; @@ -15,12 +14,7 @@ import type { IntervalLimit } from "@calcom/types/Calendar"; import type { createEmailsFixture } from "../fixtures/emails"; import type { Fixtures } from "./fixtures"; -import { test } from "./fixtures"; - -export function todo(title: string) { - // eslint-disable-next-line playwright/no-skipped-test - test.skip(title, noop); -} +import { loadJSON } from "./loadJSON"; type Request = IncomingMessage & { body?: unknown }; type RequestHandlerOptions = { req: Request; res: ServerResponse }; @@ -148,7 +142,7 @@ export const bookTimeSlot = async (page: Page, opts?: { name?: string; email?: s // Provide an standalone localize utility not managed by next-i18n export async function localize(locale: string) { const localeModule = `../../public/static/locales/${locale}/common.json`; - const localeMap = await import(localeModule); + const localeMap = loadJSON(localeModule); return (message: string) => { if (message in localeMap) return localeMap[message]; throw "No locale found for the given entry message"; diff --git a/apps/web/playwright/login.2fa.e2e.ts b/apps/web/playwright/login.2fa.e2e.ts index 62c86f2057..0facb673dc 100644 --- a/apps/web/playwright/login.2fa.e2e.ts +++ b/apps/web/playwright/login.2fa.e2e.ts @@ -15,7 +15,7 @@ test.describe.configure({ mode: "parallel" }); // a test to logout requires both a succesfull login as logout, to prevent // a doubling of tests failing on logout & logout, we can group them. test.describe("2FA Tests", async () => { - test.afterAll(async ({ users }) => { + test.afterEach(async ({ users }) => { await users.deleteAll(); }); test("should allow a user to enable 2FA and login using 2FA", async ({ page, users }) => { diff --git a/apps/web/playwright/login.e2e.ts b/apps/web/playwright/login.e2e.ts index 6796669c06..a963e457c3 100644 --- a/apps/web/playwright/login.e2e.ts +++ b/apps/web/playwright/login.e2e.ts @@ -10,7 +10,7 @@ test.describe.configure({ mode: "parallel" }); // a test to logout requires both a succesfull login as logout, to prevent // a doubling of tests failing on logout & logout, we can group them. testBothFutureAndLegacyRoutes.describe("user can login & logout succesfully", async () => { - test.afterAll(async ({ users }) => { + test.afterEach(async ({ users }) => { await users.deleteAll(); }); @@ -46,7 +46,7 @@ testBothFutureAndLegacyRoutes.describe("user can login & logout succesfully", as }); testBothFutureAndLegacyRoutes.describe("Login and logout tests", () => { - test.afterAll(async ({ users }) => { + test.afterEach(async ({ users }) => { await users.deleteAll(); }); diff --git a/apps/web/playwright/managed-event-types.e2e.ts b/apps/web/playwright/managed-event-types.e2e.ts index c77a552f70..4097beb72f 100644 --- a/apps/web/playwright/managed-event-types.e2e.ts +++ b/apps/web/playwright/managed-event-types.e2e.ts @@ -11,7 +11,7 @@ import { selectFirstAvailableTimeSlotNextMonth, } from "./lib/testUtils"; -test.afterAll(({ users }) => users.deleteAll()); +test.afterEach(({ users }) => users.deleteAll()); test.describe("Managed Event Types", () => { test("Can create managed event type", async ({ page, users }) => { diff --git a/apps/web/playwright/organization/across-org/across-org.e2e.ts b/apps/web/playwright/organization/across-org/across-org.e2e.ts index ccd1c7309e..0bcc9e9a21 100644 --- a/apps/web/playwright/organization/across-org/across-org.e2e.ts +++ b/apps/web/playwright/organization/across-org/across-org.e2e.ts @@ -5,7 +5,7 @@ import prisma from "@calcom/prisma"; import { test } from "../../lib/fixtures"; -test.afterAll(({ users }) => { +test.afterEach(({ users }) => { users.deleteAll(); }); diff --git a/apps/web/playwright/organization/organization-creation.e2e.ts b/apps/web/playwright/organization/organization-creation.e2e.ts index 8ee81bca59..7dae4c98d4 100644 --- a/apps/web/playwright/organization/organization-creation.e2e.ts +++ b/apps/web/playwright/organization/organization-creation.e2e.ts @@ -90,7 +90,7 @@ export async function expectEmailVerificationEmailToBeSent( return expectEmailWithSubject(page, emails, userEmail, subject); } -test.afterAll(({ users, orgs }) => { +test.afterEach(({ users, orgs }) => { users.deleteAll(); orgs.deleteAll(); }); diff --git a/apps/web/playwright/overlay-calendar.e2e.ts b/apps/web/playwright/overlay-calendar.e2e.ts index 803f772fb3..d6ed744917 100644 --- a/apps/web/playwright/overlay-calendar.e2e.ts +++ b/apps/web/playwright/overlay-calendar.e2e.ts @@ -2,7 +2,7 @@ export {}; // TODO: @sean - I can't run E2E locally - causing me a lot of pain to try and debug. // Will tackle in follow up once i reset my system. // test.describe("User can overlay their calendar", async () => { -// test.afterAll(async ({ users }) => { +// test.afterEach(async ({ users }) => { // await users.deleteAll(); // }); // test("Continue with Cal.com flow", async ({ page, users }) => { diff --git a/apps/web/playwright/signup.e2e.ts b/apps/web/playwright/signup.e2e.ts index dc094df48b..474ab50aad 100644 --- a/apps/web/playwright/signup.e2e.ts +++ b/apps/web/playwright/signup.e2e.ts @@ -14,7 +14,7 @@ test.describe("Signup Flow Test", async () => { test.beforeEach(async ({ features }) => { features.reset(); // This resets to the inital state not an empt yarray }); - test.afterAll(async ({ users }) => { + test.afterEach(async ({ users }) => { await users.deleteAll(); }); test("Username is taken", async ({ page, users }) => { diff --git a/apps/web/playwright/teams.e2e.ts b/apps/web/playwright/teams.e2e.ts index be7fb228ed..2733bd02f2 100644 --- a/apps/web/playwright/teams.e2e.ts +++ b/apps/web/playwright/teams.e2e.ts @@ -4,14 +4,13 @@ import { IS_TEAM_BILLING_ENABLED } from "@calcom/lib/constants"; import { prisma } from "@calcom/prisma"; import { SchedulingType } from "@calcom/prisma/enums"; -import { test } from "./lib/fixtures"; +import { test, todo } from "./lib/fixtures"; import { testBothFutureAndLegacyRoutes } from "./lib/future-legacy-routes"; import { bookTimeSlot, fillStripeTestCheckout, selectFirstAvailableTimeSlotNextMonth, testName, - todo, } from "./lib/testUtils"; test.describe.configure({ mode: "parallel" }); diff --git a/apps/web/playwright/trial.e2e.ts b/apps/web/playwright/trial.e2e.ts index b0898b7250..ea8da56305 100644 --- a/apps/web/playwright/trial.e2e.ts +++ b/apps/web/playwright/trial.e2e.ts @@ -1,6 +1,4 @@ -import { test } from "@playwright/test"; - -import { todo } from "./lib/testUtils"; +import { test, todo } from "./lib/fixtures"; test.describe("Trial account tests", () => { todo("Add tests with a TRIAL account"); diff --git a/apps/web/playwright/unpublished.e2e.ts b/apps/web/playwright/unpublished.e2e.ts index ae16a56f0e..3ad6114ebc 100644 --- a/apps/web/playwright/unpublished.e2e.ts +++ b/apps/web/playwright/unpublished.e2e.ts @@ -10,7 +10,7 @@ const title = (name: string) => `${name} is unpublished`; const description = (entity: string) => `This ${entity} link is currently not available. Please contact the ${entity} owner or ask them to publish it.`; -test.afterAll(async ({ users }) => { +test.afterEach(async ({ users }) => { await users.deleteAll(); }); diff --git a/package.json b/package.json index cabedae147..42be9cf694 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ }, "devDependencies": { "@changesets/cli": "^2.26.1", - "@playwright/test": "^1.31.2", + "@playwright/test": "^1.45.3", "@snaplet/copycat": "^4.1.0", "@testing-library/jest-dom": "^5.16.5", "@types/jsdom": "^21.1.3", diff --git a/packages/embeds/embed-core/package.json b/packages/embeds/embed-core/package.json index 9b717df854..d4c81bdcd4 100644 --- a/packages/embeds/embed-core/package.json +++ b/packages/embeds/embed-core/package.json @@ -46,7 +46,7 @@ } }, "devDependencies": { - "@playwright/test": "^1.31.2", + "@playwright/test": "^1.45.3", "@vitejs/plugin-basic-ssl": "^1.1.0", "autoprefixer": "^10.4.12", "npm-run-all": "^4.1.5", diff --git a/packages/embeds/embed-core/playwright/lib/testUtils.ts b/packages/embeds/embed-core/playwright/lib/testUtils.ts index 85ffb22b79..7ef345a7ed 100644 --- a/packages/embeds/embed-core/playwright/lib/testUtils.ts +++ b/packages/embeds/embed-core/playwright/lib/testUtils.ts @@ -1,14 +1,8 @@ import type { Page, Frame } from "@playwright/test"; -import { test, expect } from "@playwright/test"; +import { expect } from "@playwright/test"; -// eslint-disable-next-line no-restricted-imports import prisma from "@calcom/prisma"; -export function todo(title: string) { - // eslint-disable-next-line @typescript-eslint/no-empty-function, playwright/no-skipped-test - test.skip(title, () => {}); -} - export const deleteAllBookingsByEmail = async (email: string) => await prisma.booking.deleteMany({ where: { diff --git a/packages/embeds/embed-core/playwright/tests/action-based.e2e.ts b/packages/embeds/embed-core/playwright/tests/action-based.e2e.ts index 4e9464a3c2..6f5601a004 100644 --- a/packages/embeds/embed-core/playwright/tests/action-based.e2e.ts +++ b/packages/embeds/embed-core/playwright/tests/action-based.e2e.ts @@ -1,12 +1,11 @@ import type { Page } from "@playwright/test"; import { expect } from "@playwright/test"; -import { test } from "@calcom/web/playwright/lib/fixtures"; +import { test, todo } from "@calcom/web/playwright/lib/fixtures"; import type { Fixtures } from "@calcom/web/playwright/lib/fixtures"; import { selectFirstAvailableTimeSlotNextMonth } from "@calcom/web/playwright/lib/testUtils"; import { - todo, getEmbedIframe, bookFirstEvent, getBooking, diff --git a/packages/embeds/embed-core/playwright/tests/inline.e2e.ts b/packages/embeds/embed-core/playwright/tests/inline.e2e.ts index c48373234c..c87d1fff66 100644 --- a/packages/embeds/embed-core/playwright/tests/inline.e2e.ts +++ b/packages/embeds/embed-core/playwright/tests/inline.e2e.ts @@ -1,13 +1,12 @@ import { expect } from "@playwright/test"; -import { test } from "@calcom/web/playwright/lib/fixtures"; +import { test, todo } from "@calcom/web/playwright/lib/fixtures"; import { assertNoRequestIsBlocked, bookFirstEvent, deleteAllBookingsByEmail, getEmbedIframe, - todo, } from "../lib/testUtils"; test.describe("Inline Iframe", () => { diff --git a/packages/embeds/embed-react/package.json b/packages/embeds/embed-react/package.json index 7ea873ef5a..b6c44ebff2 100644 --- a/packages/embeds/embed-react/package.json +++ b/packages/embeds/embed-react/package.json @@ -44,7 +44,7 @@ } }, "devDependencies": { - "@playwright/test": "^1.31.2", + "@playwright/test": "^1.45.3", "@types/react": "18.0.26", "@types/react-dom": "^18.0.9", "@vitejs/plugin-react": "^2.2.0", diff --git a/yarn.lock b/yarn.lock index 4b5456dc95..041afbc115 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4560,7 +4560,7 @@ __metadata: version: 0.0.0-use.local resolution: "@calcom/embed-core@workspace:packages/embeds/embed-core" dependencies: - "@playwright/test": ^1.31.2 + "@playwright/test": ^1.45.3 "@vitejs/plugin-basic-ssl": ^1.1.0 autoprefixer: ^10.4.12 npm-run-all: ^4.1.5 @@ -4578,7 +4578,7 @@ __metadata: dependencies: "@calcom/embed-core": "workspace:*" "@calcom/embed-snippet": "workspace:*" - "@playwright/test": ^1.31.2 + "@playwright/test": ^1.45.3 "@types/react": 18.0.26 "@types/react-dom": ^18.0.9 "@vitejs/plugin-react": ^2.2.0 @@ -5533,7 +5533,7 @@ __metadata: "@microsoft/microsoft-graph-types-beta": 0.15.0-preview "@next-auth/prisma-adapter": ^1.0.4 "@next/bundle-analyzer": ^13.1.6 - "@playwright/test": ^1.31.2 + "@playwright/test": ^1.45.3 "@radix-ui/react-avatar": ^1.0.4 "@radix-ui/react-collapsible": ^1.0.0 "@radix-ui/react-dialog": ^1.0.4 @@ -11164,19 +11164,14 @@ __metadata: languageName: node linkType: hard -"@playwright/test@npm:^1.31.2": - version: 1.31.2 - resolution: "@playwright/test@npm:1.31.2" +"@playwright/test@npm:^1.45.3": + version: 1.45.3 + resolution: "@playwright/test@npm:1.45.3" dependencies: - "@types/node": "*" - fsevents: 2.3.2 - playwright-core: 1.31.2 - dependenciesMeta: - fsevents: - optional: true + playwright: 1.45.3 bin: playwright: cli.js - checksum: 5459ee0ce15b9a54337f4c26e2ee2d29c11e67e6207c167158eb180a4bea6659c988a2897f51dbebf591fc879f0d81f417e70936b9d8a001448c957939882588 + checksum: 3e2c88d40f98cf94ab7947263804d1ee78c4bb21a35c8dbb64855eed5565ffc688509c5f07bda5438cba6c354374981448dcba3dbe326d1699b4fef75c9ce43d languageName: node linkType: hard @@ -21394,7 +21389,7 @@ __metadata: dependencies: "@changesets/cli": ^2.26.1 "@daily-co/daily-js": ^0.59.0 - "@playwright/test": ^1.31.2 + "@playwright/test": ^1.45.3 "@snaplet/copycat": ^4.1.0 "@testing-library/jest-dom": ^5.16.5 "@types/jsdom": ^21.1.3 @@ -39178,12 +39173,12 @@ __metadata: languageName: node linkType: hard -"playwright-core@npm:1.31.2": - version: 1.31.2 - resolution: "playwright-core@npm:1.31.2" +"playwright-core@npm:1.45.3": + version: 1.45.3 + resolution: "playwright-core@npm:1.45.3" bin: - playwright: cli.js - checksum: bf1257b7d80b9d027c99cbfa7ab9d47a2110ec804422b3e3d623bbb3c43e06df7bec4764ca1d852a6d62c76e35c8776efb19941f42ce738db9bc92e7f1b6281c + playwright-core: cli.js + checksum: cecb58877b2c643403d7a72c24a7aa0fdd087a3c7f9a5ea5403851336ea831d8e304b1f159aacbbabd12e5c47eaac054333746c9e5431ec07b13d64dbf3b50ec languageName: node linkType: hard @@ -39196,6 +39191,21 @@ __metadata: languageName: node linkType: hard +"playwright@npm:1.45.3": + version: 1.45.3 + resolution: "playwright@npm:1.45.3" + dependencies: + fsevents: 2.3.2 + playwright-core: 1.45.3 + dependenciesMeta: + fsevents: + optional: true + bin: + playwright: cli.js + checksum: d9d23b155ccd001553214f710561b01e48eb409676102f8ab94c0b4aa5ac5f398becc1a96528b0554944e07e34189503d891913e0e0a4aa58ad36b9c08747983 + languageName: node + linkType: hard + "pluralize@npm:8.0.0": version: 8.0.0 resolution: "pluralize@npm:8.0.0"