refactor(test): reuse env helper in workspace skill status tests

This commit is contained in:
Peter Steinberger
2026-02-21 18:41:28 +00:00
parent cf371fde6d
commit c0706b7799

View File

@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { withEnv } from "../test-utils/env.js";
import { buildWorkspaceSkillStatus } from "./skills-status.js";
import { writeSkill } from "./skills.e2e-test-helpers.js";
@@ -60,7 +61,6 @@ describe("buildWorkspaceSkillStatus", () => {
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
const bundledDir = path.join(workspaceDir, ".bundled");
const bundledSkillDir = path.join(bundledDir, "peekaboo");
const originalBundled = process.env.OPENCLAW_BUNDLED_SKILLS_DIR;
await writeSkill({
dir: bundledSkillDir,
@@ -69,8 +69,7 @@ describe("buildWorkspaceSkillStatus", () => {
body: "# Peekaboo\n",
});
try {
process.env.OPENCLAW_BUNDLED_SKILLS_DIR = bundledDir;
withEnv({ OPENCLAW_BUNDLED_SKILLS_DIR: bundledDir }, () => {
const report = buildWorkspaceSkillStatus(workspaceDir, {
managedSkillsDir: path.join(workspaceDir, ".managed"),
config: { skills: { allowBundled: ["other-skill"] } },
@@ -80,13 +79,7 @@ describe("buildWorkspaceSkillStatus", () => {
expect(skill).toBeDefined();
expect(skill?.blockedByAllowlist).toBe(true);
expect(skill?.eligible).toBe(false);
} finally {
if (originalBundled === undefined) {
delete process.env.OPENCLAW_BUNDLED_SKILLS_DIR;
} else {
process.env.OPENCLAW_BUNDLED_SKILLS_DIR = originalBundled;
}
}
});
});
it("filters install options by OS", async () => {