52 lines
2.0 KiB
JavaScript
52 lines
2.0 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
B51_DEFAULT_THEME,
|
|
persistB51Theme,
|
|
resolveB51ForcedTheme,
|
|
resolveB51ThemeName,
|
|
} from "./b5-1-theme.ts";
|
|
|
|
const WORKSPACE = "/page/strategy/task-management/plan-task-b5-1/agent/analyst/chats";
|
|
|
|
test("non-b5-1 routes are untouched", () => {
|
|
assert.equal(resolveB51ForcedTheme("/page/workspace/chats/new"), undefined);
|
|
assert.equal(resolveB51ForcedTheme("/login"), undefined);
|
|
assert.equal(resolveB51ForcedTheme("/login?goPath=3qfx&taskId=1"), undefined);
|
|
assert.equal(resolveB51ForcedTheme("/login?goPath=agentfx"), undefined);
|
|
});
|
|
|
|
test("workspace defaults to deep blue (dark) without a theme param", () => {
|
|
assert.equal(resolveB51ForcedTheme(WORKSPACE), "dark");
|
|
assert.equal(resolveB51ForcedTheme(WORKSPACE, "?threadId=t1"), "dark");
|
|
assert.equal(B51_DEFAULT_THEME, "dark-blue");
|
|
});
|
|
|
|
test("supplied theme wins over the default", () => {
|
|
assert.equal(resolveB51ForcedTheme(WORKSPACE, "?theme=lightblue"), "light");
|
|
assert.equal(resolveB51ForcedTheme(WORKSPACE, "?theme=light"), "light");
|
|
assert.equal(resolveB51ForcedTheme(WORKSPACE, "?theme=dark-blue"), "dark");
|
|
assert.equal(resolveB51ForcedTheme(WORKSPACE, "?theme=%E6%B7%B1%E8%93%9D"), "dark");
|
|
});
|
|
|
|
test("b5-1 login page is forced too, case-insensitive on goPath", () => {
|
|
assert.equal(
|
|
resolveB51ForcedTheme("/login", "?taskId=1&goPath=b5-1"),
|
|
"dark",
|
|
);
|
|
assert.equal(
|
|
resolveB51ForcedTheme("/login", "?taskId=1&goPath=B5-1&theme=lightblue"),
|
|
"light",
|
|
);
|
|
});
|
|
|
|
test("theme resolution order falls back to the default without storage", () => {
|
|
assert.equal(resolveB51ThemeName(), "dark-blue");
|
|
assert.equal(resolveB51ThemeName("?theme=iceblue"), "iceblue");
|
|
// persistB51Theme 在无 sessionStorage 的环境(node 测试)里静默跳过,
|
|
// 浏览器里则登记后由 resolveB51ThemeName() 优先读 URL、其次读登记值。
|
|
persistB51Theme("lightgreen");
|
|
assert.equal(resolveB51ThemeName("?theme=dark"), "dark");
|
|
});
|