功能修改
This commit is contained in:
@@ -2,6 +2,7 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { UsersPage } from "./UsersPage";
|
||||
import usersPageSource from "./UsersPage.tsx?raw";
|
||||
import type { UserResponse } from "../api/types";
|
||||
import type { PageComponentProps } from "../contracts/page";
|
||||
import { capabilitiesForRoles, type CurrentUserView } from "../contracts/workspace";
|
||||
@@ -66,11 +67,22 @@ describe("UsersPage", () => {
|
||||
expect(html).not.toContain("Plugin Reviewer");
|
||||
});
|
||||
|
||||
it("renders API failure without substituting actionable sample users", () => {
|
||||
const html = renderToStaticMarkup(<UsersPage {...pageProps()} initialState={{ users: [], loading: false, source: "api", loadError: "backend unavailable" }} />);
|
||||
|
||||
expect(html).toContain("用户 API 暂不可用");
|
||||
expect(html).toContain("backend unavailable");
|
||||
expect(html).toContain("重试");
|
||||
expect(html).not.toContain("local.example.test");
|
||||
expect(usersPageSource).toContain("setUsers([])");
|
||||
expect(usersPageSource).not.toContain("fallbackUsers");
|
||||
});
|
||||
|
||||
it("renders explicit local-development fixture state with a single status flow", () => {
|
||||
const html = renderToStaticMarkup(<UsersPage {...pageProps()} initialState={{ users: [managedUser], loading: false, source: "local-development" }} />);
|
||||
|
||||
expect(html).toContain("Plugin Reviewer");
|
||||
expect(html).toContain("本地开发样例 / 禁止假成功");
|
||||
expect(html).toContain("本地开发样例 / 仅查看");
|
||||
expect(html).toContain("编辑");
|
||||
expect(html).toContain("状态");
|
||||
expect(html).toContain("应用状态");
|
||||
@@ -91,6 +103,23 @@ describe("UsersPage", () => {
|
||||
expect(html).not.toContain('aria-label="编辑用户"');
|
||||
});
|
||||
|
||||
it("renders full-width user search and role/status filters", () => {
|
||||
const html = renderToStaticMarkup(<UsersPage {...pageProps()} initialState={{ users: [managedUser], loading: false, source: "api" }} />);
|
||||
|
||||
expect(html).toContain("搜索名称、邮箱或用户 ID");
|
||||
expect(html).toContain("按角色筛选");
|
||||
expect(html).toContain("按状态筛选");
|
||||
expect(html).toContain("平台管理员");
|
||||
expect(html).toContain("服务器管理员");
|
||||
});
|
||||
|
||||
it("prevents duplicate create and edit submissions while session operations are pending", () => {
|
||||
expect(usersPageSource).toContain('operations.isPending("users", "邀请用户")');
|
||||
expect(usersPageSource).toContain('operations.isPending(editingUserId, "编辑用户")');
|
||||
expect(usersPageSource).toContain("createPending ? \"发送中…\"");
|
||||
expect(usersPageSource).toContain("editPending ? \"保存中…\"");
|
||||
});
|
||||
|
||||
it("does not render account maintenance controls for non-admins", () => {
|
||||
const html = renderToStaticMarkup(<UsersPage {...pageProps(serverUser)} initialState={{ users: [managedUser], loading: false, source: "api" }} />);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user