Skip to content

Conversation

@gru-agent
Copy link
Contributor

@gru-agent gru-agent bot commented Mar 25, 2025

Trigger Info

Trigger Type Triggered By Source File Assignment
Auto Trigger TestGru projects/app/src/web/core/workflow/utils.ts Detail

Summary

This PR introduces unit tests for the transformPreviewHistories and addStatisticalDataToHistoryItem utility functions in the utils.ts file. The tests cover various scenarios to ensure the correctness of these functions, including handling different input configurations, edge cases, and nested data structures. Additionally, the isLLMNode function is now exported from utils.ts.

Key Changes:

  1. Unit Tests Added:

    • transformPreviewHistories:

      • Validates transformation logic with responseDetail set to true and false.
    • addStatisticalDataToHistoryItem:

      • Tests behavior for non-AI objects, pre-defined totalQuoteList, and undefined responseData.

      • Ensures correct statistical calculations for various input scenarios, including nested plugin and loop details.

  2. Export Update:

    • The isLLMNode function is now exported from utils.ts for external usage.

Test Coverage:

  • Handles empty arrays and undefined values gracefully.

  • Validates nested structures like pluginDetail and loopDetail.

  • Ensures accurate computation of llmModuleAccount, totalQuoteList, totalRunningTime, and historyPreviewLength.

This PR enhances the reliability of the utility functions and ensures their behavior is well-documented through comprehensive tests.

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% -> 100% 🔺
functions 0% -> 100% 🔺
statements 0% -> 100% 🔺
branches 0% -> 96% 🔺
source program

Test Statuses

Status Change
passed 0 -> 8 🔺
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

@github-actions
Copy link

github-actions bot commented Mar 25, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 59.92% 6032 / 10066
🔵 Statements 59.92% 6032 / 10066
🔵 Functions 19.56% 45 / 230
🔵 Branches 72.92% 202 / 277
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
projects/app/src/global/core/chat/utils.ts 100% 96% 100% 100%
Generated in workflow #220 for commit 6ff90f8 by the Vitest Coverage Report Action

@c121914yu
Copy link
Collaborator

c121914yu commented Mar 25, 2025

🤖 Generated by deploy action

📦 Preview Image: ghcr.io/labring/fastgpt-pr:6ff90f84610f80da955034d7c91a81253bd343ba

@c121914yu c121914yu merged commit 29a10c1 into main Mar 26, 2025
6 of 7 checks passed
@c121914yu c121914yu deleted the gru/projects-app-src-global-core-chat-utils-ts-1742936911557 branch March 27, 2025 09:19
FinleyGe pushed a commit to FinleyGe/FastGPT that referenced this pull request Mar 27, 2025
…abring#4328)

* Add unit tests for chat utility functions and enhance statistical data calculation in utils.ts.

* Update utils.ts

---------

Co-authored-by: gru-agent[bot] <185149714+gru-agent[bot]@users.noreply.github.com>
Co-authored-by: Archer <545436317@qq.com>
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