From 0edd20fc3809bcfbd141b010aed3cc10ef3badec Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 5 Jun 2026 15:38:01 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20reconcile=20specs=20+=20?= =?UTF-8?q?lint=20with=20dev=20after=20rebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - guard optional primeResources attachments (result.attachments?.map) - revert 4 attachments assertions toEqual([]) -> toBeUndefined() to match dev's empty/no-attachments return contract (the PR's earlier toEqual([]) change predated dev returning undefined for those paths) - drop unused TDefaultLLMDeliveryPathConfig import in file-config.spec.ts - prettier formatting in resolve-llm-delivery-path.spec.ts --- packages/api/src/agents/resources.test.ts | 16 ++++++++-------- packages/data-provider/src/file-config.spec.ts | 1 - .../src/resolve-llm-delivery-path.spec.ts | 13 ++++++++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/api/src/agents/resources.test.ts b/packages/api/src/agents/resources.test.ts index 34d97501b7..1ef8b75be8 100644 --- a/packages/api/src/agents/resources.test.ts +++ b/packages/api/src/agents/resources.test.ts @@ -115,7 +115,7 @@ describe('primeResources', () => { }); expect(mockGetFiles).not.toHaveBeenCalled(); - expect(result.attachments).toEqual([]); + expect(result.attachments).toBeUndefined(); expect(result.tool_resources).toEqual(tool_resources); }); }); @@ -1347,7 +1347,7 @@ describe('primeResources', () => { role: 'USER', agentId: 'agent_shared', }); - expect(result.attachments).toEqual([]); + expect(result.attachments).toBeUndefined(); }); it('should skip filtering when filterFiles is not provided', async () => { @@ -1515,8 +1515,8 @@ describe('primeResources', () => { expect(mockGetFiles).not.toHaveBeenCalled(); // When appConfig agents endpoint is missing, context is disabled - // and no attachments are provided, the function returns an empty array - expect(result.attachments).toEqual([]); + // and no attachments are provided, the function returns undefined + expect(result.attachments).toBeUndefined(); }); it('should handle undefined tool_resources', async () => { @@ -1530,7 +1530,7 @@ describe('primeResources', () => { }); expect(result.tool_resources).toEqual({}); - expect(result.attachments).toEqual([]); + expect(result.attachments).toBeUndefined(); }); it('should handle empty requestFileSet', async () => { @@ -1609,7 +1609,7 @@ describe('primeResources', () => { agentId: 'agent1', }); - const attachmentIds = result.attachments.map((f) => f?.file_id); + const attachmentIds = result.attachments?.map((f) => f?.file_id); expect(attachmentIds).toContain('provider-file'); expect(attachmentIds).toContain('none-file'); }); @@ -1642,7 +1642,7 @@ describe('primeResources', () => { loadCodeApiKey: jest.fn().mockResolvedValue('code-key'), }); - expect(result.attachments.map((f) => f?.file_id)).toContain('none-file'); + expect(result.attachments?.map((f) => f?.file_id)).toContain('none-file'); expect(result.provisionState?.codeEnvFiles.map((f) => f.file_id)).toContain('none-file'); expect(result.provisionState?.vectorDBFiles.map((f) => f.file_id)).toContain('none-file'); }); @@ -1672,7 +1672,7 @@ describe('primeResources', () => { agentId: 'agent1', }); - const attachmentIds = result.attachments.map((f) => f?.file_id); + const attachmentIds = result.attachments?.map((f) => f?.file_id); expect(attachmentIds).toContain('legacy-file'); }); }); diff --git a/packages/data-provider/src/file-config.spec.ts b/packages/data-provider/src/file-config.spec.ts index 838bcec95c..ba55fae2ae 100644 --- a/packages/data-provider/src/file-config.spec.ts +++ b/packages/data-provider/src/file-config.spec.ts @@ -1,4 +1,3 @@ -import type { TDefaultLLMDeliveryPathConfig } from './file-config'; import type { FileConfig } from './types/files'; import { fileConfig as baseFileConfig, diff --git a/packages/data-provider/src/resolve-llm-delivery-path.spec.ts b/packages/data-provider/src/resolve-llm-delivery-path.spec.ts index c69c676472..2a2cc2829c 100644 --- a/packages/data-provider/src/resolve-llm-delivery-path.spec.ts +++ b/packages/data-provider/src/resolve-llm-delivery-path.spec.ts @@ -1,4 +1,7 @@ -import { resolveDefaultLLMDeliveryPath, SYSTEM_LLM_DELIVERY_DEFAULTS } from './resolve-llm-delivery-path'; +import { + resolveDefaultLLMDeliveryPath, + SYSTEM_LLM_DELIVERY_DEFAULTS, +} from './resolve-llm-delivery-path'; import type { TDefaultLLMDeliveryPathConfig } from './file-config'; describe('resolveDefaultLLMDeliveryPath', () => { @@ -69,8 +72,12 @@ describe('resolveDefaultLLMDeliveryPath', () => { it('should fall through entire chain to system defaults', () => { const endpointConfig: TDefaultLLMDeliveryPathConfig = {}; const globalConfig: TDefaultLLMDeliveryPathConfig = {}; - expect(resolveDefaultLLMDeliveryPath('image/png', endpointConfig, globalConfig)).toBe('provider'); - expect(resolveDefaultLLMDeliveryPath('application/pdf', endpointConfig, globalConfig)).toBe('provider'); + expect(resolveDefaultLLMDeliveryPath('image/png', endpointConfig, globalConfig)).toBe( + 'provider', + ); + expect(resolveDefaultLLMDeliveryPath('application/pdf', endpointConfig, globalConfig)).toBe( + 'provider', + ); expect(resolveDefaultLLMDeliveryPath('text/csv', endpointConfig, globalConfig)).toBe('text'); });