Add unit tests for determineTimeRange - #7322
Conversation
✅ Deploy Preview for pipecd-site canceled.
|
There was a problem hiding this comment.
🟡 Changes recommended
The MONTHLY test suite is missing coverage for LAST_1_WEEK and LAST_1_MONTH, which are selectable in the UI and currently fall through to “month-to-date” behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds unit test coverage for the determineTimeRange utility used by the Insights queries, validating UTC [from, to] boundaries for common preset ranges.
Changes:
- Introduces
web/src/utils/determine-time-range.test.tswith Jest fake timers and a fixed “now” timestamp. - Adds assertions for all DAILY ranges and the currently-handled MONTHLY ranges (3+ months), verifying start/end-of-day and start-of-month behavior.
File summaries
| File | Description |
|---|---|
| web/src/utils/determine-time-range.test.ts | Adds Jest unit tests to validate determineTimeRange UTC boundary calculations for Insights ranges/resolutions. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
2a02ec5 to
4266016
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The change is isolated to test coverage improvements and the new expectations align with the current determineTimeRange implementation.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
4266016 to
57f0872
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The change is isolated to new deterministic unit tests and aligns with the current determineTimeRange implementation and Jest setup.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Lite
What this PR does:
Adds comprehensive unit tests for the
determineTimeRangeutility function (web/src/utils/determine-time-range.test.ts).Why we need it:
determineTimeRangecalculates timestamp boundaries[from, to]for the Insights analytics page based on time ranges (LAST_1_WEEK,LAST_1_MONTH,LAST_3_MONTHS,LAST_6_MONTHS,LAST_1_YEAR,LAST_2_YEARS) across bothDAILYandMONTHLYresolutions. It previously lacked automated test coverage to verify UTC boundary calculations.Does this PR introduce a user-facing change?:
No.