From 0275ab0108e9a411d90d8ef8c8d70e21e498d81a Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Date: Wed, 2 Jul 2025 00:52:32 +0530 Subject: feat: add audio and video support to read_file (#2556) --- packages/core/src/utils/fileUtils.test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'packages/core/src/utils/fileUtils.test.ts') diff --git a/packages/core/src/utils/fileUtils.test.ts b/packages/core/src/utils/fileUtils.test.ts index 4f4c7c1e..0455b6e1 100644 --- a/packages/core/src/utils/fileUtils.test.ts +++ b/packages/core/src/utils/fileUtils.test.ts @@ -211,6 +211,16 @@ describe('fileUtils', () => { expect(detectFileType('file.pdf')).toBe('pdf'); }); + it('should detect audio type by extension', () => { + mockMimeLookup.mockReturnValueOnce('audio/mpeg'); + expect(detectFileType('song.mp3')).toBe('audio'); + }); + + it('should detect video type by extension', () => { + mockMimeLookup.mockReturnValueOnce('video/mp4'); + expect(detectFileType('movie.mp4')).toBe('video'); + }); + it('should detect known binary extensions as binary (e.g. .zip)', () => { mockMimeLookup.mockReturnValueOnce('application/zip'); expect(detectFileType('archive.zip')).toBe('binary'); @@ -427,5 +437,23 @@ describe('fileUtils', () => { ); expect(result.isTruncated).toBe(true); }); + + it('should return an error if the file size exceeds 20MB', async () => { + // Create a file just over 20MB + const twentyOneMB = 21 * 1024 * 1024; + const buffer = Buffer.alloc(twentyOneMB, 0x61); // Fill with 'a' + actualNodeFs.writeFileSync(testTextFilePath, buffer); + + const result = await processSingleFileContent( + testTextFilePath, + tempRootDir, + ); + + expect(result.error).toContain('File size exceeds the 20MB limit'); + expect(result.returnDisplay).toContain( + 'File size exceeds the 20MB limit', + ); + expect(result.llmContent).toContain('File size exceeds the 20MB limit'); + }); }); }); -- cgit v1.2.3