refactor(admin): 管理后台 - 收敛重复边框并提升运维信息密度

This commit is contained in:
ddCat
2026-09-22 06:09:03 +08:00
parent 0b285f66e8
commit 505d6076cc
18 changed files with 489 additions and 167 deletions

View File

@@ -0,0 +1,35 @@
import { expect, test } from "bun:test";
import { adminDensityStorageKey, normalizeAdminDensity } from "../src/pages/admin/components/admin-density";
import { logBillingLabel, logStatus, normalizeLogView } from "../src/pages/admin/logs/log-view";
test("后台默认紧凑,密度偏好按账号隔离且拒绝无效值", () => {
expect(normalizeAdminDensity(null)).toBe("compact");
expect(normalizeAdminDensity("invalid")).toBe("compact");
expect(normalizeAdminDensity("comfortable")).toBe("comfortable");
expect(adminDensityStorageKey("ops:a")).not.toBe(adminDensityStorageKey("ops:b"));
expect(adminDensityStorageKey("ops:a")).toContain("ops%3Aa");
});
test("请求视图默认排障,全部字段和账务仍可单独读取", () => {
expect(normalizeLogView(null)).toBe("troubleshoot");
expect(normalizeLogView("unknown")).toBe("troubleshoot");
expect(normalizeLogView("billing")).toBe("billing");
expect(normalizeLogView("all")).toBe("all");
});
test("供应商进行中与失败状态优先于 HTTP 成功,失败不会变绿", () => {
expect(logStatus({ status: "succeeded", providerStatus: "RUNNING" }).tone).toBe("warning");
for (const providerStatus of ["failed", "cancelled", "canceled", "expired"]) {
expect(logStatus({ status: "succeeded", providerStatus }).tone).toBe("error");
}
expect(logStatus({ status: "failed", providerStatus: "running" }).tone).toBe("error");
expect(logStatus({ status: "succeeded" }).tone).toBe("success");
});
test("账务视图区分不计费、未扣积分、预授权与真实结算", () => {
expect(logBillingLabel({ billable: false, billingAvailable: false })).toBe("不计费");
expect(logBillingLabel({ billable: true, billingAvailable: false, billingStatus: "settled" })).toBe("未扣积分");
expect(logBillingLabel({ billable: true, billingAvailable: true })).toBe("已预授权");
expect(logBillingLabel({ billable: true, billingAvailable: true, billingStatus: "refunded" })).toBe("已退回");
expect(logBillingLabel({ billable: true, billingAvailable: true, billingStatus: "uncertain" })).toBe("待核对");
});

View File

@@ -361,8 +361,8 @@ test("admin console tokens and shell stay isolated from the user workspace", asy
Bun.file(new URL("../src/styles/globals.css", import.meta.url)).text(),
]);
expect(tokens).toContain("--admin-canvas: #f5f5f5;");
expect(tokens).toContain("--admin-canvas: #0f0f0f;");
expect(tokens).toContain("--admin-canvas: #f7f8fa;");
expect(tokens).toContain("--admin-canvas: #111317;");
expect(tokens).not.toContain("--admin-layer-0: var(--workspace-");
expect(tokens).not.toContain("--admin-layer-0: var(--skin-admin-");
expect(shell).toContain("data-admin-root");