Refactor tests and improve error handling across various services
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 10m38s

- Updated `useAuth` tests to use async functions for JSON responses to avoid promise resolution issues.
- Changed `AdminBrandManager` tests to use `mockImplementation` for consistent mock behavior.
- Enhanced `ProfileManager.Authenticated` tests to ensure proper error handling and assertions for partial updates.
- Modified `SystemCheck` tests to prevent memory leaks by using `mockImplementation` for API calls.
- Improved error handling in `ai.routes.ts` by refining validation schemas and adding error extraction utility.
- Updated `auth.routes.test.ts` to inject mock logger for better error tracking.
- Refined `flyer.routes.ts` to ensure proper validation and error handling for flyer ID parameters.
- Enhanced `admin.db.ts` to ensure specific errors are re-thrown for better error management.
- Updated `budget.db.test.ts` to improve mock behavior and ensure accurate assertions.
- Refined `flyer.db.ts` to improve error handling for race conditions during store creation.
- Enhanced `notification.db.test.ts` to ensure specific error types are tested correctly.
- Updated `recipe.db.test.ts` to ensure proper handling of not found errors.
- Improved `user.db.ts` to ensure consistent error handling for user retrieval.
- Enhanced `flyerProcessingService.server.test.ts` to ensure accurate assertions on transformed data.
- Updated `logger.server.ts` to disable transport in test environments to prevent issues.
- Refined `queueService.workers.test.ts` to ensure accurate mocking of email service.
- Improved `userService.test.ts` to ensure proper mock implementations for repository classes.
- Enhanced `checksum.test.ts` to ensure reliable file content creation in tests.
- Updated `pdfConverter.test.ts` to reset shared state objects and mock implementations before each test.
This commit is contained in:
2025-12-15 16:40:13 -08:00
parent 0c590675b3
commit d5f185ad99
32 changed files with 430 additions and 182 deletions

View File

@@ -48,6 +48,7 @@
"passport-local": "^1.0.0",
"pdfjs-dist": "^5.4.394",
"pg": "^8.16.3",
"pino": "^10.1.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-hot-toast": "^2.6.0",
@@ -100,6 +101,7 @@
"istanbul-reports": "^3.2.0",
"jsdom": "^27.2.0",
"nyc": "^17.1.0",
"pino-pretty": "^13.1.3",
"postcss": "^8.5.6",
"rimraf": "^6.1.2",
"supertest": "^7.1.4",