mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 15:48:28 +00:00
refactor(test): consolidate doctor health and sandbox fixtures
This commit is contained in:
@@ -8,6 +8,13 @@ import { healthCommand } from "./health.js";
|
||||
const callGatewayMock = vi.fn();
|
||||
const logWebSelfIdMock = vi.fn();
|
||||
|
||||
function createRecentSessionRows(now = Date.now()) {
|
||||
return [
|
||||
{ key: "main", updatedAt: now - 60_000, age: 60_000 },
|
||||
{ key: "foo", updatedAt: null, age: null },
|
||||
];
|
||||
}
|
||||
|
||||
vi.mock("../gateway/call.js", () => ({
|
||||
callGateway: (...args: unknown[]) => callGatewayMock(...args),
|
||||
}));
|
||||
@@ -56,6 +63,7 @@ describe("healthCommand (coverage)", () => {
|
||||
});
|
||||
|
||||
it("prints the rich text summary when linked and configured", async () => {
|
||||
const recent = createRecentSessionRows();
|
||||
callGatewayMock.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
ts: Date.now(),
|
||||
@@ -104,20 +112,14 @@ describe("healthCommand (coverage)", () => {
|
||||
sessions: {
|
||||
path: "/tmp/sessions.json",
|
||||
count: 2,
|
||||
recent: [
|
||||
{ key: "main", updatedAt: Date.now() - 60_000, age: 60_000 },
|
||||
{ key: "foo", updatedAt: null, age: null },
|
||||
],
|
||||
recent,
|
||||
},
|
||||
},
|
||||
],
|
||||
sessions: {
|
||||
path: "/tmp/sessions.json",
|
||||
count: 2,
|
||||
recent: [
|
||||
{ key: "main", updatedAt: Date.now() - 60_000, age: 60_000 },
|
||||
{ key: "foo", updatedAt: null, age: null },
|
||||
],
|
||||
recent,
|
||||
},
|
||||
} satisfies HealthSummary);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user