Add Playwright E2E tests replacing Cypress with MSW integration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
77
tests/e2e/specs/navigation.spec.ts
Normal file
77
tests/e2e/specs/navigation.spec.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
// 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("Navigation and Routing", () => {
|
||||
test("redirects / to /files when logged in", async ({
|
||||
page,
|
||||
context,
|
||||
}) => {
|
||||
await loginWithMSW(context);
|
||||
await page.goto("/");
|
||||
await expect(page).toHaveURL(/\/files/);
|
||||
});
|
||||
|
||||
test("shows 404 page for unknown routes", async ({ page, context }) => {
|
||||
await loginWithMSW(context);
|
||||
await page.goto("/nonexistent-page");
|
||||
await expect(page.getByText("404")).toBeVisible();
|
||||
});
|
||||
|
||||
test("navbar shows correct view name", async ({ page, context }) => {
|
||||
await loginWithMSW(context);
|
||||
await page.goto("/files");
|
||||
await expect(page.getByText("sample-process.xes").first()).toBeVisible();
|
||||
await expect(page.locator("#nav_bar")).toBeVisible();
|
||||
await expect(page.locator("#nav_bar h2")).toContainText("FILES");
|
||||
});
|
||||
|
||||
test("navbar shows back arrow on non-files pages", async ({
|
||||
page,
|
||||
context,
|
||||
}) => {
|
||||
await loginWithMSW(context);
|
||||
await page.goto("/discover/log/1/map");
|
||||
// Back arrow should be visible on discover pages
|
||||
await expect(page.locator("#backPage")).toBeVisible();
|
||||
});
|
||||
|
||||
test("navbar tabs are clickable on discover page", async ({
|
||||
page,
|
||||
context,
|
||||
}) => {
|
||||
await loginWithMSW(context);
|
||||
await page.goto("/discover/log/1/map");
|
||||
// Discover navbar should show MAP, CONFORMANCE, PERFORMANCE tabs
|
||||
await expect(
|
||||
page.locator(".nav-item", { hasText: "MAP" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.locator(".nav-item", { hasText: "CONFORMANCE" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.locator(".nav-item", { hasText: "PERFORMANCE" }),
|
||||
).toBeVisible();
|
||||
|
||||
// Click CONFORMANCE tab
|
||||
await page.locator(".nav-item", { hasText: "CONFORMANCE" }).click();
|
||||
await expect(page).toHaveURL(/\/conformance/);
|
||||
|
||||
// Click PERFORMANCE tab
|
||||
await page.locator(".nav-item", { hasText: "PERFORMANCE" }).click();
|
||||
await expect(page).toHaveURL(/\/performance/);
|
||||
|
||||
// Click MAP tab to go back
|
||||
await page.locator(".nav-item", { hasText: "MAP" }).click();
|
||||
await expect(page).toHaveURL(/\/map/);
|
||||
});
|
||||
|
||||
test("login page is accessible at /login", async ({ page }) => {
|
||||
await page.goto("/login");
|
||||
await expect(page.getByRole("heading", { name: "LOGIN" }).first()).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user