diff --git a/src/commands/gateway-status/output.test.ts b/src/commands/gateway-status/output.test.ts index 48d464b78c23..c11f8b47ab0d 100644 --- a/src/commands/gateway-status/output.test.ts +++ b/src/commands/gateway-status/output.test.ts @@ -224,15 +224,51 @@ describe("gateway status output", () => { ok?: unknown; degraded?: unknown; primaryTargetId?: unknown; - targets?: Array<{ connect?: { ok?: unknown; rpcOk?: unknown; error?: unknown } }>; + targets?: unknown; + warnings?: unknown; } | undefined; - expect(payload?.ok).toBe(true); - expect(payload?.degraded).toBe(true); - expect(payload?.primaryTargetId).toBe("detail-timeout"); - expect(payload?.targets).toHaveLength(1); - expect(payload?.targets?.[0]?.connect?.ok).toBe(true); - expect(payload?.targets?.[0]?.connect?.rpcOk).toBe(false); - expect(payload?.targets?.[0]?.connect?.error).toBe("timeout"); + expect(payload).toStrictEqual( + expect.objectContaining({ + degraded: true, + ok: true, + primaryTargetId: "detail-timeout", + targets: [ + expect.objectContaining({ + active: true, + auth: { + capability: "read_only", + role: "operator", + scopes: ["operator.read"], + }, + config: null, + connect: { + close: null, + error: "timeout", + latencyMs: 40, + ok: true, + rpcOk: false, + scopeLimited: false, + }, + health: null, + id: "detail-timeout", + kind: "explicit", + presence: null, + self: null, + summary: null, + tunnel: null, + url: "ws://127.0.0.1:18789", + }), + ], + warnings: [ + { + code: "probe_detail_failed", + message: + "Gateway accepted the WebSocket connection, but follow-up read diagnostics failed: timeout", + targetIds: ["detail-timeout"], + }, + ], + }), + ); }); }); diff --git a/src/commands/models/auth-list.test.ts b/src/commands/models/auth-list.test.ts index 71c7eca69532..938e0ecc0d13 100644 --- a/src/commands/models/auth-list.test.ts +++ b/src/commands/models/auth-list.test.ts @@ -94,25 +94,26 @@ describe("modelsAuthListCommand", () => { cfg: {}, provider: "openai-codex", }); - expect(runtime.jsonPayloads).toHaveLength(1); + expect(runtime.jsonPayloads).toStrictEqual([ + expect.objectContaining({ + agentDir: "/tmp/openclaw/agents/coder", + agentId: "coder", + authStatePath: "/tmp/openclaw/agents/coder/auth-state.json", + profiles: [ + { + cooldownUntil: "2027-01-15T08:00:10.000Z", + email: "user@example.com", + expiresAt: "2027-01-15T08:00:00.000Z", + id: "openai-codex:user@example.com", + label: "openai-codex:user@example.com", + provider: "openai-codex", + type: "oauth", + }, + ], + provider: "openai-codex", + }), + ]); expect(JSON.stringify(runtime.jsonPayloads[0])).not.toContain("secret"); - const payload = runtime.jsonPayloads[0] as - | { - agentId?: unknown; - provider?: unknown; - profiles?: Array>; - } - | undefined; - expect(payload?.agentId).toBe("coder"); - expect(payload?.provider).toBe("openai-codex"); - expect(payload?.profiles).toHaveLength(1); - const [profile] = payload?.profiles ?? []; - expect(profile?.id).toBe("openai-codex:user@example.com"); - expect(profile?.provider).toBe("openai-codex"); - expect(profile?.type).toBe("oauth"); - expect(profile?.email).toBe("user@example.com"); - expect(profile?.expiresAt).toBe("2027-01-15T08:00:00.000Z"); - expect(profile?.cooldownUntil).toBe("2027-01-15T08:00:10.000Z"); }); it("prints an empty profile list without failing", async () => {