cal/apps/web/playwright/login.api.e2e.ts
Efraín Rochín 17d106cfda
chore: Replace UI login with api login on e2e tests (#9344)
* Replace the ui login with api login

* test api login

* go to first page after login in some tests

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-06-06 18:02:32 +00:00

22 lines
846 B
TypeScript

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();
});
});