Scheduling infrastructure for absolutely everyone.
chore: Replace UI login with api login on e2e tests (#9344)
Efraín Rochín17d106cfda5d
diff --git a/apps/web/playwright/app-store.e2e.ts b/apps/web/playwright/app-store.e2e.tsindex 08be9beaa98..92b2371da06 100644--- a/apps/web/playwright/app-store.e2e.ts+++ b/apps/web/playwright/app-store.e2e.ts@@ -9,7 +9,7 @@ test.afterEach(({ users }) => users.deleteAll());test.describe("App Store - Authed", () => {test("Browse apple-calendar and try to install", async ({ page, users }) => {const pro = await users.create();- await pro.login();+ await pro.apiLogin();await page.goto("/apps/categories/calendar");await page.click('[data-testid="app-store-app-card-apple-calendar"]');await page.waitForURL("/apps/apple-calendar");@@ -19,7 +19,7 @@ test.describe("App Store - Authed", () => {test("Installed Apps - Navigation", async ({ page, users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();await page.goto("/apps/installed");await page.waitForSelector('[data-testid="connect-calendar-apps"]');await page.click('[data-testid="vertical-tab-payment"]');diff --git a/apps/web/playwright/auth/auth-index.e2e.ts b/apps/web/playwright/auth/auth-index.e2e.tsindex 19c568bb14f..7b6a2276ba2 100644--- a/apps/web/playwright/auth/auth-index.e2e.ts+++ b/apps/web/playwright/auth/auth-index.e2e.ts@@ -3,7 +3,7 @@ import { test } from "../lib/fixtures";test.describe("Can signup from a team invite", async () => {test.beforeEach(async ({ users }) => {const proUser = await users.create();- await proUser.login();+ await proUser.apiLogin();});test.afterEach(async ({ users }) => users.deleteAll());@@ -33,65 +33,65 @@ test.describe("Can signup from a team invite", async () => {// Wait for the invite to be sent/*await page.waitForSelector(`[data-testid="member-email"][data-email="${testUser.email}"]`);- const tokenObj = await prisma.verificationToken.findFirstOrThrow({- where: { identifier: testUser.email },- select: { token: true },- });-- if (!proUser.username) throw Error("Test username is null, can't continue");-- // Open a new user window to accept the invite- const newPage = await browser.newPage();- await newPage.goto(`/auth/signup?token=${tokenObj.token}&callbackUrl=${WEBAPP_URL}/settings/teams`);-- // Fill in form- await newPage.fill('input[name="username"]', proUser.username); // Invalid username- await newPage.fill('input[name="email"]', testUser.email);- await newPage.fill('input[name="password"]', testUser.password);- await newPage.fill('input[name="passwordcheck"]', testUser.password);- await newPage.press('input[name="passwordcheck"]', "Enter"); // Press Enter to submit-- await expect(newPage.locator('text="Username already taken"')).toBeVisible();-- // Email address is already registered- // TODO: Form errors don't disappear when corrected and resubmitted, so we need to refresh- await newPage.reload();- await newPage.fill('input[name="username"]', testUser.username);- await newPage.fill('input[name="email"]', `${proUser.username}@example.com`); // Taken email- await newPage.fill('input[name="password"]', testUser.password);- await newPage.fill('input[name="passwordcheck"]', testUser.password);- await newPage.press('input[name="passwordcheck"]', "Enter"); // Press Enter to submit- await expect(newPage.locator('text="Email address is already registered"')).toBeVisible();-- // Successful signup- // TODO: Form errors don't disappear when corrected and resubmitted, so we need to refresh- await newPage.reload();- await newPage.fill('input[name="username"]', testUser.username);- await newPage.fill('input[name="email"]', testUser.email);- await newPage.fill('input[name="password"]', testUser.password);- await newPage.fill('input[name="passwordcheck"]', testUser.password);- await newPage.press('input[name="passwordcheck"]', "Enter"); // Press Enter to submit- await expect(newPage.locator(`[data-testid="login-form"]`)).toBeVisible();-- // We don't need the new browser anymore- await newPage.close();-- const createdUser = await prisma.user.findUniqueOrThrow({- where: { email: testUser.email },- include: { teams: { include: { team: true } } },- });-- console.log("createdUser", createdUser);-- // Check that the user was created- expect(createdUser).not.toBeNull();- expect(createdUser.username).toBe(testUser.username);- expect(createdUser.password).not.toBeNull();- expect(createdUser.emailVerified).not.toBeNull();- // Check that the user accepted the team invite- expect(createdUser.teams).toHaveLength(1);- expect(createdUser.teams[0].team.name).toBe(teamName);- expect(createdUser.teams[0].role).toBe("MEMBER");- expect(createdUser.teams[0].accepted).toBe(true);*/+ const tokenObj = await prisma.verificationToken.findFirstOrThrow({+ where: { identifier: testUser.email },+ select: { token: true },+ });++ if (!proUser.username) throw Error("Test username is null, can't continue");++ // Open a new user window to accept the invite+ const newPage = await browser.newPage();+ await newPage.goto(`/auth/signup?token=${tokenObj.token}&callbackUrl=${WEBAPP_URL}/settings/teams`);++ // Fill in form+ await newPage.fill('input[name="username"]', proUser.username); // Invalid username+ await newPage.fill('input[name="email"]', testUser.email);+ await newPage.fill('input[name="password"]', testUser.password);+ await newPage.fill('input[name="passwordcheck"]', testUser.password);+ await newPage.press('input[name="passwordcheck"]', "Enter"); // Press Enter to submit++ await expect(newPage.locator('text="Username already taken"')).toBeVisible();++ // Email address is already registered+ // TODO: Form errors don't disappear when corrected and resubmitted, so we need to refresh+ await newPage.reload();+ await newPage.fill('input[name="username"]', testUser.username);+ await newPage.fill('input[name="email"]', `${proUser.username}@example.com`); // Taken email+ await newPage.fill('input[name="password"]', testUser.password);+ await newPage.fill('input[name="passwordcheck"]', testUser.password);+ await newPage.press('input[name="passwordcheck"]', "Enter"); // Press Enter to submit+ await expect(newPage.locator('text="Email address is already registered"')).toBeVisible();++ // Successful signup+ // TODO: Form errors don't disappear when corrected and resubmitted, so we need to refresh+ await newPage.reload();+ await newPage.fill('input[name="username"]', testUser.username);+ await newPage.fill('input[name="email"]', testUser.email);+ await newPage.fill('input[name="password"]', testUser.password);+ await newPage.fill('input[name="passwordcheck"]', testUser.password);+ await newPage.press('input[name="passwordcheck"]', "Enter"); // Press Enter to submit+ await expect(newPage.locator(`[data-testid="login-form"]`)).toBeVisible();++ // We don't need the new browser anymore+ await newPage.close();++ const createdUser = await prisma.user.findUniqueOrThrow({+ where: { email: testUser.email },+ include: { teams: { include: { team: true } } },+ });++ console.log("createdUser", createdUser);++ // Check that the user was created+ expect(createdUser).not.toBeNull();+ expect(createdUser.username).toBe(testUser.username);+ expect(createdUser.password).not.toBeNull();+ expect(createdUser.emailVerified).not.toBeNull();+ // Check that the user accepted the team invite+ expect(createdUser.teams).toHaveLength(1);+ expect(createdUser.teams[0].team.name).toBe(teamName);+ expect(createdUser.teams[0].role).toBe("MEMBER");+ expect(createdUser.teams[0].accepted).toBe(true);*/});});diff --git a/apps/web/playwright/auth/delete-account.e2e.ts b/apps/web/playwright/auth/delete-account.e2e.tsindex 7861cbdd006..e0f39ecb5be 100644--- a/apps/web/playwright/auth/delete-account.e2e.ts+++ b/apps/web/playwright/auth/delete-account.e2e.ts@@ -8,12 +8,10 @@ test("Can delete user account", async ({ page, users }) => {const user = await users.create({username: "delete-me",});- await user.login();-+ await user.apiLogin();+ await page.goto(`/settings/my-account/profile`);await page.waitForSelector("[data-testid=dashboard-shell]");- await page.goto(`/settings/my-account/profile`);- await page.waitForLoadState("networkidle");await page.click("[data-testid=delete-account]");expect(user.username).toBeTruthy();diff --git a/apps/web/playwright/auth/forgot-password.e2e.ts b/apps/web/playwright/auth/forgot-password.e2e.tsindex d43fb5c2cb4..f18ae9cbce8 100644--- a/apps/web/playwright/auth/forgot-password.e2e.ts+++ b/apps/web/playwright/auth/forgot-password.e2e.ts@@ -18,7 +18,7 @@ test("Can reset forgotten password", async ({ page, users }) => {// Press Enterawait Promise.all([- page.waitForURL((u) => u.pathname.startsWith("/auth/forgot-password/")),+ page.waitForURL((u) => u.pathname.startsWith("/auth/forgot-password")),page.press('input[name="email"]', "Enter"),]);diff --git a/apps/web/playwright/availability.e2e.ts b/apps/web/playwright/availability.e2e.tsindex 723da4c7667..45cacf85ef4 100644--- a/apps/web/playwright/availability.e2e.ts+++ b/apps/web/playwright/availability.e2e.ts@@ -9,7 +9,7 @@ test.describe.configure({ mode: "parallel" });test.describe("Availablity tests", () => {test.beforeEach(async ({ page, users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();await page.goto("/availability");// We wait until loading is finishedawait page.waitForSelector('[data-testid="schedules"]');diff --git a/apps/web/playwright/booking-pages.e2e.ts b/apps/web/playwright/booking-pages.e2e.tsindex f35f871279e..a43573791b4 100644--- a/apps/web/playwright/booking-pages.e2e.ts+++ b/apps/web/playwright/booking-pages.e2e.ts@@ -78,7 +78,7 @@ testBothBookers.describe("pro user", () => {const [eventType] = pro.eventTypes;await bookings.create(pro.id, pro.username, eventType.id);- await pro.login();+ await pro.apiLogin();await page.goto("/bookings/upcoming");await page.waitForSelector('[data-testid="bookings"]');await page.locator('[data-testid="edit_booking"]').nth(0).click();@@ -106,7 +106,7 @@ testBothBookers.describe("pro user", () => {await expect(page.locator(`[data-testid="attendee-name-${testName}"]`)).toHaveText(testName);const [pro] = users.get();- await pro.login();+ await pro.apiLogin();await page.goto("/bookings/upcoming");await page.locator('[data-testid="cancel"]').first().click();@@ -132,7 +132,7 @@ testBothBookers.describe("pro user", () => {}) => {await bookOptinEvent(page);const [pro] = users.get();- await pro.login();+ await pro.apiLogin();await page.goto("/bookings/unconfirmed");await Promise.all([diff --git a/apps/web/playwright/booking-seats.e2e.ts b/apps/web/playwright/booking-seats.e2e.tsindex 6cb8918e0ee..5280e8b3a7e 100644--- a/apps/web/playwright/booking-seats.e2e.ts+++ b/apps/web/playwright/booking-seats.e2e.ts@@ -14,6 +14,7 @@ import {selectFirstAvailableTimeSlotNextMonth,} from "./lib/testUtils";+test.describe.configure({ mode: "parallel" });test.afterEach(({ users }) => users.deleteAll());async function createUserWithSeatedEvent(users: Fixtures["users"]) {@@ -50,17 +51,27 @@ async function createUserWithSeatedEventAndAttendees(testBothBookers.describe("Booking with Seats", (bookerVariant) => {test("User can create a seated event (2 seats as example)", async ({ users, page }) => {const user = await users.create({ name: "Seated event" });- await user.login();+ await user.apiLogin();+ await page.goto("/event-types");+ // We wait until loading is finished+ await page.waitForSelector('[data-testid="event-types"]');const eventTitle = "My 2-seated event";await createNewSeatedEventType(page, { eventTitle });await expect(page.locator(`text=${eventTitle} event type updated successfully`)).toBeVisible();});+test("Multiple Attendees can book a seated event time slot", async ({ users, page }) => {const slug = "my-2-seated-event";const user = await users.create({name: "Seated event user",eventTypes: [- { title: "My 2-seated event", slug, length: 60, seatsPerTimeSlot: 2, seatsShowAttendees: true },+ {+ title: "My 2-seated event",+ slug,+ length: 60,+ seatsPerTimeSlot: 2,+ seatsShowAttendees: true,+ },],});await page.goto(`/${user.username}/${slug}`);@@ -93,6 +104,7 @@ testBothBookers.describe("Booking with Seats", (bookerVariant) => {await expect(page.locator("[data-testid=success-page]")).toBeHidden();});});+// TODO: Make E2E test: Attendee #1 should be able to cancel his booking// todo("Attendee #1 should be able to cancel his booking");// TODO: Make E2E test: Attendee #1 should be able to reschedule his booking@@ -222,7 +234,7 @@ testBothBookers.describe("Reschedule for booking with seats", () => {{ name: "John First", email: "[email protected]", timeZone: "Europe/Berlin" },{ name: "Jane Second", email: "[email protected]", timeZone: "Europe/Berlin" },]);- await user.login();+ await user.apiLogin();const oldBooking = await prisma.booking.findFirst({where: { uid: booking.uid },@@ -328,7 +340,7 @@ testBothBookers.describe("Reschedule for booking with seats", () => {{ name: "John First", email: "[email protected]", timeZone: "Europe/Berlin" },{ name: "Jane Second", email: "[email protected]", timeZone: "Europe/Berlin" },]);- await user.login();+ await user.apiLogin();const bookingAttendees = await prisma.attendee.findMany({where: { bookingId: booking.id },@@ -379,7 +391,7 @@ testBothBookers.describe("Reschedule for booking with seats", () => {{ name: "John First", email: "[email protected]", timeZone: "Europe/Berlin" },{ name: "Jane Second", email: "[email protected]", timeZone: "Europe/Berlin" },]);- await user.login();+ await user.apiLogin();const bookingWithEventType = await prisma.booking.findFirst({where: { uid: booking.uid },select: {diff --git a/apps/web/playwright/change-password.e2e.ts b/apps/web/playwright/change-password.e2e.tsindex 54da39da706..c172d952bba 100644--- a/apps/web/playwright/change-password.e2e.ts+++ b/apps/web/playwright/change-password.e2e.ts@@ -7,7 +7,7 @@ test.afterEach(({ users }) => users.deleteAll());test.describe("Change Password Test", () => {test("change password", async ({ page, users }) => {const pro = await users.create();- await pro.login();+ await pro.apiLogin();// Go to http://localhost:3000/settings/securityawait page.goto("/settings/security/password");diff --git a/apps/web/playwright/change-username.e2e.ts b/apps/web/playwright/change-username.e2e.tsindex c21202109ca..1655a5559a0 100644--- a/apps/web/playwright/change-username.e2e.ts+++ b/apps/web/playwright/change-username.e2e.ts@@ -26,7 +26,7 @@ test.describe("Change username on settings", () => {test.fixme("User can change username", async ({ page, users, prisma }) => {const user = await users.create();- await user.login();+ await user.apiLogin();// Try to go homepageawait page.goto("/settings/my-account/profile");// Change username from normal to normal@@ -56,7 +56,7 @@ test.describe("Change username on settings", () => {const user = await users.create();await stripe.customers.create({ email: `${user?.username}@example.com` });- await user.login();+ await user.apiLogin();await page.goto("/settings/my-account/profile");// Change username from normal to premiumdiff --git a/apps/web/playwright/dynamic-booking-pages.e2e.ts b/apps/web/playwright/dynamic-booking-pages.e2e.tsindex 095b64bfd30..064eaf5c2bd 100644--- a/apps/web/playwright/dynamic-booking-pages.e2e.ts+++ b/apps/web/playwright/dynamic-booking-pages.e2e.ts@@ -14,7 +14,7 @@ test.afterEach(({ users }) => users.deleteAll());// eslint-disable-next-line playwright/no-skipped-testtest.skip("dynamic booking", async ({ page, users }) => {const pro = await users.create();- await pro.login();+ await pro.apiLogin();const free = await users.create({ username: "free" });await page.goto(`/${pro.username}+${free.username}`);diff --git a/apps/web/playwright/embed-code-generator.e2e.ts b/apps/web/playwright/embed-code-generator.e2e.tsindex 12c2b437ec1..6988073cf39 100644--- a/apps/web/playwright/embed-code-generator.e2e.ts+++ b/apps/web/playwright/embed-code-generator.e2e.ts@@ -47,7 +47,15 @@ async function expectToBeNavigatingToEmbedTypesDialog(async function expectToBeNavigatingToEmbedCodeAndPreviewDialog(page: Page,- { embedUrl, embedType, basePage }: { embedUrl: string | null; embedType: string; basePage: string }+ {+ embedUrl,+ embedType,+ basePage,+ }: {+ embedUrl: string | null;+ embedType: string;+ basePage: string;+ }) {if (!embedUrl) {throw new Error("Couldn't find embedUrl");@@ -89,7 +97,7 @@ test.afterEach(({ users }) => users.deleteAll());test.describe("Embed Code Generator Tests", () => {test.beforeEach(async ({ users }) => {const pro = await users.create();- await pro.login();+ await pro.apiLogin();});test.describe("Event Types Page", () => {diff --git a/apps/web/playwright/event-types.e2e.ts b/apps/web/playwright/event-types.e2e.tsindex c6f3f7b2b09..7b775bf0551 100644--- a/apps/web/playwright/event-types.e2e.ts+++ b/apps/web/playwright/event-types.e2e.ts@@ -13,7 +13,7 @@ test.describe("Event Types tests", () => {testBothBookers.describe("user", (bookerVariant) => {test.beforeEach(async ({ page, users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();await page.goto("/event-types");// We wait until loading is finishedawait page.waitForSelector('[data-testid="event-types"]');diff --git a/apps/web/playwright/fixtures/users.ts b/apps/web/playwright/fixtures/users.tsindex 4b10d76f81d..c4d12f30b0e 100644--- a/apps/web/playwright/fixtures/users.ts+++ b/apps/web/playwright/fixtures/users.ts@@ -262,13 +262,17 @@ const createUserFixture = (user: UserWithIncludes, page: Page) => {// self is a reflective method that return the Prisma object that references this fixture.const self = async () =>// eslint-disable-next-line @typescript-eslint/no-non-null-assertion- (await prisma.user.findUnique({ where: { id: store.user.id }, include: { eventTypes: true } }))!;+ (await prisma.user.findUnique({+ where: { id: store.user.id },+ include: { eventTypes: true },+ }))!;return {id: user.id,username: user.username,eventTypes: user.eventTypes,routingForms: user.routingForms,self,+ apiLogin: async () => apiLogin({ ...(await self()), password: user.username }, store.page),login: async () => login({ ...(await self()), password: user.username }, store.page),logout: async () => {await page.goto("/auth/logout");@@ -276,7 +280,10 @@ const createUserFixture = (user: UserWithIncludes, page: Page) => {getPaymentCredential: async () => getPaymentCredential(store.page),// ths is for developemnt only aimed to inject debugging messages in the metadata field of the userdebug: async (message: string | Record<string, JSONValue>) => {- await prisma.user.update({ where: { id: store.user.id }, data: { metadata: { debug: message } } });+ await prisma.user.update({+ where: { id: store.user.id },+ data: { metadata: { debug: message } },+ });},delete: async () => await prisma.user.delete({ where: { id: store.user.id } }),};@@ -342,6 +349,28 @@ export async function login(await page.waitForLoadState("networkidle");}+export async function apiLogin(+ user: Pick<Prisma.User, "username"> & Partial<Pick<Prisma.User, "password" | "email">>,+ page: Page+) {+ const csrfToken = await page+ .context()+ .request.get("/api/auth/csrf")+ .then((response) => response.json())+ .then((json) => json.csrfToken);+ const data = {+ email: user.email ?? `${user.username}@example.com`,+ password: user.password ?? user.username!,+ callbackURL: "http://localhost:3000/",+ redirect: "false",+ json: "true",+ csrfToken,+ };+ return page.context().request.post("/api/auth/callback/credentials", {+ data,+ });+}+export async function getPaymentCredential(page: Page) {await page.goto("/apps/stripe");diff --git a/apps/web/playwright/hash-my-url.e2e.ts b/apps/web/playwright/hash-my-url.e2e.tsindex 921a933c52b..fb817bbb8fd 100644--- a/apps/web/playwright/hash-my-url.e2e.ts+++ b/apps/web/playwright/hash-my-url.e2e.ts@@ -9,7 +9,7 @@ test.describe.configure({ mode: "parallel" });test.fixme("hash my url", () => {test.beforeEach(async ({ users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();});test.afterEach(async ({ users }) => {await users.deleteAll();diff --git a/apps/web/playwright/integrations-stripe.e2e.ts b/apps/web/playwright/integrations-stripe.e2e.tsindex fcd9cb013dd..6f4310dd915 100644--- a/apps/web/playwright/integrations-stripe.e2e.ts+++ b/apps/web/playwright/integrations-stripe.e2e.ts@@ -24,7 +24,7 @@ test.describe("Stripe integration", () => {test.describe("Stripe integration dashboard", () => {test("Can add Stripe integration", async ({ page, users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();await page.goto("/apps/installed");await user.getPaymentCredential();@@ -39,7 +39,7 @@ test.describe("Stripe integration", () => {test("Can book a paid booking", async ({ page, users }) => {const user = await users.create();const eventType = user.eventTypes.find((e) => e.slug === "paid");- await user.login();+ await user.apiLogin();await page.goto("/apps/installed");await user.getPaymentCredential();diff --git a/apps/web/playwright/integrations.e2e.ts b/apps/web/playwright/integrations.e2e.tsindex 5aea5a7f204..4f58b9ac775 100644--- a/apps/web/playwright/integrations.e2e.ts+++ b/apps/web/playwright/integrations.e2e.ts@@ -214,7 +214,7 @@ test.fixme("Integrations", () => {test.describe("Zoom App", () => {test("Can add integration", async ({ page, users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();await addZoomIntegration({ page });await page.waitForNavigation({url: (url) => {@@ -226,7 +226,7 @@ test.fixme("Integrations", () => {test("can choose zoom as a location during booking", async ({ page, users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();const eventType = await addLocationIntegrationToFirstEvent({ user });await addZoomIntegration({ page });await page.waitForNavigation({@@ -241,7 +241,7 @@ test.fixme("Integrations", () => {// POST https://api.zoom.us/v2/users/me/meetings// Verify Header-> Authorization: "Bearer " + accessToken,/**- * {+ * {topic: event.title,type: 2, // Means that this is a scheduled meetingstart_time: event.startTime,@@ -262,15 +262,15 @@ test.fixme("Integrations", () => {approval_type: 2,audio: "both",auto_recording: "none",- enforce_login: false,+ enforce_apiLogin: false,registrants_email_notification: true,},};- */+ */});test("Can disconnect from integration", async ({ page, users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();await addZoomIntegration({ page });await page.waitForNavigation({url: (url) => {@@ -299,7 +299,7 @@ test.fixme("Integrations", () => {test.describe("Hubspot App", () => {test("Can add integration", async ({ page, users }) => {const user = await users.create();- await user.login();+ await user.apiLogin();await addOauthBasedIntegration({page,slug: "hubspot",diff --git a/apps/web/playwright/lib/fixtures.ts b/apps/web/playwright/lib/fixtures.tsindex 7b86f34f752..11b583ceda3 100644--- a/apps/web/playwright/lib/fixtures.ts+++ b/apps/web/playwright/lib/fixtures.ts@@ -40,7 +40,7 @@ declare global {* @see https://playwright.dev/docs/test-fixtures*/export const test = base.extend<Fixtures>({- users: async ({ page }, use, workerInfo) => {+ users: async ({ page, context }, use, workerInfo) => {const usersFixture = createUsersFixture(page, workerInfo);await use(usersFixture);},diff --git a/apps/web/playwright/login.api.e2e.ts b/apps/web/playwright/login.api.e2e.tsnew file mode 100644index 00000000000..5cb7f331971--- /dev/null+++ b/apps/web/playwright/login.api.e2e.ts@@ -0,0 +1,21 @@+import { expect } from "@playwright/test";++import { test } from "./lib/fixtures";++test.describe.configure({ mode: "parallel" });+test.afterEach(({ users }) => users.deleteAll());++test.describe("Login with api request", () => {+ test("context request will share cookie storage with its browser context", async ({ page, users }) => {+ const pro = await users.create();+ await pro.apiLogin();++ const contextCookies = await page.context().cookies();+ const cookiesMap = new Map(contextCookies.map(({ name, value }) => [name, value]));++ // The browser context will already contain all the cookies from the API response.+ expect(cookiesMap.has("next-auth.csrf-token")).toBeTruthy();+ expect(cookiesMap.has("next-auth.callback-url")).toBeTruthy();+ expect(cookiesMap.has("next-auth.session-token")).toBeTruthy();+ });+});diff --git a/apps/web/playwright/manage-booking-questions.e2e.ts b/apps/web/playwright/manage-booking-questions.e2e.tsindex 4dae1c60b0d..fe6290daf10 100644--- a/apps/web/playwright/manage-booking-questions.e2e.ts+++ b/apps/web/playwright/manage-booking-questions.e2e.ts@@ -15,6 +15,7 @@ async function getLabelText(field: Locator) {return await field.locator("label").first().locator("span").first().innerText();}+test.describe.configure({ mode: "parallel" });test.describe("Manage Booking Questions", () => {test.afterEach(async ({ users }) => {await users.deleteAll();@@ -28,7 +29,7 @@ test.describe("Manage Booking Questions", () => {}, testInfo) => {// Considering there are many steps in it, it would need more than default test timeouttest.setTimeout(testInfo.timeout * 3);- const user = await createAndLoginUserWithEventTypes({ users });+ const user = await createAndLoginUserWithEventTypes({ users, page });const webhookReceiver = await addWebhook(user);@@ -51,7 +52,7 @@ test.describe("Manage Booking Questions", () => {}, testInfo) => {// Considering there are many steps in it, it would need more than default test timeouttest.setTimeout(testInfo.timeout * 3);- const user = await createAndLoginUserWithEventTypes({ users });+ const user = await createAndLoginUserWithEventTypes({ users, page });const team = await prisma.team.findFirst({where: {members: {@@ -247,6 +248,7 @@ async function bookTimeSlot({ page, name, email }: { page: Page; name: string; eawait page.fill('[name="email"]', email);await page.press('[name="email"]', "Enter");}+/*** 'option' starts from 1*/@@ -358,11 +360,20 @@ async function toggleQuestionRequireStatusAndSave({await saveEventType(page);}-async function createAndLoginUserWithEventTypes({ users }: { users: ReturnType<typeof createUsersFixture> }) {+async function createAndLoginUserWithEventTypes({+ users,+ page,+}: {+ users: ReturnType<typeof createUsersFixture>;+ page: Page;+}) {const user = await users.create(null, {hasTeam: true,});- await user.login();+ await user.apiLogin();+ await page.goto("/event-types");+ // We wait until loading is finished+ await page.waitForSelector('[data-testid="event-types"]');return user;}diff --git a/apps/web/playwright/managed-event-types.e2e.ts b/apps/web/playwright/managed-event-types.e2e.tsindex b365a030891..fcdac429f96 100644--- a/apps/web/playwright/managed-event-types.e2e.ts+++ b/apps/web/playwright/managed-event-types.e2e.ts@@ -11,7 +11,8 @@ test.describe("Managed Event Types tests", () => {// Creating the member user of the teamconst memberUser = await users.create();// First we work with owner user, logging in- await adminUser.login();+ await adminUser.apiLogin();+ await page.goto("/event-types");// Making sure page loads completelyawait page.waitForLoadState("networkidle");// Let's create a team@@ -58,7 +59,9 @@ test.describe("Managed Event Types tests", () => {// Now we need to accept the invitation as member and come back in as admin to// assign the member in the managed event typeawait adminUser.logout();- await memberUser.login();+ await memberUser.apiLogin();+ await page.goto("/event-types");+ // We wait until loading is finishedawait page.waitForSelector('[data-testid="event-types"]');await page.goto("/teams");await page.waitForLoadState("networkidle");@@ -67,7 +70,8 @@ test.describe("Managed Event Types tests", () => {await memberUser.logout();// Coming back as team owner to assign member user to managed event- await adminUser.login();+ await adminUser.apiLogin();+ await page.goto("/event-types");await page.waitForLoadState("networkidle");await page.locator('[data-testid="event-types"] a[title="managed"]').click();await page.locator('[data-testid="vertical-tab-assignment"]').click();@@ -78,7 +82,8 @@ test.describe("Managed Event Types tests", () => {await adminUser.logout();// Coming back as member user to see if there is a managed event present after assignment- await memberUser.login();+ await memberUser.apiLogin();+ await page.goto("/event-types");await page.waitForLoadState("networkidle");await expect(page.locator('[data-testid="event-types"] a[title="managed"]')).toBeVisible();});diff --git a/apps/web/playwright/onboarding.e2e.ts b/apps/web/playwright/onboarding.e2e.tsindex a36cc855a49..f70fe37261a 100644--- a/apps/web/playwright/onboarding.e2e.ts+++ b/apps/web/playwright/onboarding.e2e.ts@@ -11,8 +11,8 @@ test.describe("Onboarding", () => {test.describe("Onboarding v2", () => {test("Onboarding Flow", async ({ page, users }) => {const user = await users.create({ completedOnboarding: false, name: null });- await user.login();-+ await user.apiLogin();+ await page.goto("/getting-started");// tests whether the user makes it to /getting-started// after login with completedOnboarding falseawait page.waitForURL("/getting-started");diff --git a/apps/web/playwright/reschedule.e2e.ts b/apps/web/playwright/reschedule.e2e.tsindex b67821b1abe..01f75e87003 100644--- a/apps/web/playwright/reschedule.e2e.ts+++ b/apps/web/playwright/reschedule.e2e.ts@@ -25,7 +25,7 @@ testBothBookers.describe("Reschedule Tests", async () => {status: BookingStatus.ACCEPTED,});- await user.login();+ await user.apiLogin();await page.goto("/bookings/upcoming");await page.locator('[data-testid="edit_booking"]').nth(0).click();@@ -69,7 +69,7 @@ testBothBookers.describe("Reschedule Tests", async () => {rescheduled: true,});- await user.login();+ await user.apiLogin();await page.goto("/bookings/cancelled");const requestRescheduleSentElement = page.locator('[data-testid="request_reschedule_sent"]').nth(1);@@ -117,7 +117,7 @@ testBothBookers.describe("Reschedule Tests", async () => {// eslint-disable-next-line playwright/no-skipped-testtest.skip(!IS_STRIPE_ENABLED, "Skipped as Stripe is not installed");const user = await users.create();- await user.login();+ await user.apiLogin();await user.getPaymentCredential();// eslint-disable-next-line @typescript-eslint/no-non-null-assertionconst eventType = user.eventTypes.find((e) => e.slug === "paid")!;@@ -158,7 +158,7 @@ testBothBookers.describe("Reschedule Tests", async () => {test("Paid rescheduling should go to success page", async ({ page, users, bookings, payments }) => {const user = await users.create();- await user.login();+ await user.apiLogin();await user.getPaymentCredential();await users.logout();// eslint-disable-next-line @typescript-eslint/no-non-null-assertion@@ -207,7 +207,7 @@ testBothBookers.describe("Reschedule Tests", async () => {const booking = await bookings.create(user.id, user.username, eventType.id, {status: BookingStatus.ACCEPTED,});- await user.login();+ await user.apiLogin();await page.goto(`/${user.username}/${eventType.slug}?rescheduleUid=${booking.uid}`);diff --git a/apps/web/playwright/teams.e2e.ts b/apps/web/playwright/teams.e2e.tsindex 1305bf7222d..edc5a0757f3 100644--- a/apps/web/playwright/teams.e2e.ts+++ b/apps/web/playwright/teams.e2e.ts@@ -12,7 +12,7 @@ test.describe("Teams", () => {test("Can create teams via Wizard", async ({ page, users }) => {const user = await users.create();const inviteeEmail = `${user.username}[email protected]`;- await user.login();+ await user.apiLogin();await page.goto("/teams");await test.step("Can create team", async () => {diff --git a/apps/web/playwright/webhook.e2e.ts b/apps/web/playwright/webhook.e2e.tsindex a75a1fc64fa..851970dc8b3 100644--- a/apps/web/playwright/webhook.e2e.ts+++ b/apps/web/playwright/webhook.e2e.ts@@ -18,7 +18,7 @@ test.describe("BOOKING_CREATED", async () => {const webhookReceiver = createHttpServer();const user = await users.create();const [eventType] = user.eventTypes;- await user.login();+ await user.apiLogin();await page.goto(`/settings/developer/webhooks`);// --- add webhook@@ -154,7 +154,7 @@ test.describe("BOOKING_REJECTED", async () => {await bookOptinEvent(page);// --- login as that user- await user.login();+ await user.apiLogin();await page.goto(`/settings/developer/webhooks`);@@ -275,7 +275,7 @@ test.describe("BOOKING_REQUESTED", async () => {const user = await users.create();// --- login as that user- await user.login();+ await user.apiLogin();await page.goto(`/settings/developer/webhooks`);diff --git a/apps/web/playwright/wipe-my-cal.e2e.ts b/apps/web/playwright/wipe-my-cal.e2e.tsindex 47a327d625d..2ec682f221d 100644--- a/apps/web/playwright/wipe-my-cal.e2e.ts+++ b/apps/web/playwright/wipe-my-cal.e2e.ts@@ -35,7 +35,7 @@ test.describe("Wipe my Cal App Test", () => {);await bookings.create(pro.id, pro.username, eventType.id, {});await bookings.create(pro.id, pro.username, eventType.id, {});- await pro.login();+ await pro.apiLogin();await page.goto("/bookings/upcoming");await expect(page.locator("data-testid=wipe-today-button")).toBeVisible();