105 lines
3.6 KiB
TypeScript
105 lines
3.6 KiB
TypeScript
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { HomePage } from "./HomePage";
|
|
import { PluginsPage } from "./PluginsPage";
|
|
import { ProfileSettingsPage } from "./ProfileSettingsPage";
|
|
import { ServerDetailPage } from "./ServerDetailPage";
|
|
import { ServersPage } from "./ServersPage";
|
|
import { UsersPage } from "./UsersPage";
|
|
import type { PageComponentProps } from "../contracts/page";
|
|
import { capabilitiesForRoles, type CurrentUserView } from "../contracts/workspace";
|
|
import type { OperationTracker } from "../stores/operations";
|
|
|
|
const adminUser: CurrentUserView = {
|
|
id: "user-admin",
|
|
displayName: "Operator",
|
|
status: "active",
|
|
roles: ["platformAdmin"],
|
|
capabilities: capabilitiesForRoles(["platformAdmin"]),
|
|
profile: {},
|
|
source: "local"
|
|
};
|
|
|
|
const noopOperations: OperationTracker = {
|
|
operations: [],
|
|
begin: () => "op-test",
|
|
update: () => undefined,
|
|
succeed: () => undefined,
|
|
fail: () => undefined,
|
|
isPending: () => false
|
|
};
|
|
|
|
function pageProps(params: PageComponentProps["params"] = {}): PageComponentProps {
|
|
return {
|
|
session: adminUser,
|
|
params,
|
|
operations: noopOperations,
|
|
onNavigate: () => undefined,
|
|
onLogout: async () => undefined,
|
|
onProfileSave: async () => adminUser,
|
|
onThemePreferenceSave: async () => ({ userId: adminUser.id, paletteId: "mecha-black", backgroundPresetId: "mecha-grid", persistence: "api", updatedAt: "2026-07-03T00:00:00Z" })
|
|
};
|
|
}
|
|
|
|
describe("first-party console pages", () => {
|
|
it("renders the platform overview with first-screen health modules", () => {
|
|
const html = renderToStaticMarkup(<HomePage {...pageProps()} />);
|
|
|
|
expect(html).toContain("平台概览");
|
|
expect(html).toContain("资源负载");
|
|
expect(html).toContain("游戏类型分布");
|
|
expect(html).toContain("最近运营信号");
|
|
expect(html).not.toContain("sk-");
|
|
});
|
|
|
|
it("renders the server list workspace with search and status filters", () => {
|
|
const html = renderToStaticMarkup(<ServersPage {...pageProps()} />);
|
|
|
|
expect(html).toContain("服务器管理");
|
|
expect(html).toContain("搜索服务器");
|
|
expect(html).toContain("在线");
|
|
expect(html).toContain("离线");
|
|
expect(html).not.toContain("run socket");
|
|
expect(html).not.toContain("/Users/");
|
|
});
|
|
|
|
it("renders server detail sections for daily operations", () => {
|
|
const html = renderToStaticMarkup(<ServerDetailPage {...pageProps({ serverId: "server-example-1" })} />);
|
|
|
|
expect(html).toContain("返回列表");
|
|
expect(html).toContain("概览");
|
|
expect(html).toContain("日志");
|
|
expect(html).toContain("配置");
|
|
expect(html).toContain("插件控制");
|
|
expect(html).toContain("AI 助手");
|
|
expect(html).toContain("操作历史");
|
|
});
|
|
|
|
it("renders plugin catalog bridge readiness", () => {
|
|
const html = renderToStaticMarkup(<PluginsPage />);
|
|
|
|
expect(html).toContain("插件市场");
|
|
expect(html).toContain("平台 API");
|
|
expect(html).toContain("正在加载插件市场");
|
|
expect(html).not.toContain("billing");
|
|
});
|
|
|
|
it("renders user access review context", () => {
|
|
const html = renderToStaticMarkup(<UsersPage {...pageProps()} />);
|
|
|
|
expect(html).toContain("用户管理");
|
|
expect(html).toContain("Plugin Reviewer");
|
|
expect(html).toContain("needs approval");
|
|
});
|
|
|
|
it("renders profile settings as a full page", () => {
|
|
const html = renderToStaticMarkup(<ProfileSettingsPage {...pageProps()} />);
|
|
|
|
expect(html).toContain("个人设置");
|
|
expect(html).toContain("个人资料");
|
|
expect(html).toContain("界面偏好");
|
|
expect(html).not.toContain("role=\"dialog\"");
|
|
});
|
|
});
|