Skip to content
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

✅ test: add unit test for src/utils/fetch/fetchSSE.ts #6347

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Feb 20, 2025

Trigger Info

Trigger Type Triggered By Source File Assignment
Push arvinxx src/utils/fetch/fetchSSE.ts Detail

Summary

This PR introduces unit tests for the fetchSSE utility function, ensuring its behavior is validated across various scenarios. The tests cover the following cases:

  • Successful Text Streaming: Verifies that text messages are correctly handled and concatenated, and the onFinish callback is invoked with the expected result.

  • Tool Calls Streaming: Ensures that tool call events are processed and passed to the onMessageHandle callback.

  • Citations Streaming: Confirms that citation events are handled and passed correctly.

  • Reasoning Streaming: Tests the handling of reasoning events and their delivery to the onMessageHandle callback.

  • Abort Handling: Validates that the onAbort callback is triggered when an abort event occurs.

  • Error Handling: Ensures that errors are captured and passed to the onErrorHandle callback.

The fetchEventSource function is mocked to simulate different streaming scenarios, and all relevant callbacks are tested for proper invocation with expected arguments. This ensures robust coverage of the fetchSSE functionality.

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 requested a review from arvinxx February 20, 2025 05:01
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 20, 2025
Copy link

vercel bot commented Feb 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
lobe-chat-database ⬜️ Ignored (Inspect) Feb 20, 2025 5:11am
lobe-chat-desktop ⬜️ Ignored (Inspect) Feb 20, 2025 5:11am
lobe-chat-preview ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 5:11am

@lobehubbot
Copy link
Member

👍 @gru-agent[bot]

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.42%. Comparing base (cab591d) to head (b58ac19).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6347      +/-   ##
==========================================
+ Coverage   91.41%   91.42%   +0.01%     
==========================================
  Files         688      688              
  Lines       63021    63021              
  Branches     4372     3141    -1231     
==========================================
+ Hits        57608    57615       +7     
+ Misses       5413     5406       -7     
Flag Coverage Δ
app 91.42% <ø> (+0.01%) ⬆️
server 97.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants