feat: 重做管理后台的导航、表单和登录页

This commit is contained in:
Nixevol
2026-10-19 16:47:19 +08:00
parent 8beacfb931
commit 9c33ba1431
29 changed files with 794 additions and 321 deletions
+11 -7
View File
@@ -22,14 +22,18 @@ async function loadRuntime(): Promise<RuntimeInfo> {
async function login(page: Page, password: string) {
await page.goto("/login");
await page.getByPlaceholder("admin").fill("admin");
await page.getByPlaceholder("请输入用户名").fill("admin");
await page.getByPlaceholder("请输入密码").fill(password);
await page.getByTestId("login-submit").click();
await expect(page).toHaveURL(/\/overview/);
}
function nav(page: Page, label: string) {
return page.locator(".n-menu").getByText(label, { exact: true }).click();
async function nav(page: Page, label: string) {
const item = page.locator(".n-menu").getByText(label, { exact: true });
if (!(await item.isVisible())) {
await page.locator(".n-menu").getByText("通讯", { exact: true }).click();
}
await item.click();
}
async function createPeerViaAdmin(
@@ -90,7 +94,7 @@ test.describe("后台主路径 W4", () => {
const rt = await loadRuntime();
await login(page, rt.adminPassword);
await nav(page, "端");
await nav(page, "设备端");
await expect(page).toHaveURL(/\/endpoints/);
await page.getByRole("button", { name: "开通", exact: true }).click();
await page.getByTestId("create-id").locator("input").fill("w4ep001");
@@ -104,8 +108,8 @@ test.describe("后台主路径 W4", () => {
// 管理接口开通第二端(已知密码),供 MQTT 造未完成投递;管理 messages 只读
await createPeerViaAdmin(request, rt.httpBase, rt.adminPassword, "w4ep002", "password12ab");
await nav(page, "注册设置");
await expect(page).toHaveURL(/\/registration/);
await nav(page, "设置");
await expect(page).toHaveURL(/\/settings/);
await expect(page.getByTestId("reg-code-missing")).toBeVisible();
await page.getByTestId("reg-code").locator("input").fill("w4-reg-code-01");
await page.getByTestId("reg-save-code").click();
@@ -113,7 +117,7 @@ test.describe("后台主路径 W4", () => {
await page.getByTestId("reg-enabled").click();
await expect(page.getByText("已开启自助注册")).toBeVisible();
await nav(page, "群");
await nav(page, "群组");
await expect(page).toHaveURL(/\/groups/);
await page.getByTestId("group-create-open").click();
await page.getByTestId("group-name").locator("input").fill("W4测试群");