Add Playwright E2E tests replacing Cypress with MSW integration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 16:43:32 +08:00
parent 67a723207f
commit aa2661b556
33 changed files with 2284 additions and 7 deletions

30
tests/e2e/helpers.ts Normal file
View 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: "/",
},
]);
}