mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 12:18:37 +00:00
test(sandbox): use focused modules in lightweight suites
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
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", () => {
|
describe("buildSandboxCreateArgs", () => {
|
||||||
function createSandboxConfig(
|
function createSandboxConfig(
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import {
|
import { resolveSandboxConfigForAgent } from "./sandbox/config.js";
|
||||||
formatSandboxToolPolicyBlockedMessage,
|
import { formatSandboxToolPolicyBlockedMessage } from "./sandbox/runtime-status.js";
|
||||||
resolveSandboxConfigForAgent,
|
import { resolveSandboxToolPolicyForAgent } from "./sandbox/tool-policy.js";
|
||||||
resolveSandboxToolPolicyForAgent,
|
|
||||||
} from "./sandbox.js";
|
|
||||||
|
|
||||||
describe("sandbox explain helpers", () => {
|
describe("sandbox explain helpers", () => {
|
||||||
it("prefers agent overrides > global > defaults (sandbox tool policy)", () => {
|
it("prefers agent overrides > global > defaults (sandbox tool policy)", () => {
|
||||||
|
|||||||
@@ -1,20 +1,12 @@
|
|||||||
import { beforeAll, describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
import {
|
||||||
let resolveSandboxScope: typeof import("./sandbox.js").resolveSandboxScope;
|
resolveSandboxBrowserConfig,
|
||||||
let resolveSandboxDockerConfig: typeof import("./sandbox.js").resolveSandboxDockerConfig;
|
resolveSandboxDockerConfig,
|
||||||
let resolveSandboxBrowserConfig: typeof import("./sandbox.js").resolveSandboxBrowserConfig;
|
resolveSandboxPruneConfig,
|
||||||
let resolveSandboxPruneConfig: typeof import("./sandbox.js").resolveSandboxPruneConfig;
|
resolveSandboxScope,
|
||||||
|
} from "./sandbox/config.js";
|
||||||
|
|
||||||
describe("sandbox config merges", () => {
|
describe("sandbox config merges", () => {
|
||||||
beforeAll(async () => {
|
|
||||||
({
|
|
||||||
resolveSandboxScope,
|
|
||||||
resolveSandboxDockerConfig,
|
|
||||||
resolveSandboxBrowserConfig,
|
|
||||||
resolveSandboxPruneConfig,
|
|
||||||
} = await import("./sandbox.js"));
|
|
||||||
});
|
|
||||||
|
|
||||||
it("resolves sandbox scope deterministically", () => {
|
it("resolves sandbox scope deterministically", () => {
|
||||||
expect(resolveSandboxScope({})).toBe("agent");
|
expect(resolveSandboxScope({})).toBe("agent");
|
||||||
expect(resolveSandboxScope({ perSession: true })).toBe("session");
|
expect(resolveSandboxScope({ perSession: true })).toBe("session");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import path from "node:path";
|
|||||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import { captureFullEnv } from "../test-utils/env.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";
|
import { writeSkill } from "./skills.e2e-test-helpers.js";
|
||||||
|
|
||||||
vi.mock("./sandbox/docker.js", () => ({
|
vi.mock("./sandbox/docker.js", () => ({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import { ensureSandboxWorkspaceForSession, resolveSandboxContext } from "./sandbox.js";
|
import { ensureSandboxWorkspaceForSession, resolveSandboxContext } from "./sandbox/context.js";
|
||||||
|
|
||||||
describe("resolveSandboxContext", () => {
|
describe("resolveSandboxContext", () => {
|
||||||
it("does not sandbox the agent main session in non-main mode", async () => {
|
it("does not sandbox the agent main session in non-main mode", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user