Skip to content

test: Add unit test for projects/app/src/global/core/chat/utils.ts #4889

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 May 25, 2025

Trigger Info

Trigger Type Triggered By Source Pull Request Assignment
PR Created c121914yu 4888 Detail

Summary

This PR introduces the following changes:

  1. New Utility Function: getFlatAppResponses

    • Added a utility function to flatten nested response structures (pluginDetail, toolDetail, loopDetail) into a single-level array.

    • This function ensures that deeply nested response objects are properly extracted and included in the final output.

  2. Unit Tests for getFlatAppResponses

    • Comprehensive test cases added to validate the behavior of getFlatAppResponses:

      • Handles empty input.

      • Processes single-level responses.

      • Flattens nested structures (pluginDetail, toolDetail, loopDetail).

      • Handles multiple levels of nesting.

  3. Refactoring

    • Updated the imports in utils.test.ts to include the new utility function.

These changes enhance the ability to process and test complex nested response structures, improving code reliability and maintainability.

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 100% -> 100%
functions 100% -> 100%
statements 100% -> 100%
branches 95.65% -> 95.65%
source program

Test Statuses

Status Change
passed 8 -> 14 🔺
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: ghcr.io/labring/fastgpt-pr:fatsgpt_mcp_server_3338be6650f1a180fa878a449f894ce3cd0f7009

Copy link

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 22.06% 11464 / 51946
🔵 Statements 22.06% 11464 / 51946
🔵 Functions 28.99% 303 / 1045
🔵 Branches 65.79% 779 / 1184
File CoverageNo changed files found.
Generated in workflow #955 for commit 3338be6 by the Vitest Coverage Report Action

Copy link

Preview sandbox Image: ghcr.io/labring/fastgpt-pr:fatsgpt_sandbox_3338be6650f1a180fa878a449f894ce3cd0f7009

Copy link

Preview fastgpt Image: ghcr.io/labring/fastgpt-pr:fatsgpt_3338be6650f1a180fa878a449f894ce3cd0f7009

@c121914yu c121914yu closed this May 28, 2025
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