@@ -18,10 +18,6 @@ vi.mock('@/lib/uploads/contexts/workspace/workspace-file-manager', () => ({
1818import { readFileRecord } from '@/lib/copilot/vfs/file-reader'
1919
2020const MAX_IMAGE_READ_BYTES = 5 * 1024 * 1024
21- const TINY_PNG = Buffer . from (
22- 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADUlEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC' ,
23- 'base64'
24- )
2521
2622async function makeNoisePng ( width : number , height : number ) : Promise < Buffer > {
2723 const sharp = ( await import ( 'sharp' ) ) . default
@@ -35,29 +31,6 @@ async function makeNoisePng(width: number, height: number): Promise<Buffer> {
3531const SHARP_TEST_TIMEOUT_MS = 30_000
3632
3733describe ( 'readFileRecord' , ( ) => {
38- it ( 'returns small images as attachments without resize note' , async ( ) => {
39- downloadWorkspaceFile . mockResolvedValue ( TINY_PNG )
40-
41- const result = await readFileRecord ( {
42- id : 'wf_small' ,
43- workspaceId : 'ws_1' ,
44- name : 'small.png' ,
45- key : 'uploads/small.png' ,
46- path : '/api/files/serve/uploads%2Fsmall.png?context=mothership' ,
47- size : TINY_PNG . length ,
48- type : 'image/png' ,
49- uploadedBy : 'user_1' ,
50- uploadedAt : new Date ( ) ,
51- deletedAt : null ,
52- storageContext : 'mothership' ,
53- } )
54-
55- expect ( result ?. attachment ?. type ) . toBe ( 'image' )
56- expect ( result ?. attachment ?. source . media_type ) . toBe ( 'image/png' )
57- expect ( result ?. content ) . not . toContain ( 'resized for vision' )
58- expect ( Buffer . from ( result ?. attachment ?. source . data ?? '' , 'base64' ) ) . toEqual ( TINY_PNG )
59- } )
60-
6134 it (
6235 'downscales oversized images into attachments that fit the read limit' ,
6336 async ( ) => {
0 commit comments