Skip to content

test: add unit tests for analytics-range helpers - #900

Open
Ishaan-Gpt wants to merge 1 commit into
Coder-s-OG-s:mainfrom
Ishaan-Gpt:test-analytics-range-885
Open

Ishaan-Gpt wants to merge 1 commit into
Coder-s-OG-s:mainfrom
Ishaan-Gpt:test-analytics-range-885

Conversation

@Ishaan-Gpt

Copy link
Copy Markdown

Summary

Adds unit tests for the analytics range helpers in src/lib/maintainer/analytics-range.ts, covering one file from the #885 checklist as requested (one test file per PR).

Type of Change

  • Bug fix
  • New feature
  • UI / UX improvement
  • Refactor
  • Documentation
  • Other (unit tests)

Related Issue

Related to #885

What was changed?

New file src/lib/maintainer/analytics-range.test.ts (19 tests):

  • parseRange: valid ranges (7d, 30d, 90d, all) pass through; undefined, empty, and invalid inputs fall back to 30d.
  • rangeToDateBounds: 7d/30d/90d span the right number of days ending at now; all starts at 2000-01-01; the input date is not mutated; each call returns fresh Date instances; day subtraction works across month boundaries.

Screenshots

Not applicable (no UI changes).

Checklist

  • My code follows the project structure and conventions
  • I tested this locally (npx vitest run src/lib/maintainer/analytics-range.test.ts — 19/19 pass)
  • No hardcoded secrets or credentials
  • I have updated documentation if needed
  • npm run lint and prettier --check pass on the new file; tsc --noEmit shows no new errors

Covers parseRange (valid inputs pass through, invalid and
undefined default to 30d) and rangeToDateBounds (7d, 30d, 90d
spans, the all range starting at 2000-01-01, no mutation of the
input date, fresh Date instances per call, and month-boundary
subtraction). Part of Coder-s-OG-s#885.
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

This PR has had no activity for 7 days. Are you still working on it? If so, please push an update or leave a comment. Otherwise it will be labeled stale in another 7 days.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant