Description
Build comprehensive test coverage for the analytics purge cron job, verifying correct retention-window enforcement, batch deletion behavior, and handling of concurrent purge executions.
Requirements and Context
- Testing: Target
apps/backend/src/app/api/cron/purge-analytics/route.ts
- Coverage: Cover retention window, batch deletion, and concurrency
- Documentation: Document the purge retention policy
Suggested Execution
Branch: test/issue-048-analytics-purge-cron-tests
Implement Changes
- Add tests verifying only data older than the retention window is purged
- Test batch deletion behavior for large datasets
- Assert that recent data within the retention window is never deleted
- Test concurrent purge execution safety
Test and Commit
- Cover retention boundary, batch deletion, and concurrency
- Assert data within retention is preserved
- Document the retention policy in route JSDoc
Example Commit Message
test(cron): add comprehensive coverage for analytics purge edge cases
- Verify retention window enforcement
- Test batch deletion for large datasets
- Assert concurrent purge execution safety
Guidelines
- Use fake timers to control the retention boundary
- Test the exact retention boundary (just inside vs just outside)
- Mock the database to verify deletion queries
Description
Build comprehensive test coverage for the analytics purge cron job, verifying correct retention-window enforcement, batch deletion behavior, and handling of concurrent purge executions.
Requirements and Context
apps/backend/src/app/api/cron/purge-analytics/route.tsSuggested Execution
Branch:
test/issue-048-analytics-purge-cron-testsImplement Changes
Test and Commit
Example Commit Message
Guidelines