mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 22:09:57 +00:00
test: cover heartbeat doctor and include migration paths
This commit is contained in:
@@ -600,6 +600,36 @@ describe("doctor config flow", () => {
|
||||
expectGoogleChatDmAllowFromRepaired(result.cfg);
|
||||
});
|
||||
|
||||
it("migrates top-level heartbeat into agents.defaults.heartbeat on repair", async () => {
|
||||
const result = await runDoctorConfigWithInput({
|
||||
repair: true,
|
||||
config: {
|
||||
heartbeat: {
|
||||
model: "anthropic/claude-3-5-haiku-20241022",
|
||||
every: "30m",
|
||||
},
|
||||
},
|
||||
run: loadAndMaybeMigrateDoctorConfig,
|
||||
});
|
||||
|
||||
const cfg = result.cfg as {
|
||||
heartbeat?: unknown;
|
||||
agents?: {
|
||||
defaults?: {
|
||||
heartbeat?: {
|
||||
model?: string;
|
||||
every?: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
expect(cfg.heartbeat).toBeUndefined();
|
||||
expect(cfg.agents?.defaults?.heartbeat).toMatchObject({
|
||||
model: "anthropic/claude-3-5-haiku-20241022",
|
||||
every: "30m",
|
||||
});
|
||||
});
|
||||
|
||||
it("repairs googlechat account dm.policy open by setting dm.allowFrom on repair", async () => {
|
||||
const result = await runDoctorConfigWithInput({
|
||||
repair: true,
|
||||
|
||||
@@ -43,4 +43,41 @@ describe("gateway startup legacy migration fallback", () => {
|
||||
);
|
||||
expect(message).not.toContain("Legacy config entries detected but auto-migration failed.");
|
||||
});
|
||||
|
||||
test("keeps detailed validation errors when heartbeat comes from include-resolved config", async () => {
|
||||
testState.legacyIssues = [
|
||||
{
|
||||
path: "heartbeat",
|
||||
message:
|
||||
"top-level heartbeat is not a valid config path; use agents.defaults.heartbeat instead.",
|
||||
},
|
||||
];
|
||||
// Simulate a parsed source that only contains include directives, while
|
||||
// legacy heartbeat is surfaced from the resolved config.
|
||||
testState.legacyParsed = {
|
||||
$include: ["heartbeat.defaults.json"],
|
||||
};
|
||||
testState.migrationConfig = null;
|
||||
testState.migrationChanges = [];
|
||||
|
||||
let server: Awaited<ReturnType<typeof startGatewayServer>> | undefined;
|
||||
let thrown: unknown;
|
||||
try {
|
||||
server = await startGatewayServer(await getFreePort());
|
||||
} catch (err) {
|
||||
thrown = err;
|
||||
}
|
||||
|
||||
if (server) {
|
||||
await server.close();
|
||||
}
|
||||
|
||||
expect(thrown).toBeInstanceOf(Error);
|
||||
const message = String((thrown as Error).message);
|
||||
expect(message).toContain("Invalid config at");
|
||||
expect(message).toContain(
|
||||
"heartbeat: top-level heartbeat is not a valid config path; use agents.defaults.heartbeat instead.",
|
||||
);
|
||||
expect(message).not.toContain("Legacy config entries detected but auto-migration failed.");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user