Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Revert "chore(test): skip test breaking the CI"
Elian Doranf8c1dabfd530
diff --git a/apps/server/src/services/llm/providers/model_selection.spec.ts b/apps/server/src/services/llm/providers/model_selection.spec.tsindex 3f74458fa6..c6fdfae1e9 100644--- a/apps/server/src/services/llm/providers/model_selection.spec.ts+++ b/apps/server/src/services/llm/providers/model_selection.spec.ts@@ -67,7 +67,7 @@ describe('LLM Model Selection with Special Characters', () => {vi.mocked(options.getOptionBool).mockReturnValue(true);});- describe.skip('OpenAI Model Names', () => {+ describe('OpenAI Model Names', () => {it('should correctly handle model names with periods', async () => {const modelName = 'gpt-4.1-turbo-preview';vi.mocked(options.getOption).mockImplementation((key: string) => {@@ -82,7 +82,7 @@ describe('LLM Model Selection with Special Characters', () => {// Spy on getOpenAIOptions to verify model name is passed correctlyconst getOpenAIOptionsSpy = vi.spyOn(providers, 'getOpenAIOptions');-+try {await service.generateChatCompletion([{ role: 'user', content: 'test' }], opts);} catch (error) {@@ -108,7 +108,7 @@ describe('LLM Model Selection with Special Characters', () => {};const getOpenAIOptionsSpy = vi.spyOn(providers, 'getOpenAIOptions');-+try {await service.generateChatCompletion([{ role: 'user', content: 'test' }], opts);} catch (error) {@@ -127,7 +127,7 @@ describe('LLM Model Selection with Special Characters', () => {};const getOpenAIOptionsSpy = vi.spyOn(providers, 'getOpenAIOptions');-+const openaiOptions = providers.getOpenAIOptions(opts);expect(openaiOptions.model).toBe(modelName);});@@ -153,7 +153,7 @@ describe('LLM Model Selection with Special Characters', () => {});const service = new OpenAIService();-+// Access the private openai client through the serviceconst client = (service as any).getClient('test-key');const createSpy = vi.spyOn(client.chat.completions, 'create');@@ -213,7 +213,7 @@ describe('LLM Model Selection with Special Characters', () => {});const service = new AnthropicService();-+// Access the private anthropic clientconst client = (service as any).getClient('test-key');const createSpy = vi.spyOn(client.messages, 'create');@@ -278,7 +278,7 @@ describe('LLM Model Selection with Special Characters', () => {const ollamaOptions = await providers.getOllamaOptions(opts);expect(ollamaOptions.model).toBe(modelName);-+// Also test with model specified in optionsconst optsWithModel: ChatCompletionOptions = {model: 'another/model:v2.0@beta',@@ -370,7 +370,7 @@ describe('LLM Model Selection with Special Characters', () => {describe('Integration with REST API', () => {it('should pass model names correctly through REST chat service', async () => {const modelName = 'gpt-4.1-turbo-preview@latest';-+// Mock the configuration helpersvi.doMock('../config/configuration_helpers.js', () => ({getSelectedModelConfig: vi.fn().mockResolvedValue({@@ -382,8 +382,8 @@ describe('LLM Model Selection with Special Characters', () => {const { getSelectedModelConfig } = await import('../config/configuration_helpers.js');const config = await getSelectedModelConfig();-+expect(config?.model).toBe(modelName);});});-});+});\ No newline at end of filediff --git a/apps/server/src/services/llm/providers/openai_service.spec.ts b/apps/server/src/services/llm/providers/openai_service.spec.tsindex 0529640fad..39544fabc6 100644--- a/apps/server/src/services/llm/providers/openai_service.spec.ts+++ b/apps/server/src/services/llm/providers/openai_service.spec.ts@@ -53,22 +53,22 @@ describe('OpenAIService', () => {describe('isAvailable', () => {it('should return true when base checks pass', () => {vi.mocked(options.getOptionBool).mockReturnValueOnce(true); // AI enabled-+const result = service.isAvailable();-+expect(result).toBe(true);});it('should return false when AI is disabled', () => {vi.mocked(options.getOptionBool).mockReturnValueOnce(false); // AI disabled-+const result = service.isAvailable();-+expect(result).toBe(false);});});- describe.skip('generateChatCompletion', () => {+ describe('generateChatCompletion', () => {const messages: Message[] = [{ role: 'user', content: 'Hello' }];@@ -89,7 +89,7 @@ describe('OpenAIService', () => {enableTools: false};vi.mocked(providers.getOpenAIOptions).mockReturnValueOnce(mockOptions);-+// Mock the getClient method to return our mock clientconst mockCompletion = {id: 'chatcmpl-123',@@ -120,9 +120,9 @@ describe('OpenAIService', () => {};vi.spyOn(service as any, 'getClient').mockReturnValue(mockClient);-+const result = await service.generateChatCompletion(messages);-+expect(result).toEqual({text: 'Hello! How can I help you today?',model: 'gpt-3.5-turbo',@@ -144,7 +144,7 @@ describe('OpenAIService', () => {stream: true};vi.mocked(providers.getOpenAIOptions).mockReturnValueOnce(mockOptions);-+// Mock the streaming responseconst mockStream = {[Symbol.asyncIterator]: async function* () {@@ -162,7 +162,7 @@ describe('OpenAIService', () => {};}};-+const mockClient = {chat: {completions: {@@ -172,9 +172,9 @@ describe('OpenAIService', () => {};vi.spyOn(service as any, 'getClient').mockReturnValue(mockClient);-+const result = await service.generateChatCompletion(messages);-+expect(result).toHaveProperty('stream');expect(result.text).toBe('');expect(result.model).toBe('gpt-3.5-turbo');@@ -183,7 +183,7 @@ describe('OpenAIService', () => {it('should throw error if service not available', async () => {vi.mocked(options.getOptionBool).mockReturnValueOnce(false); // AI disabled-+await expect(service.generateChatCompletion(messages)).rejects.toThrow('OpenAI service is not available');@@ -197,7 +197,7 @@ describe('OpenAIService', () => {stream: false};vi.mocked(providers.getOpenAIOptions).mockReturnValueOnce(mockOptions);-+const mockClient = {chat: {completions: {@@ -207,7 +207,7 @@ describe('OpenAIService', () => {};vi.spyOn(service as any, 'getClient').mockReturnValue(mockClient);-+await expect(service.generateChatCompletion(messages)).rejects.toThrow('API Error: Invalid API key');@@ -222,7 +222,7 @@ describe('OpenAIService', () => {parameters: {}}}];-+const mockOptions = {apiKey: 'test-key',baseUrl: 'https://api.openai.com/v1',@@ -233,7 +233,7 @@ describe('OpenAIService', () => {tool_choice: 'auto'};vi.mocked(providers.getOpenAIOptions).mockReturnValueOnce(mockOptions);-+const mockCompletion = {id: 'chatcmpl-123',object: 'chat.completion',@@ -263,9 +263,9 @@ describe('OpenAIService', () => {};vi.spyOn(service as any, 'getClient').mockReturnValue(mockClient);-+await service.generateChatCompletion(messages);-+const createCall = mockClient.chat.completions.create.mock.calls[0][0];expect(createCall.tools).toEqual(mockTools);expect(createCall.tool_choice).toBe('auto');@@ -281,7 +281,7 @@ describe('OpenAIService', () => {tools: [{ type: 'function' as const, function: { name: 'test', description: 'test' } }]};vi.mocked(providers.getOpenAIOptions).mockReturnValueOnce(mockOptions);-+const mockCompletion = {id: 'chatcmpl-123',object: 'chat.completion',@@ -319,9 +319,9 @@ describe('OpenAIService', () => {};vi.spyOn(service as any, 'getClient').mockReturnValue(mockClient);-+const result = await service.generateChatCompletion(messages);-+expect(result).toEqual({text: '',model: 'gpt-3.5-turbo',@@ -342,4 +342,4 @@ describe('OpenAIService', () => {});});});-});+});\ No newline at end of file