test(sandbox): use focused modules in lightweight suites

This commit is contained in:
Peter Steinberger
2026-02-24 01:45:58 +00:00
parent f0f886ecc4
commit 467666adc7
5 changed files with 14 additions and 23 deletions

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { buildSandboxCreateArgs, type SandboxDockerConfig } from "./sandbox.js";
import { buildSandboxCreateArgs } from "./sandbox/docker.js";
import type { SandboxDockerConfig } from "./sandbox/types.js";
describe("buildSandboxCreateArgs", () => {
function createSandboxConfig(

View File

@@ -1,10 +1,8 @@
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import {
formatSandboxToolPolicyBlockedMessage,
resolveSandboxConfigForAgent,
resolveSandboxToolPolicyForAgent,
} from "./sandbox.js";
import { resolveSandboxConfigForAgent } from "./sandbox/config.js";
import { formatSandboxToolPolicyBlockedMessage } from "./sandbox/runtime-status.js";
import { resolveSandboxToolPolicyForAgent } from "./sandbox/tool-policy.js";
describe("sandbox explain helpers", () => {
it("prefers agent overrides > global > defaults (sandbox tool policy)", () => {

View File

@@ -1,20 +1,12 @@
import { beforeAll, describe, expect, it } from "vitest";
let resolveSandboxScope: typeof import("./sandbox.js").resolveSandboxScope;
let resolveSandboxDockerConfig: typeof import("./sandbox.js").resolveSandboxDockerConfig;
let resolveSandboxBrowserConfig: typeof import("./sandbox.js").resolveSandboxBrowserConfig;
let resolveSandboxPruneConfig: typeof import("./sandbox.js").resolveSandboxPruneConfig;
import { describe, expect, it } from "vitest";
import {
resolveSandboxBrowserConfig,
resolveSandboxDockerConfig,
resolveSandboxPruneConfig,
resolveSandboxScope,
} from "./sandbox/config.js";
describe("sandbox config merges", () => {
beforeAll(async () => {
({
resolveSandboxScope,
resolveSandboxDockerConfig,
resolveSandboxBrowserConfig,
resolveSandboxPruneConfig,
} = await import("./sandbox.js"));
});
it("resolves sandbox scope deterministically", () => {
expect(resolveSandboxScope({})).toBe("agent");
expect(resolveSandboxScope({ perSession: true })).toBe("session");

View File

@@ -4,7 +4,7 @@ import path from "node:path";
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 { resolveSandboxContext } from "./sandbox/context.js";
import { writeSkill } from "./skills.e2e-test-helpers.js";
vi.mock("./sandbox/docker.js", () => ({

View File

@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { ensureSandboxWorkspaceForSession, resolveSandboxContext } from "./sandbox.js";
import { ensureSandboxWorkspaceForSession, resolveSandboxContext } from "./sandbox/context.js";
describe("resolveSandboxContext", () => {
it("does not sandbox the agent main session in non-main mode", async () => {