Security Fixes
This commit is contained in:
@@ -27,7 +27,7 @@ backend/src/features/[name]/tests/
|
||||
make test
|
||||
```
|
||||
|
||||
This executes: `docker-compose exec backend npm test`
|
||||
This executes: `docker compose exec backend npm test`
|
||||
|
||||
### Feature-Specific Testing
|
||||
```bash
|
||||
@@ -45,9 +45,9 @@ npm test -- features/vehicles --coverage
|
||||
|
||||
### Test Environment Setup
|
||||
1. **Container-Based**: All tests run inside Docker containers
|
||||
2. **Test Database**: Isolated test database per feature
|
||||
3. **Mock External APIs**: No real API calls during testing
|
||||
4. **Cleanup**: Automatic test data cleanup after each test
|
||||
2. **Database**: Uses the development database in the stack (`motovaultpro`)
|
||||
3. **Mock External APIs**: No real API calls during testing (where implemented)
|
||||
4. **Cleanup**: Prefer transactions/cleanup per test; see feature tests for patterns
|
||||
|
||||
## Test Types
|
||||
|
||||
@@ -149,10 +149,14 @@ make clean && make dev
|
||||
**Coverage**: Exclude node_modules, include src only
|
||||
|
||||
### Database Testing
|
||||
- **Test DB**: Same as development (motovaultpro)
|
||||
- **Transactions**: Each test runs in transaction, rolled back after
|
||||
- **Isolation**: Tests cannot interfere with each other
|
||||
- **Seeding**: Minimal seed data, test-specific fixtures
|
||||
- **DB**: Same as development (`motovaultpro`) within Docker
|
||||
- **Transactions**: Recommended pattern is one transaction per test
|
||||
- **Isolation**: Keep tests independent; avoid shared state
|
||||
- **Seeding**: Use feature-level fixtures when needed
|
||||
|
||||
### Coverage and Availability
|
||||
- Full test suite exists for `vehicles`.
|
||||
- Other features (e.g., `fuel-logs`, `stations`, `maintenance`) have placeholders and are being built out.
|
||||
|
||||
### Mock Strategy
|
||||
- **External APIs**: Completely mocked (vPIC, Google Maps)
|
||||
@@ -214,7 +218,7 @@ make rebuild
|
||||
#### Database Connection Issues
|
||||
```bash
|
||||
# Check postgres container
|
||||
docker-compose logs postgres
|
||||
docker compose logs postgres
|
||||
|
||||
# Reset database
|
||||
make clean && make dev
|
||||
@@ -288,4 +292,4 @@ describe('Error Handling', () => {
|
||||
- Mock API failures to test error handling
|
||||
- Test timeout scenarios
|
||||
- Test network connectivity issues
|
||||
- Verify graceful degradation paths
|
||||
- Verify graceful degradation paths
|
||||
|
||||
Reference in New Issue
Block a user