Skip to content

Add unit tests for findDefaultActiveStageInDeployment - #7321

Open
vikash7485 wants to merge 1 commit into
pipe-cd:masterfrom
vikash7485:test/add-coverage-for-find-default-active-stage
Open

Add unit tests for findDefaultActiveStageInDeployment#7321
vikash7485 wants to merge 1 commit into
pipe-cd:masterfrom
vikash7485:test/add-coverage-for-find-default-active-stage

Conversation

@vikash7485

Copy link
Copy Markdown
Contributor

What this PR does:

Adds comprehensive unit tests for the findDefaultActiveStageInDeployment utility function (web/src/utils/find-default-active-stage-in-deployment.test.ts).

Why we need it:

findDefaultActiveStageInDeployment determines the active stage to display and expand by default in the deployment detail view across both Piped v0 (using stage.visible and status filtering) and Piped v1 (filtering not-started stages and prioritizing running stages). This critical selection logic previously lacked dedicated automated test coverage.

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 07:41
@vikash7485
vikash7485 requested review from a team as code owners September 5, 2026 07:41
@netlify

netlify Bot commented Sep 5, 2026

Copy link
Copy Markdown

Deploy Preview for pipecd-site canceled.

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

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 test suite misses the “no eligible stages” case where the implementation can return undefined despite a Stage | null return type, so the contract should be clarified and covered with a regression test (and corresponding implementation/type update).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a dedicated unit test suite for findDefaultActiveStageInDeployment, the helper used by the deployment detail page to choose which pipeline stage should be expanded/selected by default for both Piped v0 and v1 deployments.

Changes:

  • Introduces new unit tests covering Piped v0 vs v1 behavior (visibility handling and not-started filtering).
  • Adds assertions for prioritizing STAGE_RUNNING over “latest eligible stage”.
File summaries
File Description
web/src/utils/find-default-active-stage-in-deployment.test.ts New unit tests for default-active-stage selection logic across Piped v0/v1 scenarios
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/find-default-active-stage-in-deployment.test.ts
…ensure null return when empty

Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
@vikash7485
vikash7485 force-pushed the test/add-coverage-for-find-default-active-stage branch from 6fca2a9 to daa92ea Compare September 5, 2026 07:47
@vikash7485
vikash7485 requested a lite review from Copilot September 5, 2026 07:47

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

Changes are low-risk (tests + a small null-safety fix) and the new tests directly validate the intended selection logic for both Piped versions.

Review details
  • Files reviewed: 2/2 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