功能修改

This commit is contained in:
npc0-hue
2026-07-20 16:42:33 +08:00
parent 48b8ad8d6c
commit a0e69417db
224 changed files with 22015 additions and 884 deletions
+82 -1
View File
@@ -69,6 +69,75 @@ describe("first-party console pages", () => {
expect(html).not.toContain("sk-");
});
it("keeps unavailable overview modules visible instead of claiming an empty healthy state", () => {
const html = renderToStaticMarkup(
<HomePage
{...pageProps()}
initialState={{
core: {
status: "ready",
refreshedAt: "2026-07-18T10:00:00Z",
data: {
instances: [],
endpoints: [],
jobs: [
{
id: "job-failed-1",
serverInstanceId: "server-1",
runEndpointId: "endpoint-1",
capability: "server.lifecycle.start",
idempotencyKey: "idem-1",
state: "failed",
progress: { percent: 42 },
retryPolicy: { maxAttempts: 3, initialBackoffSeconds: 1, maxBackoffSeconds: 10 },
attempt: 3,
reconcileCount: 0,
createdAt: "2026-07-18T09:59:00Z",
updatedAt: "2026-07-18T10:00:00Z"
}
]
}
},
metrics: { status: "error", reason: "metrics unavailable", diagnosticId: "metrics-1" },
usage: { status: "error", reason: "usage unavailable", diagnosticId: "usage-1" },
providers: { status: "error", reason: "providers unavailable", diagnosticId: "providers-1" },
signals: { status: "error", reason: "audit unavailable", diagnosticId: "audit-1" }
}}
/>
);
expect(html).toContain("4 个模块不可用");
expect(html).toContain("资源指标不可用");
expect(html).toContain("审计信号不可用");
expect(html).toContain("AI 提供商信号不可用");
expect(html).toContain("server.lifecycle.start");
expect(html).not.toContain("暂无异常信号");
});
it("explains read-only overview access when the session cannot create servers", () => {
const readOnlySession: CurrentUserView = {
...adminUser,
roles: ["serverAdmin"],
capabilities: ["platform.overview.read", "servers.read"]
};
const html = renderToStaticMarkup(
<HomePage
{...pageProps()}
session={readOnlySession}
initialState={{
core: { status: "ready", data: { instances: [], endpoints: [], jobs: [] }, refreshedAt: "2026-07-18T10:00:00Z" },
metrics: { status: "ready", data: [], refreshedAt: "2026-07-18T10:00:00Z" },
usage: { status: "error", reason: "unavailable", diagnosticId: "usage" },
providers: { status: "ready", data: [], refreshedAt: "2026-07-18T10:00:00Z" },
signals: { status: "ready", data: [], refreshedAt: "2026-07-18T10:00:00Z" }
}}
/>
);
expect(html).toContain("没有创建服务器的权限");
expect(html).toContain("前往服务器管理");
});
it("renders the server list workspace with search and status filters", () => {
const html = renderToStaticMarkup(<ServersPage {...pageProps()} />);
@@ -80,7 +149,19 @@ describe("first-party console pages", () => {
expect(html).not.toContain("/Users/");
});
it("keeps server metrics unavailable and runtime commands permission-gated", () => {
expect(serversPageSource).toContain("metricsUnavailable");
expect(serversPageSource).toContain("指标不可用");
expect(serversPageSource).toContain("canManageServers");
expect(serversPageSource).toContain("当前账号没有运行操作权限");
expect(serversPageSource).toContain("failedJobs");
expect(serversPageSource).toContain("refreshMetrics");
expect(serversPageSource).toContain("onClick={() => void refreshMetrics()}");
});
it("submits declared runtime profiles and logical bindings from the create workflow", () => {
expect(serversPageSource).toContain("<ManagementDialog");
expect(serversPageSource).toContain('className="provider-form dialog-form"');
expect(serversPageSource).toContain('name="profileKey"');
expect(serversPageSource).toContain("runtimeBindingFields");
expect(serversPageSource).toContain("updateBinding(field.key");
@@ -136,7 +217,7 @@ describe("first-party console pages", () => {
expect(html).toContain("用户管理");
expect(html).toContain("Plugin Reviewer");
expect(html).toContain("needs approval");
expect(html).toContain("本地开发样例 / 禁止假成功");
expect(html).toContain("本地开发样例 / 仅查看");
});
it("renders maintenance triage entry points", () => {