mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:20:43 +00:00
fix: keep control ui slash commands browser-safe
This commit is contained in:
34
ui/src/ui/chat/slash-commands.browser-import.test.ts
Normal file
34
ui/src/ui/chat/slash-commands.browser-import.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
// @vitest-environment node
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("slash command browser import", () => {
|
||||
it("builds fallback commands from the browser-safe shared registry", async () => {
|
||||
const mod = await import("./slash-commands.ts?browser-import");
|
||||
|
||||
expect(mod.SLASH_COMMANDS.find((command) => command.name === "think")).toMatchObject({
|
||||
name: "think",
|
||||
category: "model",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps provider thinking runtime out of the Control UI import path", async () => {
|
||||
const slashCommands = await readFile(new URL("./slash-commands.ts", import.meta.url), "utf8");
|
||||
const sharedRegistry = await readFile(
|
||||
new URL("../../../../src/auto-reply/commands-registry.shared.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const serverRegistry = await readFile(
|
||||
new URL("../../../../src/auto-reply/commands-registry.data.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const mod = await import("./slash-commands.ts?browser-import");
|
||||
|
||||
expect(mod.SLASH_COMMANDS.some((command) => command.name === "think")).toBe(true);
|
||||
expect(slashCommands).toContain("commands-registry.shared.js");
|
||||
expect(sharedRegistry).toContain("thinking.shared.js");
|
||||
expect(sharedRegistry).not.toContain("./thinking.js");
|
||||
expect(sharedRegistry).not.toContain("provider-thinking");
|
||||
expect(serverRegistry).toContain('from "./thinking.js"');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user