diff --git a/apps/ai-game-creator-shell/src/view/project-development/chat/controller/useDirectProjectChatController.test.tsx b/apps/ai-game-creator-shell/src/view/project-development/chat/controller/useDirectProjectChatController.test.tsx index 1b9999c58..8e41a0c5c 100644 --- a/apps/ai-game-creator-shell/src/view/project-development/chat/controller/useDirectProjectChatController.test.tsx +++ b/apps/ai-game-creator-shell/src/view/project-development/chat/controller/useDirectProjectChatController.test.tsx @@ -2,6 +2,7 @@ import { act, cleanup, renderHook, waitFor } from '@testing-library/react'; import { afterEach, describe, expect, it, vi } from 'vitest'; +import type { TauriInvoke } from '../../../../app/types'; import type { HistorySlice } from '../generated/HistorySlice'; import type { ThreadItem } from '../generated/ThreadItem'; import { useDirectProjectChatController } from './useDirectProjectChatController'; @@ -32,6 +33,7 @@ function slice( */ function installDeferredHistoryInvoke() { const requests: SliceRequest[] = []; + // `vi.fn` 的返回类型是固定签名,装不进 `window.__TAURI__.core.invoke` 的泛型签名,这里显式转换。 const invoke = vi.fn( async (command: string, args?: Record) => { if (command !== 'read_direct_project_history_slice') return undefined; @@ -44,7 +46,7 @@ function installDeferredHistoryInvoke() { }); }); }, - ); + ) as unknown as TauriInvoke; window.__TAURI__ = { core: { invoke } }; return { /** 取出一条挂起的读取;没有就等到出现为止。 */