mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 08:31:41 +00:00
test: reclassify doctor command suites out of e2e
This commit is contained in:
@@ -1,89 +0,0 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { createDoctorRuntime, mockDoctorConfigSnapshot, note } from "./doctor.e2e-harness.js";
|
||||
|
||||
let doctorCommand: typeof import("./doctor.js").doctorCommand;
|
||||
|
||||
describe("doctor command", () => {
|
||||
beforeAll(async () => {
|
||||
({ doctorCommand } = await import("./doctor.js"));
|
||||
});
|
||||
|
||||
it("warns when per-agent sandbox docker/browser/prune overrides are ignored under shared scope", async () => {
|
||||
mockDoctorConfigSnapshot({
|
||||
config: {
|
||||
agents: {
|
||||
defaults: {
|
||||
sandbox: {
|
||||
mode: "all",
|
||||
scope: "shared",
|
||||
},
|
||||
},
|
||||
list: [
|
||||
{
|
||||
id: "work",
|
||||
workspace: "~/openclaw-work",
|
||||
sandbox: {
|
||||
mode: "all",
|
||||
scope: "shared",
|
||||
docker: {
|
||||
setupCommand: "echo work",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
note.mockClear();
|
||||
|
||||
await doctorCommand(createDoctorRuntime(), { nonInteractive: true });
|
||||
|
||||
expect(
|
||||
note.mock.calls.some(([message, title]) => {
|
||||
if (title !== "Sandbox" || typeof message !== "string") {
|
||||
return false;
|
||||
}
|
||||
const normalized = message.replace(/\s+/g, " ").trim();
|
||||
return (
|
||||
normalized.includes('agents.list (id "work") sandbox docker') &&
|
||||
normalized.includes('scope resolves to "shared"')
|
||||
);
|
||||
}),
|
||||
).toBe(true);
|
||||
}, 30_000);
|
||||
|
||||
it("does not warn when only the active workspace is present", async () => {
|
||||
mockDoctorConfigSnapshot({
|
||||
config: {
|
||||
agents: { defaults: { workspace: "/Users/steipete/openclaw" } },
|
||||
},
|
||||
});
|
||||
|
||||
note.mockClear();
|
||||
const homedirSpy = vi.spyOn(os, "homedir").mockReturnValue("/Users/steipete");
|
||||
const realExists = fs.existsSync;
|
||||
const legacyPath = path.join("/Users/steipete", "openclaw");
|
||||
const legacyAgentsPath = path.join(legacyPath, "AGENTS.md");
|
||||
const existsSpy = vi.spyOn(fs, "existsSync").mockImplementation((value) => {
|
||||
if (
|
||||
value === "/Users/steipete/openclaw" ||
|
||||
value === legacyPath ||
|
||||
value === legacyAgentsPath
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return realExists(value as never);
|
||||
});
|
||||
|
||||
await doctorCommand(createDoctorRuntime(), { nonInteractive: true });
|
||||
|
||||
expect(note.mock.calls.some(([_, title]) => title === "Extra workspace")).toBe(false);
|
||||
|
||||
homedirSpy.mockRestore();
|
||||
existsSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user