fix: 完善交互、知识库目录与 Windows 运行库提示

This commit is contained in:
电摇小子
2026-08-11 02:59:30 +08:00
parent 32864ff88c
commit 8a0d3b02d9
16 changed files with 283 additions and 20 deletions
@@ -376,6 +376,56 @@ describe('AISearchWorkspace cache privacy boundary', () => {
expect(api.runAiSearch).not.toHaveBeenCalled()
})
it('submits with Enter and keeps Shift+Enter available for a new line', async () => {
api.getAiSearchProviderStatus.mockResolvedValue({ configured: true, requiresConsent: false })
api.runAiSearch.mockResolvedValue({
requestId: 'enter-submit',
status: 'completed',
answer: 'answer',
plan: { intent: 'global_topic_search' },
knowledge: { indexedMessageCount: 1, indexedChunkCount: 1, totalMessages: 1 },
candidateEvidenceCount: 0,
contextEvidenceCount: 0,
evidence: [],
aggregation: {
messageCount: 0,
peopleCount: 0,
conversationCount: 0,
people: [],
conversations: []
},
agent: { mode: 'agent', toolCalls: 1, trace: [] },
timings: {},
elapsedMs: 1
} as never)
render(
<AISearchWorkspace
contacts={[]}
selectedContact={null}
dbReady
aiModelConfig={{
configured: true,
providerName: 'Local Provider',
model: 'model',
modelName: 'Model',
status: 'connected'
}}
onSelectContact={vi.fn()}
onOpenEvidence={vi.fn()}
onOpenAISettings={vi.fn()}
onNotice={vi.fn()}
/>
)
const input = screen.getByRole('textbox')
await userEvent.type(input, 'Enter submit question')
fireEvent.keyDown(input, { key: 'Enter', shiftKey: true })
expect(api.runAiSearch).not.toHaveBeenCalled()
fireEvent.keyDown(input, { key: 'Enter' })
await waitFor(() => expect(api.runAiSearch).toHaveBeenCalledOnce())
})
it('cancels an active analysis and ignores its late result', async () => {
api.getAiSearchProviderStatus.mockResolvedValue({ configured: true, requiresConsent: false })
let resolveSearch: ((value: unknown) => void) | undefined
+42
View File
@@ -0,0 +1,42 @@
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { CacheCleanupPage } from '../../src/renderer/src/features/settings/pages/CacheCleanupPage'
const api = {
getCacheSummary: vi.fn(),
clearCache: vi.fn(),
openKnowledgeDirectory: vi.fn()
}
describe('CacheCleanupPage', () => {
beforeEach(() => {
vi.clearAllMocks()
Object.defineProperty(window, 'api', { configurable: true, value: api })
api.getCacheSummary.mockResolvedValue({
items: [
{
id: 'knowledge',
label: '本地知识库索引',
description: '问一问微信使用的本地检索索引',
sizeBytes: 1024,
fileCount: 1
}
],
totalBytes: 1024,
updatedAt: Date.now()
})
api.openKnowledgeDirectory.mockResolvedValue({ success: true })
})
it('opens the real knowledge directory without clearing it', async () => {
const onNotice = vi.fn()
render(<CacheCleanupPage onNotice={onNotice} />)
await userEvent.click(await screen.findByRole('button', { name: '打开文件夹' }))
await waitFor(() => expect(api.openKnowledgeDirectory).toHaveBeenCalledOnce())
expect(api.clearCache).not.toHaveBeenCalled()
expect(onNotice).toHaveBeenCalledWith('已打开知识库文件夹')
})
})
@@ -180,4 +180,16 @@ describe('DatabaseConnectionPage', () => {
expect(screen.getByRole('button', { name: '返回上一步' })).toBeEnabled()
expect(screen.getByRole('button', { name: '取消并重新检查' })).toBeEnabled()
})
it('provides the official Visual C++ runtime download on Windows', () => {
renderPage({
status: '当前 Windows 缺少 Microsoft Visual C++ 运行库',
statusKind: 'error'
})
expect(screen.getByRole('link', { name: '下载运行库' })).toHaveAttribute(
'href',
'https://aka.ms/vc14/vc_redist.x64.exe'
)
})
})