Skip to content

test: Add unit test for projects/app/src/service/support/mcp/utils.ts #5430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Aug 11, 2025

Trigger Info

Trigger Type Triggered By Source Pull Request Assignment
PR Created ctrlz526 5427 Detail

Summary

This PR introduces the following changes:

  1. Dependency Updates:

    • Updated @fastgpt-sdk/plugin from 0.1.7 to 0.1.8.

    • Added @babel/[email protected] as a dependency in the next-i18next package configuration.

  2. Testing Enhancements:

    • Added a new test file utils.test.ts under test/cases/service/support/mcp/ to cover utility functions in the MCP service.

    • Implemented unit tests for the following utility functions:

      • pluginNodes2InputSchema: Converts plugin nodes to input schema.

      • workflow2InputSchema: Creates input schema for workflows.

      • getMcpServerTools: Retrieves MCP server tools based on the provided key.

      • callMcpServerTool: Executes an MCP server tool and validates the response.

  3. Mocking Improvements:

    • Mocked various modules and functions to isolate and test the utility functions effectively, including:

      • MongoMcpKey

      • MongoApp

      • authAppByTmbId

      • getAppLatestVersion

      • getUserChatInfoAndAuthTeamPoints

      • dispatchWorkFlow

      • saveChat

      • createChatUsage

These changes enhance the robustness of the MCP service utilities and ensure better test coverage for critical functionalities.

Coverage

The change in coverage value, such as: 0% -> 50%, indicates that the coverage was 0% before writing the tests and 50% after writing them.

https://web.dev/articles/ta-code-coverage

Type Change
lines 0% -> 87% 🔺
functions 0% -> 100% 🔺
statements 0% -> 87% 🔺
branches 0% -> 51.28% 🔺
source program

Test Statuses

Status Change
passed 0 -> 4 🔺
failed 0 -> 0
skipped 0 -> 0
source program

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

Tip

You can @gru-agent rebase to rebase the PR.

Tip

You can @gru-agent redo to reset or rebase before redoing the PR.

Tip

To modify the test code yourself, click here Edit Test Code

Copy link

Preview mcp_server Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_mcp_server_a8dd4505e3b5053bf1fd90dee9004d90c23e1df3

Copy link

Preview sandbox Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_sandbox_a8dd4505e3b5053bf1fd90dee9004d90c23e1df3

@c121914yu c121914yu closed this Aug 12, 2025
@c121914yu c121914yu deleted the gru/projects-app-src-service-support-mcp-utils-ts-1754901213730 branch August 12, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant