refactor: update test file naming conventions for clarity and consistency
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m22s

This commit is contained in:
2025-12-04 09:11:21 -08:00
parent 2f64e348fc
commit aac04353a3
4 changed files with 12 additions and 7 deletions

View File

@@ -37,8 +37,13 @@ const diskStorage = multer.diskStorage({
cb(null, storagePath);
},
filename: function (req, file, cb) {
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9);
cb(null, file.fieldname + '-' + uniqueSuffix + '-' + file.originalname);
// If in a test environment, use a predictable filename for easy cleanup.
if (process.env.NODE_ENV === 'test') {
cb(null, `${file.fieldname}-test-flyer-image.jpg`);
} else {
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9);
cb(null, file.fieldname + '-' + uniqueSuffix + '-' + file.originalname);
}
}
});
// 2. Memory storage for endpoints that only need to analyze the file in memory without saving it.

View File

@@ -71,7 +71,7 @@ describe('Flyer Processing Background Job Integration Test', () => {
// Arrange: Load a mock flyer PDF.
const imagePath = path.resolve(__dirname, '../assets/test-flyer-image.jpg');
const imageBuffer = await fs.readFile(imagePath);
const mockImageFile = new File([imageBuffer], 'flyer-test-flyer-image.jpg', { type: 'image/jpeg' });
const mockImageFile = new File([imageBuffer], 'test-flyer-image.jpg', { type: 'image/jpeg' });
const checksum = await generateFileChecksum(mockImageFile);
// Act 1: Upload the file to start the background job.