mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Opencode/refactor session activity (#192)
* loop: refactor-session-activity completed after 1 iterations * fix(frontend): fix MessagePart and BottomSheet test failures
This commit is contained in:
1 parent
f41bf37901
commit
40a2af7521
2 files changed
+36
-2
No files matched your search
@@ -1,11 +1,15 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { MemoryRouter } from 'react-router-dom'
|
||||
import { MessagePart } from './MessagePart'
|
||||
import type { MessagePart as MessagePartType } from '@/api/types'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
useTTS: vi.fn(),
|
||||
useSettings: vi.fn(),
|
||||
usePermissions: vi.fn(),
|
||||
useQuestions: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useTTS', () => ({
|
||||
@@ -16,6 +20,11 @@ vi.mock('@/hooks/useSettings', () => ({
|
||||
useSettings: mocks.useSettings,
|
||||
}))
|
||||
|
||||
vi.mock('@/contexts/EventContext', () => ({
|
||||
usePermissions: () => mocks.usePermissions(),
|
||||
useQuestions: () => mocks.useQuestions(),
|
||||
}))
|
||||
|
||||
interface MockTTSReturn {
|
||||
speakMessage: ReturnType<typeof vi.fn>
|
||||
stop: ReturnType<typeof vi.fn>
|
||||
@@ -61,6 +70,12 @@ describe('MessagePart', () => {
|
||||
updateSettings: vi.fn(),
|
||||
isUpdating: false,
|
||||
})
|
||||
mocks.usePermissions.mockReturnValue({
|
||||
getForCallID: vi.fn(() => null),
|
||||
})
|
||||
mocks.useQuestions.mockReturnValue({
|
||||
getForCallID: vi.fn(() => null),
|
||||
})
|
||||
})
|
||||
|
||||
const setup = (options: {
|
||||
@@ -440,7 +455,14 @@ describe('MessagePart', () => {
|
||||
})
|
||||
|
||||
const part = createToolPart()
|
||||
const { container } = render(<MessagePart part={part} />)
|
||||
const queryClient = new QueryClient()
|
||||
const { container } = render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<MemoryRouter>
|
||||
<MessagePart part={part} />
|
||||
</MemoryRouter>
|
||||
</QueryClientProvider>
|
||||
)
|
||||
|
||||
expect(container.firstChild).not.toBeNull()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user