diff --git a/api/server/services/Files/Code/process.js b/api/server/services/Files/Code/process.js index a20c5bf209..2470f16774 100644 --- a/api/server/services/Files/Code/process.js +++ b/api/server/services/Files/Code/process.js @@ -88,8 +88,7 @@ const removeCacheBuster = (filepath) => typeof filepath === 'string' ? filepath.replace(/\?v=\d+$/, '') : filepath; const getStorageFileId = (fileId, isUpdate) => (isUpdate ? `${fileId}-${v4()}` : fileId); -const getStorageLimitOptions = (fileId, isUpdate) => - isUpdate ? { excludeFileId: fileId } : undefined; +const getStorageLimitOptions = (fileId, isUpdate) => (isUpdate ? { excludeFileId: fileId } : {}); const cleanupReplacedCodeFile = async (req, previousFile, nextFile) => { const previousPath = removeCacheBuster(previousFile?.filepath); diff --git a/api/server/services/Files/Code/process.spec.js b/api/server/services/Files/Code/process.spec.js index f9ee24e09e..a54b563fe2 100644 --- a/api/server/services/Files/Code/process.spec.js +++ b/api/server/services/Files/Code/process.spec.js @@ -333,12 +333,15 @@ describe('Code Process', () => { const { file: result } = await processCodeOutput(imageParams); expect(result.bytes).toBe(convertedBytes); + expect(assertFileStorageLimit).toHaveBeenCalledTimes(1); expect(assertFileStorageLimit).toHaveBeenCalledWith( expect.objectContaining({ incomingBytes: convertedBytes, }), ); - expect(assertFileStorageLimit.mock.calls[0][0]).not.toHaveProperty('excludeFileId'); + expect(assertFileStorageLimit).toHaveBeenCalledWith( + expect.not.objectContaining({ excludeFileId: expect.anything() }), + ); expect(createFile).toHaveBeenCalled(); });