Add unit tests for findDefaultActiveStageInDeployment - #7321
Conversation
✅ Deploy Preview for pipecd-site canceled.
|
There was a problem hiding this comment.
🟡 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_RUNNINGover “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.
…ensure null return when empty Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
6fca2a9 to
daa92ea
Compare
There was a problem hiding this comment.
🟢 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
What this PR does:
Adds comprehensive unit tests for the
findDefaultActiveStageInDeploymentutility function (web/src/utils/find-default-active-stage-in-deployment.test.ts).Why we need it:
findDefaultActiveStageInDeploymentdetermines the active stage to display and expand by default in the deployment detail view across both Piped v0 (usingstage.visibleand 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.