Skip to content

Conversation

@hila-f-qodo
Copy link

@hila-f-qodo hila-f-qodo commented Jan 26, 2026

Benchmark PR from qodo-benchmark#437


Open with Devin

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 <[email protected]>
…eateReactI18nextMock` and detail global mock provisions.
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

Comment on lines +39 to +48
export function createUseTranslationMock(translations: TranslationMap = {}) {
return {
useTranslation: () => ({
t: createTFunction(translations),
i18n: {
language: 'en',
changeLanguage: vi.fn(),
},
}),
}

Choose a reason for hiding this comment

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

🟡 New i18n mock loses useTranslation(defaultNs) parameter support causing namespace prefix regression

The new createUseTranslationMock function does not pass the defaultNs parameter from useTranslation() to createTFunction(), causing a regression in behavior.

Click to expand

Issue

The original mock in vitest.setup.ts accepted a defaultNs parameter:

useTranslation: (defaultNs?: string) => ({
  t: (key: string, options?: Record<string, unknown>) => {
    const ns = options?.ns ?? defaultNs
    // ... uses ns for prefix
  },
}),

The new implementation at web/test/i18n-mock.ts:39-48 ignores this parameter:

useTranslation: () => ({
  t: createTFunction(translations),
  // defaultNs is never captured or passed
}),

Impact

Any code that calls useTranslation('someNamespace') expecting the returned t function to automatically prefix keys with that namespace will now receive unprefixed keys. This could cause test failures or false positives in tests that rely on namespace-prefixed translation keys.

For example, const { t } = useTranslation('plugin') followed by t('title') should return 'plugin.title' but now returns just 'title'.

Recommendation: Update createUseTranslationMock to accept and pass through the defaultNs parameter:

export function createUseTranslationMock(translations: TranslationMap = {}) {
  return {
    useTranslation: (defaultNs?: string) => ({
      t: createTFunction(translations, defaultNs),
      i18n: {
        language: 'en',
        changeLanguage: vi.fn(),
      },
    }),
  }
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

5 participants