refactor(test): reuse shared skill writer in sandbox and bundled tests

This commit is contained in:
Peter Steinberger
2026-02-21 18:54:48 +00:00
parent 96ef00ec38
commit f086245afe
2 changed files with 7 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { captureFullEnv } from "../test-utils/env.js";
import { resolveSandboxContext } from "./sandbox.js";
import { writeSkill } from "./skills.e2e-test-helpers.js";
vi.mock("./sandbox/docker.js", () => ({
ensureSandboxContainer: vi.fn(async () => "openclaw-sbx-test"),
@@ -18,16 +19,6 @@ vi.mock("./sandbox/prune.js", () => ({
maybePruneSandboxes: vi.fn(async () => undefined),
}));
async function writeSkill(params: { dir: string; name: string; description: string }) {
const { dir, name, description } = params;
await fs.mkdir(dir, { recursive: true });
await fs.writeFile(
path.join(dir, "SKILL.md"),
`---\nname: ${name}\ndescription: ${description}\n---\n\n# ${name}\n`,
"utf-8",
);
}
describe("sandbox skill mirroring", () => {
let envSnapshot: ReturnType<typeof captureFullEnv>;

View File

@@ -4,17 +4,9 @@ import path from "node:path";
import { pathToFileURL } from "node:url";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { captureEnv } from "../../test-utils/env.js";
import { writeSkill } from "../skills.e2e-test-helpers.js";
import { resolveBundledSkillsDir } from "./bundled-dir.js";
async function writeSkill(dir: string, name: string) {
await fs.mkdir(dir, { recursive: true });
await fs.writeFile(
path.join(dir, "SKILL.md"),
`---\nname: ${name}\ndescription: ${name}\n---\n\n# ${name}\n`,
"utf-8",
);
}
describe("resolveBundledSkillsDir", () => {
let envSnapshot: ReturnType<typeof captureEnv>;
@@ -38,7 +30,11 @@ describe("resolveBundledSkillsDir", () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-bundled-"));
await fs.writeFile(path.join(root, "package.json"), JSON.stringify({ name: "openclaw" }));
await writeSkill(path.join(root, "skills", "peekaboo"), "peekaboo");
await writeSkill({
dir: path.join(root, "skills", "peekaboo"),
name: "peekaboo",
description: "peekaboo",
});
const distDir = path.join(root, "dist");
await fs.mkdir(distDir, { recursive: true });