Skip to content

Establish Comprehensive Test Coverage for Cron Job Analytics Purge Edge Cases #584

@temma02

Description

@temma02

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions