@@ -120,6 +120,53 @@ describe('BatchImageProcessor — Vault-wide orchestration', () => {
120120 expect ( folderAndFilenameManagement . handleNameConflicts ) . toHaveBeenCalled ( ) ;
121121 } ) ;
122122
123+ it ( '4.12 Given convertTo=disabled (ORIGINAL), When processing, Then files are NOT renamed' , async ( ) => {
124+ // Fresh isolated environment with convertTo=disabled
125+ const noteFile = fakeTFile ( { path : 'notes/test.md' } ) ;
126+ const pngImage = fakeTFile ( { path : 'images/photo.png' } ) ;
127+ const jpgImage = fakeTFile ( { path : 'images/picture.jpg' } ) ;
128+ const vaultIso = fakeVault ( { files : [ noteFile , pngImage , jpgImage ] } ) as any ;
129+ const appIso = fakeApp ( {
130+ vault : vaultIso ,
131+ metadataCache : { resolvedLinks : { [ noteFile . path ] : { [ pngImage . path ] : 1 , [ jpgImage . path ] : 1 } } } as any
132+ } ) as any ;
133+ appIso . fileManager = { renameFile : vi . fn ( async ( file : any , newPath : string ) => { await appIso . vault . rename ( file , newPath ) ; } ) } ;
134+
135+ // convertTo=disabled means keep original format - set ALL required settings explicitly
136+ const pluginIso = makePluginStub ( {
137+ settings : {
138+ ProcessAllVaultconvertTo : 'disabled' ,
139+ ProcessAllVaultquality : 0.8 , // compression applied (not 1, so processing should occur)
140+ ProcessAllVaultResizeModalresizeMode : 'None' ,
141+ ProcessAllVaultResizeModaldesiredWidth : 0 ,
142+ ProcessAllVaultResizeModaldesiredHeight : 0 ,
143+ ProcessAllVaultResizeModaldesiredLength : 0 ,
144+ ProcessAllVaultEnlargeOrReduce : 'Always' ,
145+ allowLargerFiles : true ,
146+ ProcessAllVaultSkipFormats : '' ,
147+ ProcessAllVaultskipImagesInTargetFormat : false // Important: don't skip images in their own format
148+ }
149+ } ) ;
150+ const imgIso = { processImage : vi . fn ( async ( _blob : Blob ) => new ArrayBuffer ( 4 ) ) } ;
151+ const ffmIso = { handleNameConflicts : vi . fn ( async ( _dir : string , name : string ) => name ) } ;
152+ const bipIso = new BatchImageProcessor ( appIso as any , pluginIso as any , imgIso as any , ffmIso as any ) ;
153+
154+ await bipIso . processAllVaultImages ( ) ;
155+
156+ // Images should be processed (compression applied)
157+ expect ( imgIso . processImage ) . toHaveBeenCalled ( ) ;
158+
159+ // But NO renames should have occurred - files keep their original extensions
160+ expect ( appIso . fileManager . renameFile ) . not . toHaveBeenCalled ( ) ;
161+
162+ // Verify the files still exist with original names
163+ expect ( appIso . vault . getAbstractFileByPath ( 'images/photo.png' ) ) . toBeTruthy ( ) ;
164+ expect ( appIso . vault . getAbstractFileByPath ( 'images/picture.jpg' ) ) . toBeTruthy ( ) ;
165+ // And NOT renamed to .original
166+ expect ( appIso . vault . getAbstractFileByPath ( 'images/photo.original' ) ) . toBeFalsy ( ) ;
167+ expect ( appIso . vault . getAbstractFileByPath ( 'images/picture.original' ) ) . toBeFalsy ( ) ;
168+ } ) ;
169+
123170 it ( '4.10 Skip target format (vault): when convertTo=webp and skipImagesInTargetFormat=true, webp files are skipped' , async ( ) => {
124171 // Fresh, isolated environment to avoid mutated TFile state across tests
125172 const noteFile = fakeTFile ( { path : 'notes/m.md' } ) ;
0 commit comments