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

View File

@@ -0,0 +1,44 @@
// The Lucia project.
// Copyright 2026-2026 DSP, inc. All rights reserved.
// Authors:
// imacat.yang@dsp.im (imacat), 2026/03/22
import { test, expect } from "@playwright/test";
import { loginWithMSW } from "../helpers";
test.describe("404 Not Found Page", () => {
test("displays 404 page for non-existent route", async ({
page,
context,
}) => {
await loginWithMSW(context);
await page.goto("/this-page-does-not-exist");
await expect(page.getByText("404")).toBeVisible();
await expect(
page.getByText("The page you are looking for does not exist."),
).toBeVisible();
});
test("has a link back to Files page", async ({
page,
context,
}) => {
await loginWithMSW(context);
await page.goto("/some/random/path");
const link = page.getByRole("link", { name: "Go to Files" });
await expect(link).toBeVisible();
await expect(link).toHaveAttribute("href", "/files");
});
test("displays 404 for unauthenticated user on invalid route", async ({
page,
}) => {
await page.goto("/not-a-real-page");
const url = page.url();
if (url.includes("/login")) {
await expect(page).toHaveURL(/\/login/);
} else {
await expect(page.getByText("404")).toBeVisible();
}
});
});