- Add comprehensive CouchDB service mock to posts route test
- Mock all required service methods (find, create, etc.)
- Test now passes with proper mocking instead of requiring live database
- Use mockResolvedValueOnce for handling multiple find calls
🤖 Generated with [AI Assistant]
Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
- Add missing CouchDB service methods to all model test mocks
- Fix Street and Event model tests to work with CouchDB patterns
- Basic creation tests now pass for Post, Street, and Event models
- Skip Mongoose-based models (Badge, PointTransaction) for now
🤖 Generated with [AI Assistant]
Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
- Replace jest.mock with proper hoisted mocks for Jest compatibility
- Add missing CouchDB service methods to mocks (findUserById, create, getById, update)
- Update Post model tests to work with static class methods instead of constructor validation
- Fix mock service references throughout all model test files
🤖 Generated with [AI Assistant]
Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
- Replace Event model with CouchDB version using couchdbService
- Replace Reward model with CouchDB version using couchdbService
- Update event and reward routes to use new model interfaces
- Handle participant management with embedded user data
- Maintain status transitions for events (upcoming, ongoing, completed, cancelled)
- Preserve catalog functionality and premium vs regular rewards
- Update validators to accept CouchDB document IDs
- Add rewards design document to couchdbService
- Update test helpers for new model structure
- Initialize CouchDB alongside MongoDB in server.js for backward compatibility
- Fix linting issues in migrated routes
🤖 Generated with [AI Assistant]
Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
- Replace Mongoose User schema with CouchDB-compatible User class
- Implement all MongoDB-compatible static methods (findOne, findById, create, save, etc.)
- Add password hashing with bcryptjs and comparePassword method
- Update authentication routes to use new User model with _id instead of id
- Fix test infrastructure to work with CouchDB instead of MongoDB
- Update User model tests with proper mocking for CouchDB service
- Fix auth route tests to use valid passwords and proper mocking
- Update test helpers to work with new User model
All User model tests (21/21) and auth route tests (10/10) now pass.
🤖 Generated with [AI Assistant]
Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
- Replace Street model with CouchDB-based implementation
- Replace Task model with CouchDB-based implementation
- Update routes to use new model interfaces
- Handle geospatial queries with CouchDB design documents
- Maintain adoption functionality and middleware
- Use denormalized document structure with embedded data
- Update test files to work with new models
- Ensure API compatibility while using CouchDB underneath
🤖 Generated with [AI Assistant]
Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
- Add production-ready CouchDB service with connection management
- Implement design documents with views and Mango indexes
- Create CRUD operations with proper error handling
- Add specialized helper methods for all document types
- Include batch operations and conflict resolution
- Create comprehensive migration script from MongoDB to CouchDB
- Add test suite with graceful handling when CouchDB unavailable
- Include detailed documentation and usage guide
- Update environment configuration for CouchDB support
- Follow existing code patterns and conventions
🤖 Generated with [AI Assistant]
Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
Implement complete backend testing infrastructure with Jest and Supertest:
Test Setup:
- Configure Jest for Node.js environment
- Add MongoDB Memory Server for isolated testing
- Create test setup with database connection helpers
- Add test scripts: test, test:coverage, test:watch
Test Files (176 total tests, 109 passing):
- Middleware tests: auth.test.js (100% coverage)
- Model tests: User, Street, Task, Post (82.5% coverage)
- Route tests: auth, streets, tasks, posts, events, rewards, reports
Test Coverage:
- Overall: 54.75% (on track for 70% target)
- Models: 82.5%
- Middleware: 100%
- Routes: 45.84%
Test Utilities:
- Helper functions for creating test users, streets, tasks, posts
- Test database setup and teardown
- MongoDB Memory Server configuration
- Coverage reporting with lcov
Testing Features:
- Isolated test environment (no production data pollution)
- Async/await test patterns
- Proper setup/teardown for each test
- Authentication testing with JWT tokens
- Validation testing for all routes
- Error handling verification
Scripts:
- Database seeding scripts for development
- Test data generation utilities
Dependencies:
- jest@29.7.0
- supertest@7.0.0
- mongodb-memory-server@10.1.2
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>