test: unify i18next mocks into centralized helpers#30376
test: unify i18next mocks into centralized helpers#30376asukaminato0721 merged 5 commits intomainfrom
Conversation
Consolidate scattered i18next mock implementations across test files into a single source of truth. This reduces duplication and ensures consistent mock behavior. - Create test/i18n-mock.ts with reusable factory functions - Update vitest.setup.ts to use the centralized helpers - Remove redundant mock definitions from 8 test files - Update testing.md documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @hyoban, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the i18next mocking strategy within the test suite. By centralizing Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request does a great job of centralizing the i18next mock logic into a reusable helper file, test/i18n-mock.ts. This significantly reduces code duplication across numerous test files and improves maintainability. The changes in the test files to adopt the new helper are clean, and the documentation update in testing.md is clear and helpful. I've left one comment on the new i18n-mock.ts file to suggest improvements that would make the mock more robust by handling a couple of edge cases (returnObjects option and array-based namespaces) that were either supported in the previous implementation or are part of the i18next API. Overall, this is a solid and valuable refactoring.
There was a problem hiding this comment.
Pull request overview
This PR consolidates scattered i18next mock implementations into a centralized test/i18n-mock.ts module with reusable factory functions. The changes reduce duplication across test files and provide a single source of truth for i18n mocking.
Key changes:
- Created
test/i18n-mock.tswithcreateTFunction,createUseTranslationMock,createTransMock, andcreateReactI18nextMockhelper functions - Updated
vitest.setup.tsto use the new centralized mock - Removed redundant i18n mock definitions from 15+ test files across plugins, datasets, billing, and base components
- Updated
testing.mddocumentation with usage examples
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
web/test/i18n-mock.ts |
New centralized mock factory functions for i18n testing - provides reusable helpers for creating translation mocks |
web/vitest.setup.ts |
Updated to use centralized createReactI18nextMock() instead of inline mock definition |
web/testing/testing.md |
Added documentation about global mock behavior and usage examples for custom translations |
web/app/components/plugins/plugin-mutation-model/index.spec.tsx |
Removed redundant i18n mocks (now uses global mock) |
web/app/components/plugins/plugin-detail-panel/subscription-list/edit/index.spec.tsx |
Removed redundant react-i18next mock |
web/app/components/plugins/plugin-detail-panel/subscription-list/create/oauth-client.spec.tsx |
Removed redundant react-i18next mock |
web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.spec.tsx |
Removed redundant react-i18next mock |
web/app/components/plugins/marketplace/index.spec.tsx |
Updated i18next-config mock and test assertions to match new global mock behavior (namespace prefixes) |
web/app/components/plugins/install-plugin/install-from-local-package/steps/uploading.spec.tsx |
Removed redundant react-i18next mock |
web/app/components/plugins/install-plugin/install-from-local-package/steps/install.spec.tsx |
Uses centralized mock with custom Trans override for components prop handling |
web/app/components/plugins/card/index.spec.tsx |
Removed redundant i18n mocks |
web/app/components/datasets/documents/create-from-pipeline/processing/index.spec.tsx |
Removed redundant react-i18next mock |
web/app/components/datasets/create/index.spec.tsx |
Removed redundant react-i18next mock |
web/app/components/billing/pricing/footer.spec.tsx |
Removed custom translation map and mock |
web/app/components/base/input/index.spec.tsx |
Updated to import and use createReactI18nextMock with custom translations |
web/app/components/base/input-with-copy/index.spec.tsx |
Updated to import and use createReactI18nextMock with custom translations |
web/app/components/base/inline-delete-confirm/index.spec.tsx |
Updated to import and use createReactI18nextMock with custom translations |
web/app/components/app/configuration/config/config-audio.spec.tsx |
Removed redundant react-i18next mock |
web/app/components/app/configuration/config/agent-setting-button.spec.tsx |
Removed redundant react-i18next mock |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…eateReactI18nextMock` and detail global mock provisions.
Consolidate scattered i18next mock implementations across test files into a single source of truth. This reduces duplication and ensures consistent mock behavior.
🤖 Generated with Claude Code
Important
Fixes #<issue number>.Summary
fixes #30304
Screenshots
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods