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