test: 暂存代码

This commit is contained in:
电摇小子
2026-08-06 20:29:25 +08:00
parent 307d247660
commit ad4b3a8074
43 changed files with 9978 additions and 512 deletions
@@ -1,4 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { AiSearchPipelineRequest } from '../../src/shared/ai-search'
import type { KnowledgeSearchIpcRequest } from '../../src/shared/knowledge'
const invoke = vi.fn()
const on = vi.fn()
@@ -37,6 +39,28 @@ describe('preload IPC contract', () => {
limit: 50
})
const knowledgeSearch: KnowledgeSearchIpcRequest = {
text: '测试 Knowledge Worker 检索',
terms: ['Knowledge Worker'],
conversationIds: ['fixture-user'],
startTime: 10,
limit: 20
}
await api.searchKnowledge(knowledgeSearch)
expect(invoke).toHaveBeenLastCalledWith('knowledge:search', knowledgeSearch)
const aiSearch: AiSearchPipelineRequest = {
requestId: 'fixture-search',
text: '最近谁聊过健身',
scope: 'global',
range: '7d'
}
await api.runAiSearch(aiSearch)
expect(invoke).toHaveBeenLastCalledWith('ai-search:run', aiSearch)
await api.startKnowledgeIndex()
expect(invoke).toHaveBeenLastCalledWith('knowledge:startIndex')
await api.clearCache('knowledge')
expect(invoke).toHaveBeenLastCalledWith('cache:clear', 'knowledge')
await api.getImage('fixture-md5', 'fixture.dat', 'fixture-session', {
force: true,
priority: 0