mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:21:35 +00:00
test: speed up skills-cli integration
This commit is contained in:
@@ -4,6 +4,7 @@ import path from "node:path";
|
|||||||
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
||||||
import type { SkillStatusEntry, SkillStatusReport } from "../agents/skills-status.js";
|
import type { SkillStatusEntry, SkillStatusReport } from "../agents/skills-status.js";
|
||||||
import type { SkillEntry } from "../agents/skills.js";
|
import type { SkillEntry } from "../agents/skills.js";
|
||||||
|
import { captureEnv } from "../test-utils/env.js";
|
||||||
import { formatSkillInfo, formatSkillsCheck, formatSkillsList } from "./skills-cli.format.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.
|
// 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", () => {
|
describe("integration: loads real skills from bundled directory", () => {
|
||||||
let tempWorkspaceDir = "";
|
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-"));
|
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(() => {
|
afterAll(() => {
|
||||||
if (tempWorkspaceDir) {
|
if (tempWorkspaceDir) {
|
||||||
fs.rmSync(tempWorkspaceDir, { recursive: true, force: true });
|
fs.rmSync(tempWorkspaceDir, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
|
if (tempBundledDir) {
|
||||||
|
fs.rmSync(tempBundledDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
envSnapshot.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
const createEntries = (): SkillEntry[] => {
|
const createEntries = (): SkillEntry[] => {
|
||||||
@@ -247,7 +259,6 @@ describe("skills-cli", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
it("loads bundled skills and formats them", async () => {
|
it("loads bundled skills and formats them", async () => {
|
||||||
const { buildWorkspaceSkillStatus } = await import("../agents/skills-status.js");
|
|
||||||
const entries = createEntries();
|
const entries = createEntries();
|
||||||
const report = buildWorkspaceSkillStatus(tempWorkspaceDir, {
|
const report = buildWorkspaceSkillStatus(tempWorkspaceDir, {
|
||||||
managedSkillsDir: "/nonexistent",
|
managedSkillsDir: "/nonexistent",
|
||||||
@@ -271,7 +282,6 @@ describe("skills-cli", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("formats info for a real bundled skill (peekaboo)", async () => {
|
it("formats info for a real bundled skill (peekaboo)", async () => {
|
||||||
const { buildWorkspaceSkillStatus } = await import("../agents/skills-status.js");
|
|
||||||
const entries = createEntries();
|
const entries = createEntries();
|
||||||
const report = buildWorkspaceSkillStatus(tempWorkspaceDir, {
|
const report = buildWorkspaceSkillStatus(tempWorkspaceDir, {
|
||||||
managedSkillsDir: "/nonexistent",
|
managedSkillsDir: "/nonexistent",
|
||||||
|
|||||||
Reference in New Issue
Block a user