|
1 | 1 | // Skills CLI tests cover skill listing, install, and command output behavior. |
2 | | -import { describe, expect, it, vi } from "vitest"; |
| 2 | +import { afterEach, describe, expect, it, vi } from "vitest"; |
3 | 3 | import type { SkillStatusEntry, SkillStatusReport } from "../skills/discovery/status.js"; |
4 | 4 | import { createEmptyInstallChecks } from "./requirements-test-fixtures.js"; |
5 | 5 | import { formatSkillInfo, formatSkillsCheck, formatSkillsList } from "./skills-cli.format.js"; |
@@ -51,6 +51,66 @@ function createMockReport(skills: SkillStatusEntry[]): SkillStatusReport { |
51 | 51 | } |
52 | 52 |
|
53 | 53 | describe("skills-cli", () => { |
| 54 | + afterEach(() => { |
| 55 | + vi.unstubAllEnvs(); |
| 56 | + }); |
| 57 | + |
| 58 | + describe("ClawHub command hints", () => { |
| 59 | + it.each([ |
| 60 | + { |
| 61 | + name: "named profile", |
| 62 | + profile: "work", |
| 63 | + container: "", |
| 64 | + prefix: "openclaw --profile work", |
| 65 | + }, |
| 66 | + { |
| 67 | + name: "managed container", |
| 68 | + profile: "", |
| 69 | + container: "demo", |
| 70 | + prefix: "openclaw --container demo", |
| 71 | + }, |
| 72 | + { |
| 73 | + name: "default profile", |
| 74 | + profile: "default", |
| 75 | + container: "", |
| 76 | + prefix: "openclaw", |
| 77 | + }, |
| 78 | + ])("preserves the $name on every human skill surface", ({ profile, container, prefix }) => { |
| 79 | + vi.stubEnv("OPENCLAW_PROFILE", profile); |
| 80 | + vi.stubEnv("OPENCLAW_CONTAINER_HINT", container); |
| 81 | + const report = createMockReport([]); |
| 82 | + const outputs = [ |
| 83 | + formatSkillsList(report, {}), |
| 84 | + formatSkillInfo(report, "missing-skill", {}), |
| 85 | + formatSkillsCheck(report, {}), |
| 86 | + ]; |
| 87 | + |
| 88 | + for (const output of outputs) { |
| 89 | + for (const action of ["search", "install", "update"]) { |
| 90 | + expect(output).toContain(`${prefix} skills ${action}`); |
| 91 | + } |
| 92 | + } |
| 93 | + }); |
| 94 | + |
| 95 | + it("keeps profile and container guidance out of machine-readable skill output", () => { |
| 96 | + vi.stubEnv("OPENCLAW_PROFILE", "work"); |
| 97 | + vi.stubEnv("OPENCLAW_CONTAINER_HINT", "demo"); |
| 98 | + const report = createMockReport([]); |
| 99 | + const outputs = [ |
| 100 | + formatSkillsList(report, { json: true }), |
| 101 | + formatSkillInfo(report, "missing-skill", { json: true }), |
| 102 | + formatSkillsCheck(report, { json: true }), |
| 103 | + ]; |
| 104 | + |
| 105 | + for (const output of outputs) { |
| 106 | + expect(() => JSON.parse(output)).not.toThrow(); |
| 107 | + expect(output).not.toContain("Tip:"); |
| 108 | + expect(output).not.toContain("openclaw --profile"); |
| 109 | + expect(output).not.toContain("openclaw --container"); |
| 110 | + } |
| 111 | + }); |
| 112 | + }); |
| 113 | + |
54 | 114 | describe("formatSkillsList", () => { |
55 | 115 | it("formats empty skills list", () => { |
56 | 116 | const report = createMockReport([]); |
|
0 commit comments