修复控制器回归测试的 invoke 替身类型
- vi.fn 返回固定签名,装不进 window.__TAURI__.core.invoke 的泛型签名,显式转成 TauriInvoke - tsc 不再报 TS2322;用例行为与断言不变 Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
+3
-1
@@ -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<string, unknown>) => {
|
||||
if (command !== 'read_direct_project_history_slice') return undefined;
|
||||
@@ -44,7 +46,7 @@ function installDeferredHistoryInvoke() {
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
) as unknown as TauriInvoke;
|
||||
window.__TAURI__ = { core: { invoke } };
|
||||
return {
|
||||
/** 取出一条挂起的读取;没有就等到出现为止。 */
|
||||
|
||||
Reference in New Issue
Block a user