Add Playwright E2E tests replacing Cypress with MSW integration
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
72
tests/e2e/specs/logout.spec.ts
Normal file
72
tests/e2e/specs/logout.spec.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
// 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("Logout Flow", () => {
|
||||
test.beforeEach(async ({ context }) => {
|
||||
await loginWithMSW(context);
|
||||
});
|
||||
|
||||
test("shows account menu when head icon is clicked", async ({ page }) => {
|
||||
await page.goto("/files");
|
||||
await expect(page.getByText("sample-process.xes").first()).toBeVisible();
|
||||
|
||||
// Click the head icon to open account menu
|
||||
await page.locator("#acct_mgmt_button").click();
|
||||
await expect(page.locator("#account_menu")).toBeVisible();
|
||||
await expect(page.locator("#greeting")).toContainText("Test Admin");
|
||||
});
|
||||
|
||||
test("account menu shows admin management link for admin user", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/files");
|
||||
await expect(page.getByText("sample-process.xes").first()).toBeVisible();
|
||||
|
||||
await page.locator("#acct_mgmt_button").click();
|
||||
await expect(page.locator("#account_menu")).toBeVisible();
|
||||
// Admin user should see account management option
|
||||
await expect(page.locator("#btn_acct_mgmt")).toBeVisible();
|
||||
});
|
||||
|
||||
test("account menu has logout button", async ({ page }) => {
|
||||
await page.goto("/files");
|
||||
await expect(page.getByText("sample-process.xes").first()).toBeVisible();
|
||||
|
||||
await page.locator("#acct_mgmt_button").click();
|
||||
await expect(page.locator("#btn_logout_in_menu")).toBeVisible();
|
||||
});
|
||||
|
||||
test("clicking My Account navigates to /my-account", async ({ page }) => {
|
||||
await page.goto("/files");
|
||||
await expect(page.getByText("sample-process.xes").first()).toBeVisible();
|
||||
|
||||
await page.locator("#acct_mgmt_button").click();
|
||||
await page.locator("#btn_mang_ur_acct").click();
|
||||
await expect(page).toHaveURL(/\/my-account/);
|
||||
});
|
||||
|
||||
test("clicking Account Management navigates to /account-admin", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/files");
|
||||
await expect(page.getByText("sample-process.xes").first()).toBeVisible();
|
||||
|
||||
await page.locator("#acct_mgmt_button").click();
|
||||
await page.locator("#btn_acct_mgmt").click();
|
||||
await expect(page).toHaveURL(/\/account-admin/);
|
||||
});
|
||||
|
||||
test("logout redirects to login page", async ({ page }) => {
|
||||
await page.goto("/files");
|
||||
await expect(page.getByText("sample-process.xes").first()).toBeVisible();
|
||||
|
||||
await page.locator("#acct_mgmt_button").click();
|
||||
await page.locator("#btn_logout_in_menu").click();
|
||||
await expect(page).toHaveURL(/\/login/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user