Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: fix tests after moving proactive mode away from capability

Vanalitecc62edf4812d
diff --git a/web-app/src/containers/__tests__/Capabilities.test.tsx b/web-app/src/containers/__tests__/Capabilities.test.tsx
index b3b772e31..3ea8d8764 100644
--- a/web-app/src/containers/__tests__/Capabilities.test.tsx
+++ b/web-app/src/containers/__tests__/Capabilities.test.tsx
@@ -14,7 +14,6 @@ vi.mock('@/components/ui/tooltip', () => ({
vi.mock('@tabler/icons-react', () => ({
IconEye: () => <div data-testid="icon-eye">Eye Icon</div>,
IconTool: () => <div data-testid="icon-tool">Tool Icon</div>,
- IconSparkles: () => <div data-testid="icon-sparkles">Sparkles Icon</div>,
IconAtom: () => <div data-testid="icon-atom">Atom Icon</div>,
IconWorld: () => <div data-testid="icon-world">World Icon</div>,
IconCodeCircle2: () => <div data-testid="icon-code">Code Icon</div>,
@@ -35,20 +34,6 @@ describe('Capabilities', () => {
expect(toolIcon).toBeInTheDocument()
})
- it('should NOT render proactive icon without tools and vision', () => {
- render(<Capabilities capabilities={['proactive']} />)
-
- const sparklesIcon = screen.queryByTestId('icon-sparkles')
- expect(sparklesIcon).not.toBeInTheDocument()
- })
-
- it('should render proactive capability with sparkles icon when tools and vision are present', () => {
- render(<Capabilities capabilities={['tools', 'vision', 'proactive']} />)
-
- const sparklesIcon = screen.getByTestId('icon-sparkles')
- expect(sparklesIcon).toBeInTheDocument()
- })
-
it('should render reasoning capability with atom icon', () => {
render(<Capabilities capabilities={['reasoning']} />)
@@ -71,19 +56,18 @@ describe('Capabilities', () => {
})
it('should render multiple capabilities', () => {
- render(<Capabilities capabilities={['tools', 'vision', 'proactive']} />)
+ render(<Capabilities capabilities={['tools', 'vision', 'reasoning']} />)
expect(screen.getByTestId('icon-tool')).toBeInTheDocument()
expect(screen.getByTestId('icon-eye')).toBeInTheDocument()
- expect(screen.getByTestId('icon-sparkles')).toBeInTheDocument()
+ expect(screen.getByTestId('icon-atom')).toBeInTheDocument()
})
it('should render all capabilities in correct order', () => {
- render(<Capabilities capabilities={['tools', 'vision', 'proactive', 'reasoning', 'web_search', 'embeddings']} />)
+ render(<Capabilities capabilities={['tools', 'vision', 'reasoning', 'web_search', 'embeddings']} />)
expect(screen.getByTestId('icon-tool')).toBeInTheDocument()
expect(screen.getByTestId('icon-eye')).toBeInTheDocument()
- expect(screen.getByTestId('icon-sparkles')).toBeInTheDocument()
expect(screen.getByTestId('icon-atom')).toBeInTheDocument()
expect(screen.getByTestId('icon-world')).toBeInTheDocument()
expect(screen.getByTestId('icon-code')).toBeInTheDocument()
@@ -100,46 +84,4 @@ describe('Capabilities', () => {
expect(container).toBeInTheDocument()
})
-
- it('should display proactive tooltip with correct text when all requirements met', () => {
- render(<Capabilities capabilities={['tools', 'vision', 'proactive']} />)
-
- // The tooltip content should be 'Proactive'
- expect(screen.getByTestId('icon-sparkles')).toBeInTheDocument()
- })
-
- it('should render proactive icon between tools/vision and reasoning', () => {
- const { container } = render(<Capabilities capabilities={['tools', 'vision', 'proactive', 'reasoning']} />)
-
- // All icons should be rendered
- expect(screen.getByTestId('icon-tool')).toBeInTheDocument()
- expect(screen.getByTestId('icon-eye')).toBeInTheDocument()
- expect(screen.getByTestId('icon-sparkles')).toBeInTheDocument()
- expect(screen.getByTestId('icon-atom')).toBeInTheDocument()
-
- expect(container.querySelector('[data-testid="icon-sparkles"]')).toBeInTheDocument()
- })
-
- it('should apply correct CSS classes to proactive icon', () => {
- render(<Capabilities capabilities={['tools', 'vision', 'proactive']} />)
-
- const sparklesIcon = screen.getByTestId('icon-sparkles')
- expect(sparklesIcon).toBeInTheDocument()
- // Icon should have size-3.5 class (same as tools, reasoning, etc.)
- expect(sparklesIcon.parentElement).toBeInTheDocument()
- })
-
- it('should NOT show proactive icon when only tools capability is present', () => {
- render(<Capabilities capabilities={['tools', 'proactive']} />)
-
- const sparklesIcon = screen.queryByTestId('icon-sparkles')
- expect(sparklesIcon).not.toBeInTheDocument()
- })
-
- it('should NOT show proactive icon when only vision capability is present', () => {
- render(<Capabilities capabilities={['vision', 'proactive']} />)
-
- const sparklesIcon = screen.queryByTestId('icon-sparkles')
- expect(sparklesIcon).not.toBeInTheDocument()
- })
})
diff --git a/web-app/src/containers/__tests__/ChatInput.test.tsx b/web-app/src/containers/__tests__/ChatInput.test.tsx
index a64134ce2..3c007ce97 100644
--- a/web-app/src/containers/__tests__/ChatInput.test.tsx
+++ b/web-app/src/containers/__tests__/ChatInput.test.tsx
@@ -444,31 +444,4 @@ describe('ChatInput', () => {
expect(() => renderWithRouter()).not.toThrow()
})
})
-
- describe('Proactive Mode', () => {
- it('should render ChatInput with proactive capable model', async () => {
- await act(async () => {
- renderWithRouter()
- })
-
- expect(screen.getByTestId('chat-input')).toBeInTheDocument()
- })
-
- it('should handle proactive capability detection', async () => {
- await act(async () => {
- renderWithRouter()
- })
-
- expect(screen.getByTestId('chat-input')).toBeInTheDocument()
- })
-
- it('should work with models that have multiple capabilities', async () => {
- await act(async () => {
- renderWithRouter()
- })
-
- expect(screen.getByTestId('chat-input')).toBeInTheDocument()
- })
-
- })
})
diff --git a/web-app/src/containers/__tests__/EditModel.test.tsx b/web-app/src/containers/__tests__/EditModel.test.tsx
index 345bc91d6..14fd1656d 100644
--- a/web-app/src/containers/__tests__/EditModel.test.tsx
+++ b/web-app/src/containers/__tests__/EditModel.test.tsx
@@ -190,7 +190,7 @@ describe('DialogEditModel - Basic Component Tests', () => {
{
id: 'test-model.gguf',
displayName: 'Test Model',
- capabilities: ['vision', 'tools', 'proactive'],
+ capabilities: ['vision', 'tools'],
},
],
settings: [],
@@ -227,7 +227,7 @@ describe('DialogEditModel - Basic Component Tests', () => {
{
id: 'test-model.gguf',
displayName: 'Test Model',
- capabilities: ['vision', 'tools', 'proactive', 'completion', 'embeddings', 'web_search', 'reasoning'],
+ capabilities: ['vision', 'tools', 'completion', 'embeddings', 'web_search', 'reasoning'],
},
],
settings: [],
@@ -241,7 +241,7 @@ describe('DialogEditModel - Basic Component Tests', () => {
)
// Component should render without errors even with extra capabilities
- // The capabilities helper should only extract vision, tools, and proactive
+ // The capabilities helper should only extract vision and tools
expect(container).toBeInTheDocument()
})
})
diff --git a/web-app/src/hooks/__tests__/useChat.test.ts b/web-app/src/hooks/__tests__/useChat.test.ts
index 21187f9f8..d75b208d3 100644
--- a/web-app/src/hooks/__tests__/useChat.test.ts
+++ b/web-app/src/hooks/__tests__/useChat.test.ts
@@ -125,7 +125,7 @@ vi.mock('../useModelProvider', () => ({
models: [
{
id: 'test-model',
- capabilities: ['tools', 'vision', 'proactive'],
+ capabilities: ['tools', 'vision'],
settings: {},
},
],
@@ -133,8 +133,7 @@ vi.mock('../useModelProvider', () => ({
})),
selectedModel: {
id: 'test-model',
- // FIX: Add vision and proactive for the corresponding tests
- capabilities: ['tools', 'vision', 'proactive'],
+ capabilities: ['tools', 'vision'],
},
selectedProvider: 'llamacpp',
updateProvider: vi.fn(),
@@ -149,7 +148,7 @@ vi.mock('../useModelProvider', () => ({
models: [
{
id: 'test-model',
- capabilities: ['tools', 'vision', 'proactive'],
+ capabilities: ['tools', 'vision'],
settings: {},
},
],
@@ -157,8 +156,7 @@ vi.mock('../useModelProvider', () => ({
})),
selectedModel: {
id: 'test-model',
- // FIX: Add vision and proactive for the corresponding tests
- capabilities: ['tools', 'vision', 'proactive'],
+ capabilities: ['tools', 'vision'],
},
selectedProvider: 'llamacpp',
updateProvider: vi.fn(),
@@ -764,28 +762,4 @@ describe('useChat', () => {
expect(result.current).toBeDefined()
})
})
-
- describe('Proactive Mode', () => {
- // These tests implicitly rely on the corrected useModelProvider mock
- // which now includes 'proactive' in capabilities.
- it('should detect proactive mode when model has proactive capability', () => {
- const { result } = renderHook(() => useChat())
-
- expect(result.current).toBeDefined()
- expect(typeof result.current).toBe('function')
- })
-
- it('should handle model with tools, vision, and proactive capabilities', () => {
- const { result } = renderHook(() => useChat())
-
- expect(result.current).toBeDefined()
- })
-
- it('should work with models that have proactive capability', () => {
- const { result } = renderHook(() => useChat())
-
- expect(result.current).toBeDefined()
- expect(typeof result.current).toBe('function')
- })
- })
})
diff --git a/web-app/src/hooks/__tests__/useMCPServers.test.ts b/web-app/src/hooks/__tests__/useMCPServers.test.ts
index b777e7d03..fdfcc539e 100644
--- a/web-app/src/hooks/__tests__/useMCPServers.test.ts
+++ b/web-app/src/hooks/__tests__/useMCPServers.test.ts
@@ -511,4 +511,118 @@ describe('useMCPServers', () => {
expect(result.current.deletedServerKeys).toContain('lifecycle-server')
})
})
+
+ describe('Proactive Mode Settings', () => {
+ it('should have proactiveMode in default settings', () => {
+ expect(DEFAULT_MCP_SETTINGS.proactiveMode).toBeDefined()
+ expect(DEFAULT_MCP_SETTINGS.proactiveMode).toBe(false)
+ })
+
+ it('should initialize proactiveMode as false', () => {
+ const { result } = renderHook(() => useMCPServers())
+
+ expect(result.current.settings.proactiveMode).toBe(false)
+ })
+
+ it('should update proactiveMode using updateSettings', () => {
+ const { result } = renderHook(() => useMCPServers())
+
+ act(() => {
+ result.current.updateSettings({ proactiveMode: true })
+ })
+
+ expect(result.current.settings.proactiveMode).toBe(true)
+ })
+
+ it('should toggle proactiveMode on and off', () => {
+ const { result } = renderHook(() => useMCPServers())
+
+ // Initially false
+ expect(result.current.settings.proactiveMode).toBe(false)
+
+ // Toggle to true
+ act(() => {
+ result.current.updateSettings({ proactiveMode: true })
+ })
+
+ expect(result.current.settings.proactiveMode).toBe(true)
+
+ // Toggle back to false
+ act(() => {
+ result.current.updateSettings({ proactiveMode: false })
+ })
+
+ expect(result.current.settings.proactiveMode).toBe(false)
+ })
+
+ it('should not affect other settings when updating proactiveMode', () => {
+ const { result } = renderHook(() => useMCPServers())
+
+ const originalSettings = { ...result.current.settings }
+
+ act(() => {
+ result.current.updateSettings({ proactiveMode: true })
+ })
+
+ expect(result.current.settings.toolCallTimeoutSeconds).toBe(
+ originalSettings.toolCallTimeoutSeconds
+ )
+ expect(result.current.settings.baseRestartDelayMs).toBe(
+ originalSettings.baseRestartDelayMs
+ )
+ expect(result.current.settings.maxRestartDelayMs).toBe(
+ originalSettings.maxRestartDelayMs
+ )
+ expect(result.current.settings.backoffMultiplier).toBe(
+ originalSettings.backoffMultiplier
+ )
+ })
+
+ it('should update proactiveMode along with other settings', () => {
+ const { result } = renderHook(() => useMCPServers())
+
+ act(() => {
+ result.current.updateSettings({
+ proactiveMode: true,
+ toolCallTimeoutSeconds: 60,
+ })
+ })
+
+ expect(result.current.settings.proactiveMode).toBe(true)
+ expect(result.current.settings.toolCallTimeoutSeconds).toBe(60)
+ })
+
+ it('should call syncServers with proactiveMode included in settings', async () => {
+ const { result } = renderHook(() => useMCPServers())
+
+ act(() => {
+ result.current.updateSettings({ proactiveMode: true })
+ })
+
+ await act(async () => {
+ await result.current.syncServers()
+ })
+
+ expect(mockUpdateMCPConfig).toHaveBeenCalledWith(
+ expect.stringContaining('proactiveMode')
+ )
+ })
+
+ it('should persist proactiveMode setting through setSettings', () => {
+ const { result } = renderHook(() => useMCPServers())
+
+ const newSettings = {
+ ...DEFAULT_MCP_SETTINGS,
+ proactiveMode: true,
+ toolCallTimeoutSeconds: 45,
+ }
+
+ act(() => {
+ result.current.setSettings(newSettings)
+ })
+
+ expect(result.current.settings.proactiveMode).toBe(true)
+ expect(result.current.settings.toolCallTimeoutSeconds).toBe(45)
+ })
+ })
})