test: fix Feishu lifecycle type checks

This commit is contained in:
Tak Hoffman
2026-03-19 16:54:39 -05:00
parent 73e08775d7
commit da8fb70525
4 changed files with 27 additions and 16 deletions

View File

@@ -115,6 +115,7 @@ function createLifecycleConfig(): ClawdbotConfig {
function createLifecycleAccount(): ResolvedFeishuAccount {
return {
accountId: "acct-acp",
selectionSource: "explicit",
enabled: true,
configured: true,
appId: "cli_test",
@@ -135,7 +136,7 @@ function createLifecycleAccount(): ResolvedFeishuAccount {
},
allowFrom: ["ou_sender_1"],
},
} as ResolvedFeishuAccount;
} as unknown as ResolvedFeishuAccount;
}
function createRuntimeEnv(): RuntimeEnv {

View File

@@ -5,18 +5,18 @@ import { monitorSingleAccount } from "./monitor.account.js";
import { setFeishuRuntime } from "./runtime.js";
import type { ResolvedFeishuAccount } from "./types.js";
type BoundConversation = {
bindingId: string;
targetSessionKey: string;
};
const createEventDispatcherMock = vi.hoisted(() => vi.fn());
const monitorWebSocketMock = vi.hoisted(() => vi.fn(async () => {}));
const monitorWebhookMock = vi.hoisted(() => vi.fn(async () => {}));
const createFeishuThreadBindingManagerMock = vi.hoisted(() => vi.fn(() => ({ stop: vi.fn() })));
const createFeishuReplyDispatcherMock = vi.hoisted(() => vi.fn());
const resolveBoundConversationMock = vi.hoisted(() =>
vi.fn<
() => {
bindingId: string;
targetSessionKey: string;
} | null
>(() => null),
const resolveBoundConversationMock = vi.hoisted(
() => vi.fn<() => BoundConversation | null>(() => null),
);
const touchBindingMock = vi.hoisted(() => vi.fn());
const resolveAgentRouteMock = vi.hoisted(() => vi.fn());
@@ -117,6 +117,7 @@ function createLifecycleConfig(): ClawdbotConfig {
function createLifecycleAccount(): ResolvedFeishuAccount {
return {
accountId: "acct-menu",
selectionSource: "explicit",
enabled: true,
configured: true,
appId: "cli_test",
@@ -129,7 +130,7 @@ function createLifecycleAccount(): ResolvedFeishuAccount {
requireMention: false,
resolveSenderNames: false,
},
} as ResolvedFeishuAccount;
} as unknown as ResolvedFeishuAccount;
}
function createRuntimeEnv(): RuntimeEnv {
@@ -209,10 +210,10 @@ describe("Feishu bot-menu lifecycle", () => {
markDispatchIdle: vi.fn(),
});
resolveBoundConversationMock.mockReturnValue({
resolveBoundConversationMock.mockImplementation(() => ({
bindingId: "binding-menu",
targetSessionKey: "agent:bound-agent:feishu:direct:ou_user1",
});
}));
resolveAgentRouteMock.mockReturnValue({
agentId: "main",

View File

@@ -131,6 +131,7 @@ function createLifecycleConfig(): ClawdbotConfig {
function createLifecycleAccount(accountId: "account-A" | "account-B"): ResolvedFeishuAccount {
return {
accountId,
selectionSource: "explicit",
enabled: true,
configured: true,
appId: accountId === "account-A" ? "cli_a" : "cli_b",
@@ -148,7 +149,7 @@ function createLifecycleAccount(accountId: "account-A" | "account-B"): ResolvedF
},
},
},
} as ResolvedFeishuAccount;
} as unknown as ResolvedFeishuAccount;
}
function createRuntimeEnv(): RuntimeEnv {

View File

@@ -6,12 +6,19 @@ import { monitorSingleAccount } from "./monitor.account.js";
import { setFeishuRuntime } from "./runtime.js";
import type { ResolvedFeishuAccount } from "./types.js";
type BoundConversation = {
bindingId: string;
targetSessionKey: string;
};
const createEventDispatcherMock = vi.hoisted(() => vi.fn());
const monitorWebSocketMock = vi.hoisted(() => vi.fn(async () => {}));
const monitorWebhookMock = vi.hoisted(() => vi.fn(async () => {}));
const createFeishuThreadBindingManagerMock = vi.hoisted(() => vi.fn(() => ({ stop: vi.fn() })));
const createFeishuReplyDispatcherMock = vi.hoisted(() => vi.fn());
const resolveBoundConversationMock = vi.hoisted(() => vi.fn(() => null));
const resolveBoundConversationMock = vi.hoisted(
() => vi.fn<() => BoundConversation | null>(() => null),
);
const touchBindingMock = vi.hoisted(() => vi.fn());
const resolveAgentRouteMock = vi.hoisted(() => vi.fn());
const dispatchReplyFromConfigMock = vi.hoisted(() => vi.fn());
@@ -111,6 +118,7 @@ function createLifecycleConfig(): ClawdbotConfig {
function createLifecycleAccount(): ResolvedFeishuAccount {
return {
accountId: "acct-card",
selectionSource: "explicit",
enabled: true,
configured: true,
appId: "cli_test",
@@ -123,7 +131,7 @@ function createLifecycleAccount(): ResolvedFeishuAccount {
requireMention: false,
resolveSenderNames: false,
},
} as ResolvedFeishuAccount;
} as unknown as ResolvedFeishuAccount;
}
function createRuntimeEnv(): RuntimeEnv {
@@ -228,10 +236,10 @@ describe("Feishu card-action lifecycle", () => {
markDispatchIdle: vi.fn(),
});
resolveBoundConversationMock.mockReturnValue({
resolveBoundConversationMock.mockImplementation(() => ({
bindingId: "binding-card",
targetSessionKey: "agent:bound-agent:feishu:direct:ou_user1",
});
}));
resolveAgentRouteMock.mockReturnValue({
agentId: "main",