


















@@ -101,14 +101,10 @@ describe("gateway status output", () => {
101101discoveryCount: 0,
102102});
103103104-expect(warnings).toContainEqual(
105-expect.objectContaining({
106-code: "no_gateway_reachable",
107-message: expect.stringContaining("openclaw gateway status --deep --require-rpc"),
108-targetIds: ["localLoopback"],
109-}),
110-);
111-expect(warnings.at(0)?.message).toContain("lsof -nP -iTCP:<port>");
104+const warning = warnings.find((entry) => entry.code === "no_gateway_reachable");
105+expect(warning?.message).toContain("openclaw gateway status --deep --require-rpc");
106+expect(warning?.targetIds).toStrictEqual(["localLoopback"]);
107+expect(warning?.message).toContain("lsof -nP -iTCP:<port>");
112108});
113109114110it("derives summary capability from reachable probes only in json output", () => {
@@ -145,13 +141,13 @@ describe("gateway status output", () => {
145141primaryTargetId: "reachable-read",
146142});
147143148-expect(mocks.writeRuntimeJson).toHaveBeenCalledWith(
149- runtime,
150- expect.objectContaining({
151- ok: true,
152- capability: "read_only",
153- }),
154-);
144+expect(mocks.writeRuntimeJson).toHaveBeenCalledOnce();
145+expect(mocks.writeRuntimeJson.mock.calls[0]?.[0]).toBe(runtime);
146+const payload = mocks.writeRuntimeJson.mock.calls[0]?.[1] as
147+| { ok?: unknown; capability?: unknown }
148+| undefined;
149+expect(payload?.ok).toBe(true);
150+expect(payload?.capability).toBe("read_only");
155151});
156152157153it("derives summary capability from reachable probes only in text output", () => {
@@ -219,22 +215,22 @@ describe("gateway status output", () => {
219215primaryTargetId: "detail-timeout",
220216});
221217222-expect(mocks.writeRuntimeJson).toHaveBeenCalledWith(
223- runtime,
224- expect.objectContaining({
225- ok: true,
226-degraded: true,
227-primaryTargetId: "detail-timeout",
228-targets: [
229-expect.objectContaining({
230- connect: expect.objectContaining({
231- ok: true,
232- rpcOk: false,
233- error: "timeout",
234- }),
235- }),
236- ],
237- }),
238-);
218+expect(mocks.writeRuntimeJson).toHaveBeenCalledOnce();
219+expect(mocks.writeRuntimeJson.mock.calls[0]?.[0]).toBe(runtime);
220+const payload = mocks.writeRuntimeJson.mock.calls[0]?.[1] as
221+| {
222+ ok?: unknown;
223+ degraded?: unknown;
224+ primaryTargetId?: unknown;
225+targets?: Array<{ connect?: { ok?: unknown; rpcOk?: unknown; error?: unknown } }>;
226+}
227+| undefined;
228+expect(payload?.ok).toBe(true);
229+expect(payload?.degraded).toBe(true);
230+expect(payload?.primaryTargetId).toBe("detail-timeout");
231+expect(payload?.targets).toHaveLength(1);
232+expect(payload?.targets?.[0]?.connect?.ok).toBe(true);
233+expect(payload?.targets?.[0]?.connect?.rpcOk).toBe(false);
234+expect(payload?.targets?.[0]?.connect?.error).toBe("timeout");
239235});
240236});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。