🧪 testing improvement: add unit tests for upload-excel api and fix failing tests#7
🧪 testing improvement: add unit tests for upload-excel api and fix failing tests#7deitaur wants to merge 1 commit into
Conversation
- Added comprehensive tests for `POST /api/upload-excel` to handle the Excel upload, parsing logic, and DB transactions handling. - Covered happy path, missing file (400 code), and DB errors resulting in rollback (500 code). - Fixed the previous failing tests in `__tests__/api.test.js` by globally intercepting Passport's `req.isAuthenticated()` and `req.user` through `Object.defineProperty` and fixing `pg` queries. Co-authored-by: deitaur <113350206+deitaur@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What:
POST /api/upload-excellacked any unit testing, leaving crucial logic regarding importing user inventories from Excel vulnerable to regressions.api.test.jswere completely broken due to theensureAuthenticatedcheckingreq.userfrom Passport.js, which was undefined since we didn't mock Passport appropriately before importingapp.📊 Coverage:
pgconnection pools/clients to interceptBEGIN,COMMIT,ROLLBACKand query execution.POST /api/upload-excelthat dynamically create a real Excel document in buffer to test theexceljsloading logic properly.app.request.isAuthenticatedandapp.request.userto easily mock authenticated sessions forsupertest.✨ Result:
passportand missing.envmock parameters.PR created automatically by Jules for task 14958525485771934442 started by @deitaur