diff --git a/extensions/feishu/src/channel.test.ts b/extensions/feishu/src/channel.test.ts new file mode 100644 index 00000000000..affc25fae5d --- /dev/null +++ b/extensions/feishu/src/channel.test.ts @@ -0,0 +1,48 @@ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import { describe, expect, it, vi } from "vitest"; + +const probeFeishuMock = vi.hoisted(() => vi.fn()); + +vi.mock("./probe.js", () => ({ + probeFeishu: probeFeishuMock, +})); + +import { feishuPlugin } from "./channel.js"; + +describe("feishuPlugin.status.probeAccount", () => { + it("uses current account credentials for multi-account config", async () => { + const cfg = { + channels: { + feishu: { + enabled: true, + accounts: { + main: { + appId: "cli_main", + appSecret: "secret_main", + enabled: true, + }, + }, + }, + }, + } as OpenClawConfig; + + const account = feishuPlugin.config.resolveAccount(cfg, "main"); + probeFeishuMock.mockResolvedValueOnce({ ok: true, appId: "cli_main" }); + + const result = await feishuPlugin.status?.probeAccount?.({ + account, + timeoutMs: 1_000, + cfg, + }); + + expect(probeFeishuMock).toHaveBeenCalledTimes(1); + expect(probeFeishuMock).toHaveBeenCalledWith( + expect.objectContaining({ + accountId: "main", + appId: "cli_main", + appSecret: "secret_main", + }), + ); + expect(result).toMatchObject({ ok: true, appId: "cli_main" }); + }); +}); diff --git a/extensions/feishu/src/channel.ts b/extensions/feishu/src/channel.ts index d4c8e102016..bdc3aa04ba9 100644 --- a/extensions/feishu/src/channel.ts +++ b/extensions/feishu/src/channel.ts @@ -321,9 +321,7 @@ export const feishuPlugin: ChannelPlugin = { probe: snapshot.probe, lastProbeAt: snapshot.lastProbeAt ?? null, }), - probeAccount: async ({ account }) => { - return await probeFeishu(account); - }, + probeAccount: async ({ account }) => await probeFeishu(account), buildAccountSnapshot: ({ account, runtime, probe }) => ({ accountId: account.accountId, enabled: account.enabled,