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("Password validation on create account.", () => {
test.beforeEach(async ({ page, context }) => {
await loginWithMSW(context);
await page.goto("/account-admin");
await expect(page.getByText("Test Admin").first()).toBeVisible();
});
test("When password is too short, confirm button stays disabled.", async ({
page,
}) => {
await page.getByRole("button", { name: "Create New" }).click();
await page.locator("#input_account_field").fill("unit-test-0001");
await page.locator("#input_name_field").fill("unit-test-0001");
// Password shorter than 6 characters
await page.locator("#input_first_pwd").fill("aaa");
await expect(
page.getByRole("button", { name: "Confirm" }),
).toBeDisabled();
});
test("When password meets minimum length, confirm button enables.", async ({
page,
}) => {
await page.getByRole("button", { name: "Create New" }).click();
await page.locator("#input_account_field").fill("unit-test-0001");
await page.locator("#input_name_field").fill("unit-test-0001");
await page.locator("#input_first_pwd").fill("aaaaaa");
await expect(
page.getByRole("button", { name: "Confirm" }),
).toBeEnabled();
});
});