fix: 修复样式, 调用接口方法

This commit is contained in:
Wxw-Gu
2026-08-25 15:14:30 +08:00
parent 47e0d7cd1e
commit eec6286a58
10 changed files with 154 additions and 23 deletions
@@ -59,6 +59,23 @@ describe('Agent Hub controls', () => {
expect(screen.getByRole('button', { name: '复制日志' })).toBeDisabled()
})
it('keeps the enabled capability examples visible', async () => {
render(<AgentHubWorkspace />)
await screen.findByText('系统就绪')
expect(screen.getByText('已启用能力')).toBeInTheDocument()
expect(screen.getByText('微信数据助手')).toBeInTheDocument()
expect(screen.getByText('支持自然语言,可以这样问')).toBeInTheDocument()
expect(screen.getByText('“最近 5 条消息是谁?”')).toBeInTheDocument()
expect(screen.getByText('“帮我看看最近跟xx聊了些什么”')).toBeInTheDocument()
expect(screen.getByText('“生成产品交流群今天的群聊总结图片”')).toBeInTheDocument()
expect(
document.querySelectorAll(
'.agent-hub-capability-card li:not(.agent-hub-capability-status) > i'
)
).toHaveLength(4)
})
it('keeps reconnect and destructive disconnect actions separate', async () => {
const user = userEvent.setup()
render(<AgentHubWorkspace />)
@@ -16,7 +16,7 @@ const baseProps = {
}
describe('export progress panel', () => {
it('uses the semantic accent surface for outgoing preview messages', () => {
it('keeps the preview canvas distinct from the bubble surface', () => {
render(
<ExportPreviewPanel
{...baseProps}
@@ -40,6 +40,7 @@ describe('export progress panel', () => {
expect(screen.getByText('已发送的消息').closest('.export-preview-bubble')).toHaveClass(
'bg-accent'
)
expect(screen.getByRole('complementary')).toHaveClass('export-preview-panel')
})
it('shows an indeterminate bar while the first message scan is still at zero', () => {
@@ -8,6 +8,17 @@ const mocks = vi.hoisted(() => ({
updateSettings: vi.fn()
}))
const electronNetFetch = vi.hoisted(() => vi.fn())
vi.mock('electron', () => ({
app: {
getPath: vi.fn(() => '/tmp/tracememo-test')
},
net: {
fetch: electronNetFetch
}
}))
vi.mock('../../src/main/ai-provider-key-store', () => ({
AIProviderKeyStore: class {
get = mocks.keyGet
@@ -66,4 +77,41 @@ describe('TextToSpeechSettingsService', () => {
ttsSelectedVoiceId: 'fish-model-id'
})
})
it('uses Electron net.fetch for Fish Audio requests', async () => {
mocks.keyGet.mockReturnValue({ success: true, available: true, key: 'stored' })
electronNetFetch.mockResolvedValue({
ok: true,
json: vi.fn().mockResolvedValue({ total: 0, items: [], has_more: false })
})
const result = await new TextToSpeechSettingsService().listVoices({ pageSize: 1 })
expect(result.success).toBe(true)
expect(electronNetFetch).toHaveBeenCalledWith(
expect.stringContaining('https://api.fish.audio/model'),
expect.objectContaining({
headers: { Authorization: 'Bearer stored' }
})
)
})
it('falls back to Node fetch when Electron transport is unavailable', async () => {
mocks.keyGet.mockReturnValue({ success: true, available: true, key: 'stored' })
electronNetFetch.mockRejectedValue(new TypeError('Electron transport unavailable'))
const nodeFetch = vi.fn().mockResolvedValue({
ok: true,
json: vi.fn().mockResolvedValue({ total: 0, items: [], has_more: false })
})
vi.stubGlobal('fetch', nodeFetch)
const result = await new TextToSpeechSettingsService().listVoices({ pageSize: 1 })
expect(result.success).toBe(true)
expect(nodeFetch).toHaveBeenCalledWith(
expect.stringContaining('https://api.fish.audio/model'),
expect.objectContaining({ headers: { Authorization: 'Bearer stored' } })
)
vi.unstubAllGlobals()
})
})