


























@@ -89,13 +89,18 @@ function expectFields(value: unknown, expected: Record<string, unknown>): void {
8989}
90909191function readFirstCallArg(mock: ReturnType<typeof vi.fn>): Record<string, unknown> {
92-const [arg] = mock.mock.calls.at(0) ?? [];
92+const [arg] = mock.mock.calls[0] ?? [];
9393if (!arg || typeof arg !== "object") {
9494throw new Error("expected first call argument object");
9595}
9696return arg as Record<string, unknown>;
9797}
989899+function readFirstLogMessage(runtime: { log: ReturnType<typeof vi.fn> }): string {
100+const [message] = runtime.log.mock.calls[0] ?? [];
101+return String(message);
102+}
103+99104function findCallArg(
100105mock: ReturnType<typeof vi.fn>,
101106predicate: (arg: Record<string, unknown>) => boolean,
@@ -223,7 +228,7 @@ describe("channel-auth", () => {
223228await runChannelLogin({ channel: "whatsapp", account: "acct-1" }, runtime);
224229225230expect(mocks.callGateway).not.toHaveBeenCalled();
226-expect(String(runtime.log.mock.calls.at(0)?.[0])).toContain("Gateway is in remote mode");
231+expect(readFirstLogMessage(runtime)).toContain("Gateway is in remote mode");
227232});
228233229234it("keeps login successful when local gateway runtime reconcile fails", async () => {
@@ -233,7 +238,7 @@ describe("channel-auth", () => {
233238runChannelLogin({ channel: "whatsapp", account: "acct-1" }, runtime),
234239).resolves.toBeUndefined();
235240236-expect(String(runtime.log.mock.calls.at(0)?.[0])).toContain(
241+expect(readFirstLogMessage(runtime)).toContain(
237242"running gateway did not restart it: gateway unreachable",
238243);
239244});
@@ -565,7 +570,7 @@ describe("channel-auth", () => {
565570account: { id: "resolved-account" },
566571 runtime,
567572});
568-expect(String(runtime.log.mock.calls.at(0)?.[0])).toContain(
573+expect(readFirstLogMessage(runtime)).toContain(
569574"running gateway did not stop it: gateway unreachable",
570575);
571576expect(mocks.setVerbose).not.toHaveBeenCalled();
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。