test: speed up skills-cli integration

This commit is contained in:
Peter Steinberger
2026-02-16 02:03:27 +00:00
parent 88033002ba
commit 38c91c5a13

View File

@@ -4,6 +4,7 @@ import path from "node:path";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import type { SkillStatusEntry, SkillStatusReport } from "../agents/skills-status.js";
import type { SkillEntry } from "../agents/skills.js";
import { captureEnv } from "../test-utils/env.js";
import { formatSkillInfo, formatSkillsCheck, formatSkillsList } from "./skills-cli.format.js";
// Unit tests: don't pay the runtime cost of loading/parsing the real skills loader.
@@ -218,15 +219,26 @@ describe("skills-cli", () => {
describe("integration: loads real skills from bundled directory", () => {
let tempWorkspaceDir = "";
let tempBundledDir = "";
let envSnapshot: ReturnType<typeof captureEnv>;
let buildWorkspaceSkillStatus: typeof import("../agents/skills-status.js").buildWorkspaceSkillStatus;
beforeAll(() => {
beforeAll(async () => {
envSnapshot = captureEnv(["OPENCLAW_BUNDLED_SKILLS_DIR"]);
tempWorkspaceDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-skills-test-"));
tempBundledDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-bundled-skills-test-"));
process.env.OPENCLAW_BUNDLED_SKILLS_DIR = tempBundledDir;
({ buildWorkspaceSkillStatus } = await import("../agents/skills-status.js"));
});
afterAll(() => {
if (tempWorkspaceDir) {
fs.rmSync(tempWorkspaceDir, { recursive: true, force: true });
}
if (tempBundledDir) {
fs.rmSync(tempBundledDir, { recursive: true, force: true });
}
envSnapshot.restore();
});
const createEntries = (): SkillEntry[] => {
@@ -247,7 +259,6 @@ describe("skills-cli", () => {
};
it("loads bundled skills and formats them", async () => {
const { buildWorkspaceSkillStatus } = await import("../agents/skills-status.js");
const entries = createEntries();
const report = buildWorkspaceSkillStatus(tempWorkspaceDir, {
managedSkillsDir: "/nonexistent",
@@ -271,7 +282,6 @@ describe("skills-cli", () => {
});
it("formats info for a real bundled skill (peekaboo)", async () => {
const { buildWorkspaceSkillStatus } = await import("../agents/skills-status.js");
const entries = createEntries();
const report = buildWorkspaceSkillStatus(tempWorkspaceDir, {
managedSkillsDir: "/nonexistent",