Skip to content

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Jul 10, 2025

Trigger Info

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

Summary

This PR introduces comprehensive unit tests for the marketing/utils module, ensuring robust validation of its functionality. The tests cover the following utility functions:

  1. inviterId:

    • Validates getInviterId, setInviterId, and removeInviterId operations.

    • Ensures empty values are not set.

  2. bdVId:

    • Tests getBdVId and setBdVId functionality.

    • Prevents setting empty values.

  3. msclkid:

    • Verifies getMsclkid and setMsclkid behavior.

    • Ensures empty values are not set.

  4. utmWorkflow:

    • Covers getUtmWorkflow, setUtmWorkflow, and removeUtmWorkflow.

    • Prevents setting empty values.

  5. utmParams:

    • Validates getUtmParams, setUtmParams, and removeUtmParams.

    • Handles invalid JSON gracefully.

    • Ensures empty or undefined values are not set.

  6. fastGPTSem:

    • Tests getFastGPTSem, setFastGPTSem, and removeFastGPTSem.

    • Handles invalid JSON inputs.

    • Prevents setting empty values.

  7. sourceDomain:

    • Validates getSourceDomain and setSourceDomain.

    • Ensures existing values are not overridden.

    • Uses document.referrer as a fallback when no value is provided.

Mock implementations for localStorage, sessionStorage, and document.referrer are used to simulate browser behavior, ensuring isolated and reliable testing. The tests also include edge cases, such as handling invalid JSON and preventing unnecessary storage operations for empty or undefined values.

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

Test Statuses

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

@gru-agent gru-agent bot mentioned this pull request Jul 10, 2025
Copy link

Preview sandbox Image:

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

Copy link

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 22.1% 12035 / 54434
🔵 Statements 22.1% 12035 / 54434
🔵 Functions 29.74% 326 / 1096
🔵 Branches 67.9% 874 / 1287
File CoverageNo changed files found.
Generated in workflow #1390 for commit d0786aa by the Vitest Coverage Report Action

Copy link

Preview mcp_server Image:

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

Copy link

Preview fastgpt Image:

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

@c121914yu c121914yu closed this Jul 10, 2025
@c121914yu c121914yu deleted the gru/projects-app-src-web-support-marketing-utils-ts-1752136234761 branch July 16, 2025 13:03
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