Files
modelstudioai__cli/packages/commands/tests/agent-launch.test.ts
inhai 9ab5de8c2e feat(config-ui): enrich config UI with skills, MCP, agents, assets and model catalog
- Add Skills / MCP / Agents / Assets inventory views with click-to-open
  right-side detail drawers (reusable infoDrawer)
- Render SKILL.md as Markdown via a self-contained, XSS-safe inline renderer
  (HTML-escape first, strip YAML frontmatter, no external deps)
- Add local vs remote origin badges to Skills and MCP items
- Add quick-launch for coding agents (allowlisted id->binary, execFile, no
  shell); gate the button on Connected AND the CLI binary being on PATH
- Add per-category model catalog surfaced as click-to-fill suggestion chips
  under each default_*_model field, sourced from real bl pipeline model names
- Add assets browser (categorized, time-sorted) with preview, open-locally
  and delete, backed by path-traversal-guarded file serving
- Convert Profiles to a tile grid with an add-tile and design-consistent
  new-profile modal; make view headers sticky and use drawers for editing
- Tests for inventory, agent-launch, assets and config-ui endpoints
2026-07-21 21:54:27 +08:00

32 lines
1.2 KiB
TypeScript

import { expect, test } from "vite-plus/test";
import {
AGENT_COMMANDS,
agentCommand,
agentLaunchable,
launchAgent,
} from "../src/commands/config/agent-launch.ts";
test("agentCommand 返回已知 agent 的可执行命令,未知返回 undefined", () => {
expect(agentCommand("qwen-code")).toBe("qwen");
expect(agentCommand("codex")).toBe("codex");
expect(agentCommand("nope")).toBeUndefined();
// Guards against prototype keys leaking through the allowlist lookup.
expect(agentCommand("toString")).toBeUndefined();
});
test("AGENT_COMMANDS 覆盖所有已知 agent id", () => {
expect(Object.keys(AGENT_COMMANDS).sort()).toEqual(
["claude-code", "codex", "hermes", "opencode", "openclaw", "qwen-code"].sort(),
);
});
test("launchAgent 对未知 id 抛错且不启动任何进程", async () => {
await expect(launchAgent("definitely-not-an-agent")).rejects.toThrow(/Unknown agent/);
});
test("agentLaunchable 对未知 id 返回 false,不探测 PATH", async () => {
expect(await agentLaunchable("definitely-not-an-agent")).toBe(false);
// Prototype keys must not resolve to a launchable command either.
expect(await agentLaunchable("toString")).toBe(false);
});