fix(plugins): 插件管理 - 强化开关状态配色与文案 (#330)
This commit is contained in:
26
web/test/plugin-state-switch.test.ts
Normal file
26
web/test/plugin-state-switch.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
describe("plugin state switches", () => {
|
||||
test("uses a page-scoped green and neutral switch palette", () => {
|
||||
const styles = readFileSync(resolve(import.meta.dir, "../src/styles/globals.css"), "utf8");
|
||||
|
||||
expect(styles).toContain("--plugin-switch-checked-bg: #15803d;");
|
||||
expect(styles).toContain("--plugin-switch-checked-bg: #16a34a;");
|
||||
expect(styles).toContain("--plugin-switch-off-bg: #d4d4d8;");
|
||||
expect(styles).toContain("--plugin-switch-off-bg: #3f3f46;");
|
||||
expect(styles).toContain(":where(.plugin-state-switch.ant-switch.ant-switch-checked)");
|
||||
expect(styles).toContain(":where(.plugin-state-switch.ant-switch:not(.ant-switch-checked))");
|
||||
});
|
||||
|
||||
test("shows explicit state text on both plugin pages", () => {
|
||||
const userPage = readFileSync(resolve(import.meta.dir, "../src/pages/plugins/index.tsx"), "utf8");
|
||||
const adminPage = readFileSync(resolve(import.meta.dir, "../src/pages/admin/plugins/plugins-page.tsx"), "utf8");
|
||||
|
||||
expect(userPage).toContain('className="plugin-state-switch"');
|
||||
expect(userPage).toContain('enabled ? "已启用" : "已停用"');
|
||||
expect(adminPage).toContain('className="plugin-state-switch"');
|
||||
expect(adminPage).toContain('available ? "平台开放" : "平台停用"');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user