-
Notifications
You must be signed in to change notification settings - Fork 0
test: unify i18next mocks into centralized helpers #38
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
base: greptile_combined_100_qodo_grep_sentry_1_base_test_unify_i18next_mocks_into_centralized_helpers_pr129
Are you sure you want to change the base?
Changes from all commits
344da1f
6834145
33272bd
1a45b88
ebf6662
f78fd25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,33 +21,6 @@ import Card from './index' | |
| // Mock External Dependencies Only | ||
| // ================================ | ||
|
|
||
|
Comment on lines
21
to
23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test will fail: The Card component uses Fix: Either restore the local mocks that were removed in this PR OR add global mocks for these hooks in Prompt To Fix With AIThis is a comment left during a code review.
Path: web/app/components/plugins/card/index.spec.tsx
Line: 21:23
Comment:
**Test will fail:** The Card component uses `useMixedTranslation` and `useGetLanguage` (imported in the actual component), but this test file removed the local mocks for these hooks. The global mock in `vitest.setup.ts` does NOT provide mocks for these hooks, so tests will fail when trying to render the Card component.
**Fix:** Either restore the local mocks that were removed in this PR OR add global mocks for these hooks in `vitest.setup.ts` (see comment on that file).
How can I resolve this? If you propose a fix, please make it concise. |
||
| // Mock react-i18next (translation hook) | ||
| vi.mock('react-i18next', () => ({ | ||
| useTranslation: () => ({ | ||
| t: (key: string) => key, | ||
| }), | ||
| })) | ||
|
|
||
| // Mock useMixedTranslation hook | ||
| vi.mock('../marketplace/hooks', () => ({ | ||
| useMixedTranslation: (_locale?: string) => ({ | ||
| t: (key: string, options?: { ns?: string }) => { | ||
| const fullKey = options?.ns ? `${options.ns}.${key}` : key | ||
| const translations: Record<string, string> = { | ||
| 'plugin.marketplace.partnerTip': 'Partner plugin', | ||
| 'plugin.marketplace.verifiedTip': 'Verified plugin', | ||
| 'plugin.installModal.installWarning': 'Install warning message', | ||
| } | ||
| return translations[fullKey] || key | ||
| }, | ||
| }), | ||
| })) | ||
|
|
||
| // Mock useGetLanguage context | ||
| vi.mock('@/context/i18n', () => ({ | ||
| useGetLanguage: () => 'en-US', | ||
| })) | ||
|
|
||
| // Mock useTheme hook | ||
| vi.mock('@/hooks/use-theme', () => ({ | ||
| default: () => ({ theme: 'light' }), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation inaccuracy: Same issue as
testing.md- this documentation claims the global mock providesuseMixedTranslationanduseGetLanguage, but these are NOT actually mocked inweb/vitest.setup.ts.Fix: Either update the documentation to reflect what's actually mocked, OR add the missing mocks to
vitest.setup.ts.Prompt To Fix With AI