Skip to content

test: unify i18next mocks into centralized helpers#92

Open
tomerqodo wants to merge 5 commits intogreptile_combined_20260121_qodo_grep_cursor_copilot_1_base_test_unify_i18next_mocks_into_centralized_helpers_pr437from
greptile_combined_20260121_qodo_grep_cursor_copilot_1_head_test_unify_i18next_mocks_into_centralized_helpers_pr437
Open

test: unify i18next mocks into centralized helpers#92
tomerqodo wants to merge 5 commits intogreptile_combined_20260121_qodo_grep_cursor_copilot_1_base_test_unify_i18next_mocks_into_centralized_helpers_pr437from
greptile_combined_20260121_qodo_grep_cursor_copilot_1_head_test_unify_i18next_mocks_into_centralized_helpers_pr437

Conversation

@tomerqodo
Copy link

Benchmark PR from qodo-benchmark#437

hyoban and others added 5 commits January 21, 2026 15:55
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>
…eateReactI18nextMock` and detail global mock provisions.
@greptile-apps
Copy link

greptile-apps bot commented Jan 21, 2026

Greptile Summary

  • Refactors i18next mocking across frontend tests by creating a centralized helper function createReactI18nextMock in web/test/i18n-mock.ts to replace duplicate inline mocks
  • Updates 20+ test files to use the centralized helper instead of maintaining individual react-i18next mock implementations
  • Enhances testing documentation and templates to guide developers towards using the standardized mocking approach rather than creating custom inline mocks

Important Files Changed

Filename Overview
web/test/i18n-mock.ts New centralized helper file that provides createReactI18nextMock function with TypeScript support for consistent i18n mocking
web/vitest.setup.ts Updated global test setup to use centralized i18n mock helper instead of inline implementation
web/testing/testing.md Enhanced testing documentation with guidance on using centralized i18n helpers over manual mock definitions

Confidence score: 5/5

  • This PR is extremely safe to merge with minimal risk as it's purely a refactoring effort that consolidates duplicate code
  • Score reflects thorough implementation across the entire frontend test suite with consistent patterns and well-documented changes
  • No files require special attention as the changes maintain identical test functionality while improving maintainability

Sequence Diagram

sequenceDiagram
    participant Developer
    participant TestFile
    participant I18nMockHelper
    participant ViTest
    participant GlobalSetup

    Developer->>TestFile: "Write/update test file"
    TestFile->>I18nMockHelper: "Import createReactI18nextMock"
    TestFile->>I18nMockHelper: "Call createReactI18nextMock({ 'key': 'value' })"
    I18nMockHelper->>TestFile: "Return mock config"
    TestFile->>ViTest: "vi.mock('react-i18next', mockConfig)"
    ViTest->>GlobalSetup: "Load vitest.setup.ts"
    GlobalSetup->>ViTest: "Apply global i18n mock"
    ViTest->>TestFile: "Override with custom translations"
    TestFile->>TestFile: "Render component"
    TestFile->>TestFile: "Assert using custom translation"
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. web/app/components/plugins/plugin-mutation-model/index.spec.tsx, line 18-27 (link)

    style: These i18n-config mocks may be inconsistent with the centralized i18next mocking approach. Consider moving these to the centralized helpers as well.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

    Context Used: Context from dashboard - .cursorrules (source). Should these remaining i18n-config mocks also be moved to the centralized helpers for consistency?

21 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants