Files
lucia-frontend/tests/e2e/helpers.ts
2026-03-22 18:43:18 +08:00

31 lines
726 B
TypeScript

// The Lucia project.
// Copyright 2026-2026 DSP, inc. All rights reserved.
// Authors:
// imacat.yang@dsp.im (imacat), 2026/03/22
import { type BrowserContext } from "@playwright/test";
/**
* Sets authentication cookies to simulate a logged-in user.
* MSW handles all API interception via the service worker.
* @param context - Playwright browser context.
*/
export async function loginWithMSW(
context: BrowserContext,
): Promise<void> {
await context.addCookies([
{
name: "luciaToken",
value: "fake-access-token-for-testing",
domain: "localhost",
path: "/",
},
{
name: "isLuciaLoggedIn",
value: "true",
domain: "localhost",
path: "/",
},
]);
}