[jsweep] Clean dispatch_repository.cjs#28397
Conversation
- Use error_codes.cjs constants (SAFE_OUTPUT_E001, SAFE_OUTPUT_E099) instead of raw string literals - Replace manual for-of loop with spread operator when building clientPayload from message.inputs - Add comprehensive test file with 18 tests covering all handler paths Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🧪 Test Quality Sentinel ReportTest Quality Score: 73/100
Test Classification DetailsView all 18 test classifications
Score Breakdown
ObservationsThe tests in this PR are high quality overall. All 18 tests assert on observable return values ( The 4 happy-path-only tests ( Language Support
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: §24928655226
|
There was a problem hiding this comment.
Pull request overview
Cleans up the dispatch_repository safe-output handler by standardizing selected error code prefixes and simplifying how message.inputs is merged into the dispatch client_payload, and adds a new test suite for the handler.
Changes:
- Use
error_codes.cjsconstants forE001/E099error prefixes indispatch_repository.cjs. - Replace the manual
Object.entriesloop with object spread when mergingmessage.inputsintoclient_payload. - Add
dispatch_repository.test.cjswith coverage for validation, dispatch behavior, staged mode, and max enforcement.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/dispatch_repository.cjs | Standardizes E001/E099 prefix usage and simplifies client_payload construction. |
| actions/setup/js/dispatch_repository.test.cjs | Adds a dedicated Vitest suite covering common error paths and successful dispatch 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: 2
|
|
||
| const { main } = require("./dispatch_repository.cjs"); | ||
|
|
| // Stub handler_auth to return the mock github client | ||
| const handlerAuth = require("./handler_auth.cjs"); | ||
| vi.spyOn(handlerAuth, "createAuthenticatedGitHubClient").mockResolvedValue(mockGithub); | ||
| }); |
|
@copilot review all comments |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/b554d0eb-cf0b-441e-bc19-9b58bae2cee3 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed both reviewer comments in commit
|
Summary
Cleaned
actions/setup/js/dispatch_repository.cjsas part of the daily jsweep unbloat process.Context
File type: github-script context (uses
core,context,githubglobals)Changes Made
dispatch_repository.cjserror_codes.cjsconstants instead of raw string literals ("E001","E099") — importsSAFE_OUTPUT_E001andSAFE_OUTPUT_E099for consistent, centralized error codesfor-ofloop with spread operator when mergingmessage.inputsintoclientPayload, making the intent clearer and more concise:dispatch_repository.test.cjs(new file)Added 18 comprehensive tests covering:
tool_name, unknown tool, no target repository, invalid repo slug, missingevent_typemessage.inputspropagated toclient_payloadaw_contextinjected intoclient_payloadmessage.repositoryoverride overtoolConfig.repositoryallowed_repositoriesentryValidation ✅
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npx vitest run dispatch_repository.test.cjs) ✓