[jsweep] Clean remove_trigger_label.cjs#29251
Conversation
- Move require('./error_helpers.cjs') from inside main() to top-level imports
- Add comprehensive test suite (14 tests) covering all code paths:
- Missing/invalid GH_AW_LABEL_NAMES config
- workflow_dispatch skip
- No label in payload
- Label not in configured list
- issues, pull_request, discussion label removal
- 404 non-fatal error handling
- Non-404 API error warnings
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Cleans up the remove_trigger_label.cjs GitHub Action script and adds a comprehensive Vitest suite to validate behavior across supported events and error conditions.
Changes:
- Moved
getErrorMessageimport to top-level inremove_trigger_label.cjsfor consistency. - Added
remove_trigger_label.test.cjswith coverage for config parsing, event-specific behavior, skip paths, and API error handling.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/remove_trigger_label.cjs | Hoists error_helpers.cjs import to module scope to align with codebase patterns. |
| actions/setup/js/remove_trigger_label.test.cjs | Adds a full test suite exercising label removal behavior across events and error cases. |
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
| @@ -0,0 +1,220 @@ | |||
| // @ts-check | |||
| import { describe, it, expect, beforeEach, vi } from "vitest"; | |||
There was a problem hiding this comment.
afterEach is used later in this test file but isn’t imported from vitest. The rest of the test suite consistently imports the hooks it uses (e.g. actions/setup/js/action_conclusion_otlp.test.cjs:2). Please add afterEach to the Vitest import list for consistency and to avoid relying on global hook injection.
| import { describe, it, expect, beforeEach, vi } from "vitest"; | |
| import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; |
|
@copilot review all comments |
🧪 Test Quality Sentinel ReportTest Quality Score: 80/100✅ Excellent test quality
Test Classification DetailsView all 14 test classifications
Mocking Strategy AssessmentAll mocked targets are GitHub Actions runtime globals ( Test Inflation NoteThe raw inflation ratio (220 test lines : 1 production line added) exceeds the 2:1 threshold, triggering the standard 10-point penalty. However, this is context-appropriate: the test file is newly added to cover an already-existing production file ( Language SupportTests analyzed:
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:
|
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/b453b824-12cd-44a5-a0de-5a6946b25d66 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Summary
Cleans
remove_trigger_label.cjsand adds a comprehensive test suite.Context
Execution context: github-script (uses
core,github,contextglobals)Changes
Code cleanup:
require('./error_helpers.cjs')from insidemain()to top-level imports — consistent with all other files in the codebaseTests added (14 tests):
New file
remove_trigger_label.test.cjscovers:GH_AW_LABEL_NAMESenv var (3 cases)workflow_dispatchevent → skip with empty outputissuesevent: happy path + missing issue numberpull_requestevent: happy path + missing PR numberdiscussionevent: happy path via GraphQL + missing node IDsValidation ✅
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓