Achieve 100% test coverage for Cart model
- Added comprehensive unit tests (26 tests) covering Cart business logic
- Created integration tests (13 tests) with real database objects
- Fixed original production bug: free carts with coupons not crashing
- Covered critical payment threshold logic (64 cent minimum)
- Added tests for coupon validation, inventory management, and handling costs
- Increased coverage from ~35% to 100% (296/296 lines)
Key areas tested:
- Cart operations (add/remove products, quantity management)
- Payment requirements and discount calculations
- Physical product handling and inventory checks
- Coupon validation and redemption limits
- Cart merging and edge cases
- ORM relationships and database boundaries
This comprehensive test suite prevents regressions and ensures reliable cart/checkout functionality in production.
Summary by CodeRabbit
-
Documentation
- Added a new documentation file with detailed development notes, project setup instructions, environment management, testing guidelines, and commit message policies.
-
Tests
- Introduced an extensive suite of unit tests for cart functionality, covering payment logic, cart content management, merging, coupon validation, handling costs, and property methods.
-
Chores
- Added a Makefile target to run tests with coverage reporting, including terminal and HTML output.
Edited by CodeRabbit