You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test(mongodb): verify User schema behaviors under connection state 99 (JhaSourav07#2019)
## Description
FixesJhaSourav07#1415
Added a comprehensive Vitest test case in `models/User.test.ts` to
document and verify the schema's behavior when the database connection
is uninitialized (State 99).
**Changes made:**
- Utilized Vitest's `vi.spyOn` to mock `mongoose.connection.readyState`,
forcing it to return `99` (Uninitialized).
- Mocked the `User.findOne` database operation to simulate Mongoose's
lazy initialization fallback (buffering).
- Verified that the model successfully queues and resolves the operation
rather than crashing the application when uninitialized.
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [ ] 📐 Pillar 2 — Geometric SVG Improvement
- [ ] 🕐 Pillar 3 — Timezone Logic Optimization
- [x] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
*N/A - This PR adds backend database tests; no visual UI changes were
made.*
## Checklist before requesting a review:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
- [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
- [x] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have started the repo.
- [x] I have made sure that i have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
- [x](Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.
0 commit comments