Conversation
- Extract resolveRestEndpoint() helper: maps REST events to API endpoints, returns null for GraphQL events (no ambiguous undefined sentinel) - Extract handleGraphQLOrUnknownEvent() helper: handles discussion/ discussion_comment GraphQL paths and unsupported event fallback - Replace `const owner = …; const repo = …` with destructuring - Export both new helpers for direct unit testing - Add 14 new tests covering resolveRestEndpoint and handleGraphQLOrUnknownEvent (57 total, up from 43) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/q update selection strategy using some deterministic query to find outdated files that need cleanup. |
|
🎩 Mission equipment ready! Q has optimized your workflow. Use wisely, 007! 🔫 |
There was a problem hiding this comment.
Pull request overview
Refactors actions/setup/js/add_reaction.cjs by extracting REST endpoint resolution and GraphQL/unsupported-event handling into exported helpers, and expands unit test coverage for the new helper functions.
Changes:
- Extracts
resolveRestEndpoint()andhandleGraphQLOrUnknownEvent()to simplifymain()and enable direct unit testing. - Updates control flow to use the new helpers (REST vs GraphQL paths).
- Adds new direct test suites for both helpers (increasing test count).
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/add_reaction.cjs | Refactors event-to-endpoint logic into helpers and exports them. |
| actions/setup/js/add_reaction.test.cjs | Adds direct unit tests for the newly exported helper functions. |
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: 1
| // GraphQL paths (discussion, discussion_comment) and error paths are handled inside | ||
| await handleGraphQLOrUnknownEvent(eventName, owner, repo, reaction); |
🧪 Test Quality Sentinel ReportTest Quality Score: 77/100
Test Classification DetailsView all 14 test classifications
Flagged Tests — Requires ReviewNo tests are flagged for low behavioral value. The following is a minor improvement suggestion for the 6 happy-path endpoint tests that do not include an error sub-assertion: i️ Happy-path endpoint tests (4 tests: issues, issue_comment, pull_request, pull_request_review_comment)Classification: Design test — no action required Language SupportTests analyzed:
Test Inflation Note
The ratio slightly exceeds the 2:1 threshold. However, the new tests cover two previously untested exported helpers ( Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §25620805627
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 77/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%). All 14 new tests verify behavioral contracts across REST endpoint URL generation, error handling via setFailed, and GraphQL output assertions.
There was a problem hiding this comment.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · ● 2.9M
|
@copilot review all comments |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed in 93f176f: the jsweep fallback selection guidance now uses a deterministic
Addressed in 93f176f: I fixed the |
Summary
Cleaned
actions/setup/js/add_reaction.cjsand followed up on review feedback with a small regression fix in the extracted control flow, plus a jsweep workflow update to use a deterministic git-based query when selecting outdated files for future cleanup runs.Context
Execution context: github-script (uses
core,github,contextglobals)Changes
Refactoring
resolveRestEndpoint(): replaces the inlineswitchthat setlet reactionEndpoint: string | undefined. The helper returns astring | null—nullfor GraphQL/unsupported events — eliminating the need for the undefined sentinel and the dead-code guardif (!reactionEndpoint) return.handleGraphQLOrUnknownEvent(): consolidates thediscussion,discussion_comment, anddefaultbranches from the original switch into a focused async helper, keepingmain()lean.const { owner, repo } = context.repoinstead of two separate assignments.Follow-up fixes
main()now returns afterresolveRestEndpoint()validation failures for REST-backed events instead of falling through to the unsupported-event handler..github/workflows/jsweep.mdnow specifies a deterministic fallback query usinggit log -1 --format='%ct' -- <file>over candidates sorted by path, instead of filesystem modification timestamps.Test Improvements
resolveRestEndpoint (direct)suite: 9 tests covering each event type, missing-payload cases, and non-REST events returning null cleanly.handleGraphQLOrUnknownEvent (direct)suite: 5 tests covering discussion, discussion_comment, missing payloads, and unsupported event fallback.pkg/workflow/jsweep_workflow_test.gofor the deterministic fallback selection instructions.Validation ✅
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npx vitest run add_reaction.test.cjs— 57/57 passed ✓go test ./pkg/workflow -run TestJSweepWorkflow✓> Generated by jsweep - JavaScript Unbloater · ● 21.2M · ◷
> - [x] expires on May 12, 2026, 5:03 AM UTC