mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:50:49 +00:00
test(doctor): share legacy config step harness
This commit is contained in:
@@ -3,32 +3,39 @@ import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import type { DoctorConfigPreflightResult } from "../../doctor-config-preflight.js";
|
||||
import { applyLegacyCompatibilityStep, applyUnknownConfigKeyStep } from "./config-flow-steps.js";
|
||||
|
||||
function createLegacyStepResult(
|
||||
snapshot: DoctorConfigPreflightResult["snapshot"],
|
||||
doctorFixCommand = "openclaw doctor --fix",
|
||||
) {
|
||||
return applyLegacyCompatibilityStep({
|
||||
snapshot,
|
||||
state: {
|
||||
cfg: {},
|
||||
candidate: {},
|
||||
pendingChanges: false,
|
||||
fixHints: [],
|
||||
},
|
||||
shouldRepair: false,
|
||||
doctorFixCommand,
|
||||
});
|
||||
}
|
||||
|
||||
describe("doctor config flow steps", () => {
|
||||
it("collects legacy compatibility issue lines and preview fix hints", () => {
|
||||
const result = applyLegacyCompatibilityStep({
|
||||
snapshot: {
|
||||
exists: true,
|
||||
parsed: { heartbeat: { enabled: true } },
|
||||
legacyIssues: [{ path: "heartbeat", message: "use agents.defaults.heartbeat" }],
|
||||
path: "/tmp/config.json",
|
||||
valid: true,
|
||||
issues: [],
|
||||
raw: "{}",
|
||||
resolved: {},
|
||||
sourceConfig: {},
|
||||
config: {},
|
||||
runtimeConfig: {},
|
||||
warnings: [],
|
||||
} satisfies DoctorConfigPreflightResult["snapshot"],
|
||||
state: {
|
||||
cfg: {},
|
||||
candidate: {},
|
||||
pendingChanges: false,
|
||||
fixHints: [],
|
||||
},
|
||||
shouldRepair: false,
|
||||
doctorFixCommand: "openclaw doctor --fix",
|
||||
});
|
||||
const result = createLegacyStepResult({
|
||||
exists: true,
|
||||
parsed: { heartbeat: { enabled: true } },
|
||||
legacyIssues: [{ path: "heartbeat", message: "use agents.defaults.heartbeat" }],
|
||||
path: "/tmp/config.json",
|
||||
valid: true,
|
||||
issues: [],
|
||||
raw: "{}",
|
||||
resolved: {},
|
||||
sourceConfig: {},
|
||||
config: {},
|
||||
runtimeConfig: {},
|
||||
warnings: [],
|
||||
} satisfies DoctorConfigPreflightResult["snapshot"]);
|
||||
|
||||
expect(result.issueLines).toEqual([expect.stringContaining("- heartbeat:")]);
|
||||
expect(result.changeLines).not.toEqual([]);
|
||||
@@ -39,35 +46,25 @@ describe("doctor config flow steps", () => {
|
||||
});
|
||||
|
||||
it("keeps pending repair state for legacy issues even when the snapshot is already normalized", () => {
|
||||
const result = applyLegacyCompatibilityStep({
|
||||
snapshot: {
|
||||
exists: true,
|
||||
parsed: { talk: { voiceId: "voice-1", modelId: "eleven_v3" } },
|
||||
legacyIssues: [
|
||||
{
|
||||
path: "talk",
|
||||
message: "talk.voiceId/talk.voiceAliases/talk.modelId/talk.outputFormat/talk.apiKey",
|
||||
},
|
||||
],
|
||||
path: "/tmp/config.json",
|
||||
valid: true,
|
||||
issues: [],
|
||||
raw: "{}",
|
||||
resolved: {},
|
||||
sourceConfig: {},
|
||||
config: {},
|
||||
runtimeConfig: {},
|
||||
warnings: [],
|
||||
} satisfies DoctorConfigPreflightResult["snapshot"],
|
||||
state: {
|
||||
cfg: {},
|
||||
candidate: {},
|
||||
pendingChanges: false,
|
||||
fixHints: [],
|
||||
},
|
||||
shouldRepair: false,
|
||||
doctorFixCommand: "openclaw doctor --fix",
|
||||
});
|
||||
const result = createLegacyStepResult({
|
||||
exists: true,
|
||||
parsed: { talk: { voiceId: "voice-1", modelId: "eleven_v3" } },
|
||||
legacyIssues: [
|
||||
{
|
||||
path: "talk",
|
||||
message: "talk.voiceId/talk.voiceAliases/talk.modelId/talk.outputFormat/talk.apiKey",
|
||||
},
|
||||
],
|
||||
path: "/tmp/config.json",
|
||||
valid: true,
|
||||
issues: [],
|
||||
raw: "{}",
|
||||
resolved: {},
|
||||
sourceConfig: {},
|
||||
config: {},
|
||||
runtimeConfig: {},
|
||||
warnings: [],
|
||||
} satisfies DoctorConfigPreflightResult["snapshot"]);
|
||||
|
||||
expect(result.changeLines).toEqual([]);
|
||||
expect(result.state.pendingChanges).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user