refactor(test): consolidate doctor health and sandbox fixtures

This commit is contained in:
Peter Steinberger
2026-02-16 16:48:46 +00:00
parent 2d8edf85ad
commit 0d51869c3c
5 changed files with 133 additions and 109 deletions

View File

@@ -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);