Skip to content

Conversation

@ssebayigga-sharif
Copy link

@ssebayigga-sharif ssebayigga-sharif commented Dec 23, 2025

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

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

Screenshot (38)

Related Issue

https://openmrs.atlassian.net/browse/O3-5000

Other

None

],
"module": "esnext",
"moduleResolution": "node",
"ignoreDeprecations":"5.0",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"ignoreDeprecations":"5.0",

Shouldn't be necessary to modify the TypeScript config.

Copy link
Member

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.

Comment on lines -85 to -86
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
Copy link
Member

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.

Comment on lines +11 to +12
jest.mock('@hooks/getLanguageOptionsFromSession');
jest.mock('@hooks/useBackendTranslations');
Copy link
Member

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', {
Copy link
Member

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.

Comment on lines +73 to +76
mockedShowSnackbar.mockReset();
mockedShowModal.mockReset();
mockedUploadTranslations.mockReset();
mockedFetchTranslations.mockClear();
Copy link
Member

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.

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.

2 participants