mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-05-01 06:36:23 +08:00
test: fix Feishu lifecycle type checks
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user