Skip to content

✅ test: add unit test for src/server/translation.ts #7268

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

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

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Apr 2, 2025

Trigger Info

Trigger Type Triggered By Source Pull Request Assignment
PR Created arvinxx 7265 Detail

Summary

This PR refactors the translation.test.ts file to simplify and improve the testing process for translations. Key changes include:

  • Removed Node.js fs and path mocks: The tests no longer rely on file system operations or path manipulation. Instead, translation files are directly mocked using vi.mock.

  • Added direct mocks for translation files: Mocked translation files (en-US, zh-CN, and default translations) are now imported directly, improving clarity and reducing complexity.

  • Updated fallback logic tests: Tests for fallback behavior now focus on mocked imports rather than file existence checks.

  • Improved error handling tests: Tests for handling import errors were added to ensure graceful fallback when an invalid locale is provided.

  • Simplified dev mode behavior: Tests now verify that zh-CN translations are used in development mode for the zh-CN locale.

These changes streamline the testing process, remove unnecessary dependencies, and improve 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 79.31% -> 100% 🔺
functions 0.88% -> 1.1% 🔺
statements 79.31% -> 100% 🔺
branches 75% -> 93.33% 🔺
source program

Test Statuses

Status Change
passed 4 -> 7 🔺
failed 4 -> 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

vercel bot commented Apr 2, 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) Apr 2, 2025 4:57am
lobe-chat-desktop ⬜️ Ignored (Inspect) Apr 2, 2025 4:57am
lobe-chat-preview ⬜️ Ignored (Inspect) Visit Preview Apr 2, 2025 4:57am

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 2, 2025
@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
Contributor Author

gru-agent bot commented Apr 2, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

1 similar comment
Copy link
Contributor Author

gru-agent bot commented Apr 2, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

@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 Apr 2, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

1 similar comment
Copy link
Contributor Author

gru-agent bot commented Apr 2, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

@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 Apr 2, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

1 similar comment
Copy link
Contributor Author

gru-agent bot commented Apr 2, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

@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 Apr 3, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

1 similar comment
Copy link
Contributor Author

gru-agent bot commented Apr 3, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

@lobehubbot
Copy link
Member

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


🔄 Rebasing Testgru per ...

1 similar comment
@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 Apr 3, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

1 similar comment
Copy link
Contributor Author

gru-agent bot commented Apr 3, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

@lobehubbot
Copy link
Member

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


🔄 Rebasing Testgru per ...

1 similar comment
@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 Apr 3, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

@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 Apr 3, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

Base automatically changed from refactor/improve-code to main April 3, 2025 02:52
Copy link
Contributor Author

gru-agent bot commented Apr 3, 2025

❌ Rebase test pr failed: Error: Pull request #7268 has conflicts. you can use @gru-agent redo to redo.

@lobehubbot
Copy link
Member

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


🔄 Rebasing Testgru per ...

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

Successfully merging this pull request may close these issues.

2 participants