From 0fa4b2fb46f2009467e090a7ec79eeff94561241 Mon Sep 17 00:00:00 2001 From: Shakker Date: Mon, 11 May 2026 20:13:27 +0100 Subject: [PATCH] test: check status json audit shape --- src/commands/status-json.test.ts | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/commands/status-json.test.ts b/src/commands/status-json.test.ts index 9dce77a5be3..1a4e09f6921 100644 --- a/src/commands/status-json.test.ts +++ b/src/commands/status-json.test.ts @@ -95,8 +95,23 @@ describe("statusJsonCommand", () => { await statusJsonCommand({}, runtime); expect(mocks.runSecurityAudit).not.toHaveBeenCalled(); - expect(logs).toHaveLength(1); - expect(JSON.parse(logs[0] ?? "{}")).not.toHaveProperty("securityAudit"); + expect(logs).toStrictEqual([expect.any(String)]); + const payload = JSON.parse(logs[0] ?? "{}") as Record; + expect(payload).toMatchObject({ + ok: true, + configuredChannels: [], + os: { platform: "linux" }, + update: { installKind: "npm", git: { tag: null, branch: null } }, + updateChannel: "stable", + updateChannelSource: "config", + memory: null, + memoryPlugin: null, + gatewayService: { installed: false }, + nodeService: { installed: false }, + agents: [], + secretDiagnostics: [], + }); + expect(payload).not.toHaveProperty("securityAudit"); }); it("includes security audit details only when --all is requested", async () => { @@ -130,7 +145,14 @@ describe("statusJsonCommand", () => { "telegram", "whatsapp", ]); - expect(logs).toHaveLength(1); - expect(JSON.parse(logs[0] ?? "{}")).toHaveProperty("securityAudit.summary.critical", 1); + expect(logs).toStrictEqual([expect.any(String)]); + const payload = JSON.parse(logs[0] ?? "{}") as Record; + expect(payload).toMatchObject({ + ok: true, + securityAudit: { + summary: { critical: 1, warn: 0, info: 0 }, + findings: [], + }, + }); }); });