Skip to content

fix: Fill unit-test gaps for MCP task functionality#688

Merged
jirispilka merged 3 commits intomasterfrom
claude/explore-task-test-gaps-NdtAc
Apr 17, 2026
Merged

fix: Fill unit-test gaps for MCP task functionality#688
jirispilka merged 3 commits intomasterfrom
claude/explore-task-test-gaps-NdtAc

Conversation

@jirispilka
Copy link
Copy Markdown
Collaborator

@jirispilka jirispilka commented Apr 16, 2026

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.

claude and others added 2 commits April 16, 2026 22:03
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>
@github-actions github-actions Bot added t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics. labels Apr 16, 2026
@jirispilka jirispilka changed the title test: Fill unit-test gaps for MCP task functionality fix: Fill unit-test gaps for MCP task functionality Apr 16, 2026
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/unit/utils.progress.test.ts
@jirispilka jirispilka added the debt Code quality improvement or decrease of technical debt. label Apr 16, 2026
@jirispilka
Copy link
Copy Markdown
Collaborator Author

@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>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

@copilot please fix all the reviewer commnets

Done in 734d36e.

I fixed the reviewer-reported progressToken=0 handling by replacing falsy checks with nullish checks in progress tracking, updated the actor-mcp notification-handler gate, and added a unit test that covers progressToken = 0 end-to-end in createProgressTracker/updateProgress.

@jirispilka jirispilka merged commit 3899fa7 into master Apr 17, 2026
12 checks passed
@jirispilka jirispilka deleted the claude/explore-task-test-gaps-NdtAc branch April 17, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt Code quality improvement or decrease of technical debt. t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants