mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 05:03:44 +00:00
refactor(test): centralize doctor e2e runtime and snapshot scaffolding
This commit is contained in:
@@ -2,16 +2,11 @@ import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { note, readConfigFileSnapshot } from "./doctor.e2e-harness.js";
|
||||
import { createDoctorRuntime, mockDoctorConfigSnapshot, note } from "./doctor.e2e-harness.js";
|
||||
|
||||
describe("doctor command", () => {
|
||||
it("warns when per-agent sandbox docker/browser/prune overrides are ignored under shared scope", async () => {
|
||||
readConfigFileSnapshot.mockResolvedValue({
|
||||
path: "/tmp/openclaw.json",
|
||||
exists: true,
|
||||
raw: "{}",
|
||||
parsed: {},
|
||||
valid: true,
|
||||
mockDoctorConfigSnapshot({
|
||||
config: {
|
||||
agents: {
|
||||
defaults: {
|
||||
@@ -35,20 +30,12 @@ describe("doctor command", () => {
|
||||
],
|
||||
},
|
||||
},
|
||||
issues: [],
|
||||
legacyIssues: [],
|
||||
});
|
||||
|
||||
note.mockClear();
|
||||
|
||||
const { doctorCommand } = await import("./doctor.js");
|
||||
const runtime = {
|
||||
log: vi.fn(),
|
||||
error: vi.fn(),
|
||||
exit: vi.fn(),
|
||||
};
|
||||
|
||||
await doctorCommand(runtime, { nonInteractive: true });
|
||||
await doctorCommand(createDoctorRuntime(), { nonInteractive: true });
|
||||
|
||||
expect(
|
||||
note.mock.calls.some(([message, title]) => {
|
||||
@@ -65,17 +52,10 @@ describe("doctor command", () => {
|
||||
}, 30_000);
|
||||
|
||||
it("does not warn when only the active workspace is present", async () => {
|
||||
readConfigFileSnapshot.mockResolvedValue({
|
||||
path: "/tmp/openclaw.json",
|
||||
exists: true,
|
||||
raw: "{}",
|
||||
parsed: {},
|
||||
valid: true,
|
||||
mockDoctorConfigSnapshot({
|
||||
config: {
|
||||
agents: { defaults: { workspace: "/Users/steipete/openclaw" } },
|
||||
},
|
||||
issues: [],
|
||||
legacyIssues: [],
|
||||
});
|
||||
|
||||
note.mockClear();
|
||||
@@ -95,13 +75,7 @@ describe("doctor command", () => {
|
||||
});
|
||||
|
||||
const { doctorCommand } = await import("./doctor.js");
|
||||
const runtime = {
|
||||
log: vi.fn(),
|
||||
error: vi.fn(),
|
||||
exit: vi.fn(),
|
||||
};
|
||||
|
||||
await doctorCommand(runtime, { nonInteractive: true });
|
||||
await doctorCommand(createDoctorRuntime(), { nonInteractive: true });
|
||||
|
||||
expect(note.mock.calls.some(([_, title]) => title === "Extra workspace")).toBe(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user