




























@@ -61,6 +61,16 @@ async function invokeSecretsReload(params: {
6161});
6262}
636364+type RespondCall = [boolean, unknown, { message?: string } | undefined];
65+66+function firstRespondCall(respond: ReturnType<typeof vi.fn>): RespondCall {
67+const call = respond.mock.calls[0];
68+if (!call) {
69+throw new Error("expected respond call");
70+}
71+return call as RespondCall;
72+}
73+6474// Other gateway test helpers (e.g. test-helpers.mocks.ts, test-helpers.server.ts)
6575// set OPENCLAW_SKIP_CHANNELS / OPENCLAW_SKIP_PROVIDERS at module load. When a
6676// shared vitest worker imports those helpers before this file's tests run,
@@ -273,10 +283,10 @@ describe("gateway aux handlers", () => {
273283// The handler surfaces the partial-failure so the caller can retry/alert
274284// instead of treating a swallowed restart error as a successful rotation.
275285expect(respond.mock.calls).toHaveLength(1);
276-const [okFlag, successPayload, errorPayload] = respond.mock.calls.at(0) ?? [];
286+const [okFlag, successPayload, errorPayload] = firstRespondCall(respond);
277287expect(okFlag).toBe(false);
278288expect(successPayload).toBeUndefined();
279-expect(String(errorPayload?.message ?? "")).toBe("secrets.reload failed");
289+expect(errorPayload?.message ?? "").toBe("secrets.reload failed");
280290expect(getActiveSecretsRuntimeSnapshot()?.config).toEqual(
281291asConfig({
282292channels: {
@@ -351,7 +361,7 @@ describe("gateway aux handlers", () => {
351361// stopChannel(zalo) rejected.
352362expect(startChannel.mock.calls.map(([ch]) => ch)).toEqual(["slack", "slack", "zalo"]);
353363expect(respond.mock.calls).toHaveLength(1);
354-expect(respond.mock.calls.at(0)?.[0]).toBe(false);
364+expect(firstRespondCall(respond)[0]).toBe(false);
355365});
356366357367it("restores both current and required shared-gateway generation on reload failure", async () => {
@@ -403,7 +413,7 @@ describe("gateway aux handlers", () => {
403413expect(sharedGatewaySessionGenerationState.current).toBe("gen-a");
404414expect(sharedGatewaySessionGenerationState.required).toBe("gen-a");
405415expect(respond.mock.calls).toHaveLength(1);
406-expect(respond.mock.calls.at(0)?.[0]).toBe(false);
416+expect(firstRespondCall(respond)[0]).toBe(false);
407417});
408418409419it("fails reload when channel restarts are required but skip flags block them", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。