Add Playwright E2E tests replacing Cypress with MSW integration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
30
tests/e2e/helpers.ts
Normal file
30
tests/e2e/helpers.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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: "/",
|
||||
},
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user