-
Notifications
You must be signed in to change notification settings - Fork 117
(Test) O3-5000 : Added unit tests to the Translation Builder Component #1079
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: main
Are you sure you want to change the base?
Conversation
| ], | ||
| "module": "esnext", | ||
| "moduleResolution": "node", | ||
| "ignoreDeprecations":"5.0", |
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.
| "ignoreDeprecations":"5.0", |
Shouldn't be necessary to modify the TypeScript config.
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.
We don't support React 19 yet, so we can undo changes to the lockfile.
| "@types/react": "^18.3.2", | ||
| "@types/react-dom": "^18.3.0", |
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.
Ditto about React 19 support.
| jest.mock('@hooks/getLanguageOptionsFromSession'); | ||
| jest.mock('@hooks/useBackendTranslations'); |
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.
See our recommended mocking patterns for the canonical way to stub mocks.
| const mockedShowSnackbar = showSnackbar as jest.Mock; | ||
|
|
||
| beforeAll(() => { | ||
| Object.defineProperty(window, 'matchMedia', { |
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.
This should be in setupTests.ts or similar.
| mockedShowSnackbar.mockReset(); | ||
| mockedShowModal.mockReset(); | ||
| mockedUploadTranslations.mockReset(); | ||
| mockedFetchTranslations.mockClear(); |
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.
The top-level jest config should have a clearMocks: true option that resets all mocks per test run.
Requirements
Summary
This PR adds unit tests to improve reliability and ensure correct behavior of the Translation Builder
Key Test Coverage:
Rendering: Verify Translation Builder UI renders with schema (tabs, dropdown, buttons, search).
Translations Display: Confirm fallback and overridden translations appear correctly.
Editing: Validate EditTranslationModal opens, updates schema on save, and cancels without changes.
Filtering & Search: Ensure tabs (All/Translated/Untranslated) and search filtering work.
Language Switching: Confirm translations update when switching languages, including backend merge.
Download: Test translation download, with error handling when no translations exist.
Upload: Mock upload flow with success and failure cases, showing proper snackbar messages
Screenshots
Related Issue
https://openmrs.atlassian.net/browse/O3-5000
Other
None