Skip to content

[jsweep] Clean update_pr_description_helpers.cjs#36575

Merged
pelikhan merged 1 commit into
mainfrom
signed/jsweep/update-pr-description-helpers-21c754ff1051df8b
Jun 3, 2026
Merged

[jsweep] Clean update_pr_description_helpers.cjs#36575
pelikhan merged 1 commit into
mainfrom
signed/jsweep/update-pr-description-helpers-21c754ff1051df8b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 3, 2026

Summary

Refactors updateBody in update_pr_description_helpers.cjs to eliminate duplicated island marker and content construction by hoisting shared variables above the if/else branches, and extends the test suite with coverage for the optional historyUrl parameter and workflowIdMarker inclusion/exclusion when includeFooter is false.


Changes

actions/setup/js/update_pr_description_helpers.cjs (modified)

  • Hoisted shared island-marker and content variables above the if/else branches in updateBody, removing duplication between both code paths.

actions/setup/js/update_pr_description_helpers.test.cjs (modified)

  • Added test cases for the optional historyUrl parameter.
  • Added test cases verifying workflowIdMarker is excluded when includeFooter is false.

Risk Assessment

Dimension Assessment
Breaking change No
Test coverage Extended
Scope Single helper + its tests
Risk Low — logic-preserving refactor with accompanying tests

Generated by PR Description Updater for issue #36575 · sonnet46 947.5K ·

- Deduplicate island content building in replace-island branch
- Add 4 new tests: historyUrl, workflowIdMarker with/without workflowId
- All 40 tests pass (was 36)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review June 3, 2026 05:51
Copilot AI review requested due to automatic review settings June 3, 2026 05:51
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Jun 3, 2026

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Jun 3, 2026

🧪 Test Quality Sentinel completed test quality analysis.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Jun 3, 2026

PR Code Quality Reviewer completed the code quality review.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Jun 3, 2026

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #36575 does not have the 'implementation' label (has_implementation_label=false) and has 0 new lines of code in business logic directories (default_business_additions=0, well below the 100-line threshold). requires_adr_by_default_volume=false.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors update_pr_description_helpers.cjs to reduce duplicated string construction in the replace-island path, and extends the unit tests to cover historyUrl propagation and includeFooter: false workflow-id marker behavior.

Changes:

  • Hoist startMarker, endMarker, and islandContent construction in updateBody()’s replace-island branch to eliminate duplicated code.
  • Add tests covering historyUrl being included in the generated footer output.
  • Add tests ensuring <!-- gh-aw-workflow-id: ... --> is emitted (or omitted) when includeFooter: false depending on whether workflowId is non-empty.
Show a summary per file
File Description
actions/setup/js/update_pr_description_helpers.cjs Deduplicates island marker/content construction for the replace-island operation.
actions/setup/js/update_pr_description_helpers.test.cjs Adds coverage for historyUrl and includeFooter: false workflow-id marker behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@github-actions github-actions Bot mentioned this pull request Jun 3, 2026
Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /zoom-out — approving with one minor observation on test precision.

📋 Key Themes & Highlights

Key Themes

  • Clean deduplication: Hoisting the three startMarker/endMarker/islandContent variables above the if/else is semantically equivalent and clearly correct — all variables are derived from stable locals (workflowId, contentWithCaution, etc.) that do not change between the two branches.
  • Good test additions: The four new tests cover previously untested paths (historyUrl propagation, workflowId marker presence/absence when includeFooter: false), which lock in the behaviour and validate the refactor is safe.

Positive Highlights

  • ✅ Refactor is a strict deduplication — no logic change
  • ✅ Net -5 lines in the implementation file
  • ✅ All CI checks pass (format, lint, typecheck, 40 tests)
  • ✅ One inline suggestion about test assertion specificity — non-blocking

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 1.1M

});
expect(result).toContain("New content");
// historyUrl should be included in the footer
expect(result).toContain("https://github.com/search?q=test");
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[/zoom-out] The historyUrl test verifies that the URL appears somewhere in the output, but does not assert it lands specifically inside the generated footer. If historyUrl were accidentally placed in the main content, the test would still pass.

💡 Suggestion

Consider asserting on the specific footer fragment that carries the URL:

expect(result).toContain(`[◷](https://github.com/search?q=test)`);
// or
expect(result).toMatch(/Generated by.*https:\/\/github\.com\/search/);

This guards against regressions where the URL is injected in the wrong location.

Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

✅ Clean deduplication — no blocking issues

The refactor correctly hoists the shared islandContent construction before the if (island.found) branch. Both the found and fallback paths used identical construction code before, so the hoist is semantically equivalent. New tests cover historyUrl, workflowIdMarker with and without a workflowId, which are the right things to assert on.

🔎 Code quality review by PR Code Quality Reviewer · sonnet46 87.1K

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Jun 3, 2026

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 75/100 — Acceptable

Analyzed 4 JavaScript test(s) in update_pr_description_helpers.test.cjs: 4 design tests (behavioral contracts), 0 implementation tests, 0 guideline violations. Score reduced by test inflation (58 lines added to test file vs. 4 lines added to production file).

📊 Metrics & Test Classification (4 tests analyzed)
Metric Value
New/modified tests analyzed 4
✅ Design tests (behavioral contracts) 4 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 2 (50%)
Duplicate test clusters 0
Test inflation detected ⚠️ Yes — 58 test lines vs. 4 production lines (14.5:1 ratio)
🚨 Coding-guideline violations 0

Test Classification Details

Test File Classification Issues Detected
should pass historyUrl to the footer when provided update_pr_description_helpers.test.cjs ✅ Design None
should work without historyUrl (optional parameter) update_pr_description_helpers.test.cjs ✅ Design Edge case: absent optional param
should include workflow ID marker when includeFooter is false and workflowId is provided update_pr_description_helpers.test.cjs ✅ Design None
should not include workflow ID marker when includeFooter is false and workflowId is empty update_pr_description_helpers.test.cjs ✅ Design Edge case: empty string input

Language Support

Tests analyzed:

  • 🟨 JavaScript (*.test.cjs): 4 tests (vitest)

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). All 4 new tests verify observable output behavior via expect(result).toContain / expect(result).not.toContain. The test inflation flag (14.5:1 ratio) is contextually expected — the production change was primarily a cleanup/refactor with net deletions, while the tests add new behavioral coverage for two previously untested parameters (historyUrl and the workflowId+includeFooter:false combination).

📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 1.7M ·

Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 75/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%). All 4 new tests verify observable behavioral contracts.

@pelikhan pelikhan merged commit 97aef66 into main Jun 3, 2026
49 of 53 checks passed
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.

2 participants