From c0706b7799f137db2772e879d869f93eadbf2cc0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 21 Feb 2026 18:41:28 +0000 Subject: [PATCH] refactor(test): reuse env helper in workspace skill status tests --- .../skills.buildworkspaceskillstatus.e2e.test.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/agents/skills.buildworkspaceskillstatus.e2e.test.ts b/src/agents/skills.buildworkspaceskillstatus.e2e.test.ts index eca3ca853..2a3b4cff4 100644 --- a/src/agents/skills.buildworkspaceskillstatus.e2e.test.ts +++ b/src/agents/skills.buildworkspaceskillstatus.e2e.test.ts @@ -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 () => {