Conversation
…ltered labels - Add test for staged mode preview without calling API - Add test that staged calls count toward processedCount limit - Add test for blocked pattern filtering (removes matching labels) - Add test for when all labels are filtered out by allowed list (succeeds with empty labelsAdded) Total: 25 → 29 tests for add_labels handler Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Improves confidence in the add_labels.cjs handler by adding tests for previously untested execution paths (staged mode behavior and label filtering scenarios).
Changes:
- Added tests verifying staged mode returns preview info and does not call the GitHub API.
- Added tests ensuring staged mode still counts toward the
maxprocessed limit. - Added tests covering blocked-pattern filtering and the “no valid labels” success path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ); | ||
|
|
||
| expect(result.success).toBe(true); | ||
| expect(result.labelsAdded).toEqual(["bug", "enhancement"]); |
There was a problem hiding this comment.
This test assumes the GitHub API is called exactly once, but it never asserts the call count. Adding an explicit assertion (e.g., that addLabelsCalls has length 1) would prevent the test from passing if the handler accidentally performs multiple addLabels calls.
| expect(result.labelsAdded).toEqual(["bug", "enhancement"]); | |
| expect(result.labelsAdded).toEqual(["bug", "enhancement"]); | |
| expect(addLabelsCalls).toHaveLength(1); |
| expect(result.success).toBe(true); | ||
| expect(result.labelsAdded).toEqual([]); | ||
| expect(result.message).toContain("No valid labels"); | ||
| }); |
There was a problem hiding this comment.
This test doesn’t verify that the handler avoids calling github.rest.issues.addLabels when no valid labels remain after filtering. Consider stubbing addLabels (as in other tests) and asserting it was not called, so the behavior remains protected against regressions.
…h inputs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/3ead85d8-c115-425f-88b4-18f27175e720
Fixed in fd58d1d. The Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…se for item_number input Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/531637cf-d8c8-415b-8b02-277e0e917422
Fixed in 62acaad. The issue was that Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
Analyzed and improved
add_labels.cjs(github-script context handler for adding labels to issues/PRs).Analysis
The
add_labels.cjsfile is already clean and modern —@ts-checkenabled, optional chaining, proper JSDoc types, no unnecessary try/catch. TheHANDLER_TYPEconstant, while seemingly unused in logic, is intentionally required by thesafe_outputs_type_validation.test.cjstype-marker test and must be retained.The main opportunity was test coverage gaps for three untested code paths.
Changes
add_labels.test.cjs— Added 4 new tests (25 → 29 tests):should preview labels in staged mode without calling API{ success: true, staged: true, previewInfo }without making GitHub API callshould count staged calls toward processedCountprocessedCount, enforcing the max limitshould filter out labels matching blocked patternsblocked: ["internal-*", "~*"]correctly removes matching labels while keeping valid onesshould succeed with empty labelsAdded when all labels filtered by allowed list{ success: true, labelsAdded: [], message: "No valid labels found" }Context
core,github,contextglobals)validateLabels,isStagedMode,resolveAndValidateRepo,tryEnforceArrayLimitValidation ✅
All checks passed:
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npx vitest run add_labels.test.cjs safe_outputs_type_validation.test.cjs— 42 tests passed ✓Warning
**⚠️ Firewall blocked 2 domains**
The following domains were blocked by the firewall during workflow execution:
invalid.example.invalidproxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.