


























@@ -5,10 +5,18 @@ import {
55createTestWizardPrompter,
66runSetupWizardConfigure,
77} from "openclaw/plugin-sdk/plugin-test-runtime";
8-import { describe, expect, it, vi } from "vitest";
8+import { beforeEach, describe, expect, it, vi } from "vitest";
9+import type { FeishuProbeResult } from "./types.js";
10+11+const { probeFeishuMock } = vi.hoisted(() => ({
12+probeFeishuMock: vi.fn<() => Promise<FeishuProbeResult>>(async () => ({
13+ok: false,
14+error: "mocked",
15+})),
16+}));
9171018vi.mock("./probe.js", () => ({
11-probeFeishu: vi.fn(async () => ({ ok: false, error: "mocked" })),
19+probeFeishu: probeFeishuMock,
1220}));
13211422vi.mock("./app-registration.js", () => ({
@@ -69,6 +77,11 @@ const feishuConfigure = createPluginSetupWizardConfigure(feishuPlugin);
6977const feishuGetStatus = createPluginSetupWizardStatus(feishuPlugin);
70787179describe("feishu setup wizard", () => {
80+beforeEach(() => {
81+probeFeishuMock.mockReset();
82+probeFeishuMock.mockResolvedValue({ ok: false, error: "mocked" });
83+});
84+7285it("does not throw when config appId/appSecret are SecretRef objects", async () => {
7386const text = vi
7487.fn()
@@ -101,6 +114,11 @@ describe("feishu setup wizard", () => {
101114});
102115103116describe("feishu setup wizard status", () => {
117+beforeEach(() => {
118+probeFeishuMock.mockReset();
119+probeFeishuMock.mockResolvedValue({ ok: false, error: "mocked" });
120+});
121+104122it("treats SecretRef appSecret as configured when appId is present", async () => {
105123const status = await feishuGetStatus({
106124cfg: {
@@ -121,6 +139,39 @@ describe("feishu setup wizard status", () => {
121139expect(status.configured).toBe(true);
122140});
123141142+it("probes the resolved default account in multi-account config", async () => {
143+probeFeishuMock.mockResolvedValueOnce({ ok: true, botName: "Feishu Main" });
144+145+const status = await feishuGetStatus({
146+cfg: {
147+channels: {
148+feishu: {
149+enabled: true,
150+defaultAccount: "main-bot",
151+accounts: {
152+"main-bot": {
153+appId: "cli_main",
154+appSecret: "main-app-secret", // pragma: allowlist secret
155+connectionMode: "websocket",
156+},
157+},
158+},
159+},
160+} as never,
161+ ...baseStatusContext,
162+});
163+164+expect(status.configured).toBe(true);
165+expect(status.statusLines).toEqual(["Feishu: connected as Feishu Main"]);
166+expect(probeFeishuMock).toHaveBeenCalledWith(
167+expect.objectContaining({
168+accountId: "main-bot",
169+appId: "cli_main",
170+appSecret: "main-app-secret", // pragma: allowlist secret
171+}),
172+);
173+});
174+124175it("does not fallback to top-level appId when account explicitly sets empty appId", async () => {
125176const status = await feishuGetStatus({
126177cfg: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。