mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 19:01:47 +03:00
fix: use resolved feishu account in status probe (openclaw#11233) thanks @onevcat
Co-authored-by: Wei Wang <1019875+onevcat@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -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" });
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -321,9 +321,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount> = {
|
|||||||
probe: snapshot.probe,
|
probe: snapshot.probe,
|
||||||
lastProbeAt: snapshot.lastProbeAt ?? null,
|
lastProbeAt: snapshot.lastProbeAt ?? null,
|
||||||
}),
|
}),
|
||||||
probeAccount: async ({ account }) => {
|
probeAccount: async ({ account }) => await probeFeishu(account),
|
||||||
return await probeFeishu(account);
|
|
||||||
},
|
|
||||||
buildAccountSnapshot: ({ account, runtime, probe }) => ({
|
buildAccountSnapshot: ({ account, runtime, probe }) => ({
|
||||||
accountId: account.accountId,
|
accountId: account.accountId,
|
||||||
enabled: account.enabled,
|
enabled: account.enabled,
|
||||||
|
|||||||
Reference in New Issue
Block a user