fix: Fill unit-test gaps for MCP task functionality#688
Conversation
Task behavior is covered end-to-end at the integration level but the small pure helpers were uncovered at the unit level. Adds: - isTaskCancelled (src/mcp/utils.ts): return values for each task status and not-found case, plus that taskId/mcpSessionId propagate to getTask. - ProgressTracker: related-task _meta is included when taskId is supplied and absent otherwise. - createProgressTracker factory: null/instance branches for each combination of progressToken, sendNotification, and onStatusMessage. - taskSupport contract across tool categories: only default-mode call-actor declares execution.taskSupport, value is in ALLOWED_TASK_TOOL_EXECUTION_MODES, and no openai-mode tool declares it. https://claude.ai/code/session_01SBaWhEW1vE35bTTivv1JNs
…Tracker tests Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
LGTM — test-only additions plus a trivial string-literal-to-constant refactor in progress.ts.
Extended reasoning...
Overview
This PR adds unit test coverage for three previously-untested helpers (isTaskCancelled, ProgressTracker._meta path, createProgressTracker) and a taskSupport structural contract test. The only production code change is replacing the hardcoded string 'io.modelcontextprotocol/related-task' with the new RELATED_TASK_META_KEY constant — a mechanical, semantics-preserving refactor.
Security risks
None. No auth, crypto, or permission-sensitive code is touched. The new constant is a string key used in MCP notification metadata.
Level of scrutiny
Low. The diff is almost entirely test code. The single non-test change is a constant extraction that makes the codebase more maintainable and keeps the key in sync when the SDK eventually exports it.
Other factors
The reported bug (progressToken=0 falsy coercion) is pre-existing and explicitly flagged as out-of-scope by the bug tracker. It doesn't affect the correctness of this PR. All 492 unit tests pass per the PR description, and the new tests correctly exercise the branches they target.
|
@copilot please fix all the reviewer commnets |
Agent-Logs-Url: https://github.com/apify/apify-mcp-server/sessions/aed4b4c5-420c-469d-a96d-0bf1cf8915b1 Co-authored-by: jirispilka <19406805+jirispilka@users.noreply.github.com>
Done in I fixed the reviewer-reported |
Fills unit-test gaps for MCP task functionality. Task lifecycle is covered end-to-end in
tests/integration/suite.ts, but the pure helpers underneath were uncovered.Out of scope:
executeToolAndUpdateTask(covered by #680 + integration), polling, runtime task-param rejection.