mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
test: exercise command json payloads
This commit is contained in:
@@ -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"],
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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<Record<string, unknown>>;
|
||||
}
|
||||
| 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 () => {
|
||||
|
||||
Reference in New Issue
Block a user