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/server/responsive.ts #5911

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

gru-agent[bot]
Copy link
Contributor

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

Trigger Info

Trigger Type Triggered By Source Pull Request Assignment
Auto Rebase arvinxx 5910 Detail

Summary

This PR introduces unit tests for the isMobileDevice and gerServerDeviceInfo functions in the responsive.ts module. Key changes include:

  • Unit Tests:

    • Added tests for isMobileDevice to verify:

      • Correct detection of mobile devices based on the user-agent header.

      • Proper error handling when the function is called outside a server environment.

    • Added tests for gerServerDeviceInfo to verify:

      • Accurate extraction of device information (browser, OS, and mobile status).

      • Proper error handling when the function is called outside a server environment.

  • Mocking:

    • Mocked the next/headers module to simulate server-side behavior and provide a custom user-agent header for testing.
  • Export Fix:

    • Ensured isMobileDevice is explicitly exported from responsive.ts.

These changes improve test coverage and ensure the reliability of server-side device detection 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 8, 2025 22:55
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 8, 2025
Copy link

vercel bot commented Feb 8, 2025

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

Name Status Preview Comments Updated (UTC)
lobe-chat-database ✅ Ready (Inspect) Visit Preview Feb 9, 2025 5:56am
lobe-chat-preview 🛑 Canceled (Inspect) Feb 9, 2025 5:56am

@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 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.13%. Comparing base (cbc5967) to head (4890ac0).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #5911     +/-   ##
=========================================
  Coverage   92.13%   92.13%             
=========================================
  Files         650      651      +1     
  Lines       59053    59098     +45     
  Branches     2925     4094   +1169     
=========================================
+ Hits        54406    54451     +45     
  Misses       4647     4647             
Flag Coverage Δ
app 92.13% <100.00%> (+<0.01%) ⬆️
server 98.01% <ø> (ø)

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.

Copy link
Contributor Author

gru-agent bot commented Feb 9, 2025

✅ Rebase TestGru PR Success

Type Change
Base Sha e5a1f47...a63a385
Head Sha 6abb989...b982300

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


🔄 Rebasing Testgru per ...

@gru-agent gru-agent bot force-pushed the testgru-src-utils-server-responsive.ts-1739055310509 branch from 6abb989 to b982300 Compare February 9, 2025 02:55
@vercel vercel bot temporarily deployed to Preview – lobe-chat-preview February 9, 2025 03:06 Inactive
Copy link
Contributor Author

gru-agent bot commented Feb 9, 2025

✅ Rebase TestGru PR Success

Type Change
Base Sha a63a385...9fa0f25
Head Sha b982300...c95b203

@gru-agent gru-agent bot force-pushed the testgru-src-utils-server-responsive.ts-1739055310509 branch from b982300 to c95b203 Compare February 9, 2025 03:13
@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


🔄 Rebasing Testgru per ...

@vercel vercel bot temporarily deployed to Preview – lobe-chat-preview February 9, 2025 03:16 Inactive
Copy link
Contributor Author

gru-agent bot commented Feb 9, 2025

✅ Rebase TestGru PR Success

Type Change
Base Sha 9fa0f25...dd3ac56
Head Sha c95b203...f32b7b8

@gru-agent gru-agent bot force-pushed the testgru-src-utils-server-responsive.ts-1739055310509 branch from c95b203 to f32b7b8 Compare February 9, 2025 03:17
Copy link

vercel bot commented Feb 9, 2025

Deployment failed with the following error:

Resource is limited - try again in 25 minutes (more than 100, code: "api-deployments-free-per-day").

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


🔄 Rebasing Testgru per ...

Copy link
Contributor Author

gru-agent bot commented Feb 9, 2025

✅ Rebase TestGru PR Success

Type Change
Base Sha dd3ac56...c71147f
Head Sha f32b7b8...4890ac0

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


🔄 Rebasing Testgru per ...

@gru-agent gru-agent bot force-pushed the testgru-src-utils-server-responsive.ts-1739055310509 branch from f32b7b8 to 4890ac0 Compare February 9, 2025 03:41
Copy link

vercel bot commented Feb 9, 2025

Deployment failed with the following error:

Resource is limited - try again in 38 seconds (more than 100, code: "api-deployments-free-per-day").

Base automatically changed from perf/rewrite-local to main February 9, 2025 05:40
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 9, 2025
@vercel vercel bot temporarily deployed to Preview – lobe-chat-preview February 9, 2025 05:56 Inactive
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