Skip to content

Add unit tests for determineTimeRange - #7322

Open
vikash7485 wants to merge 1 commit into
pipe-cd:masterfrom
vikash7485:test/add-coverage-for-determine-time-range
Open

Add unit tests for determineTimeRange#7322
vikash7485 wants to merge 1 commit into
pipe-cd:masterfrom
vikash7485:test/add-coverage-for-determine-time-range

Conversation

@vikash7485

Copy link
Copy Markdown
Contributor

What this PR does:

Adds comprehensive unit tests for the determineTimeRange utility function (web/src/utils/determine-time-range.test.ts).

Why we need it:

determineTimeRange calculates 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 both DAILY and MONTHLY resolutions. It previously lacked automated test coverage to verify UTC boundary calculations.

Does this PR introduce a user-facing change?:

No.

  • How are users affected by this change: N/A (Internal test coverage improvement)
  • Is this breaking change: No.
  • How to migrate (if breaking change): N/A.

Copilot AI lite review requested due to automatic review settings September 5, 2026 10:19
@vikash7485
vikash7485 requested review from a team as code owners September 5, 2026 10:19
@netlify

netlify Bot commented Sep 5, 2026

Copy link
Copy Markdown

Deploy Preview for pipecd-site canceled.

Name Link
🔨 Latest commit 57f0872
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6a9bf6c7e6f7c00008254287

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.ts with 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.

Comment thread web/src/utils/determine-time-range.test.ts
@vikash7485
vikash7485 force-pushed the test/add-coverage-for-determine-time-range branch from 2a02ec5 to 4266016 Compare September 5, 2026 10:25
@vikash7485
vikash7485 requested a lite review from Copilot September 5, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

Comment thread web/src/utils/determine-time-range.test.ts Outdated
Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
@vikash7485
vikash7485 force-pushed the test/add-coverage-for-determine-time-range branch from 4266016 to 57f0872 Compare September 5, 2026 11:02
@vikash7485
vikash7485 requested a lite review from Copilot September 5, 2026 11:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants