From 6c24f7619ea9e5337c6eeff0a873c6a35d872ec4 Mon Sep 17 00:00:00 2001 From: praneeth <141117659+Muppasanipraneeth@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:44:47 +0530 Subject: [PATCH 1/7] fix : changed the language modal --- .../src/components/change-language/change-language.modal.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx index ddfd3bae7..3ddb1fbb5 100644 --- a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx +++ b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx @@ -12,6 +12,7 @@ import { import { useConnectivity, useSession } from '@openmrs/esm-framework'; import { postUserPropertiesOffline, postUserPropertiesOnline } from './change-language.resource'; import styles from './change-language.scss'; +import { capitalize } from 'lodash-es'; interface ChangeLanguageModalProps { close(): void; @@ -69,7 +70,7 @@ export default function ChangeLanguageModal({ close }: ChangeLanguageModalProps) key={`locale-option-${locale}-${i}`} id={`locale-option-${locale}-${i}`} name={locale} - labelText={languageNames[locale]} + labelText={capitalize(languageNames[locale])} value={locale} /> ))} From b108365c23bd6265d739156b4aad985183a6b987 Mon Sep 17 00:00:00 2001 From: praneeth <141117659+Muppasanipraneeth@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:59:23 +0530 Subject: [PATCH 2/7] O3-4298 change the language modal --- .../src/components/change-language/change-language.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx index 4097cbea8..2be5e0f93 100644 --- a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx +++ b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx @@ -55,9 +55,9 @@ describe(`Change Language Modal`, () => { render(); - expect(screen.getByRole('radio', { name: /français/ })).toBeChecked(); + expect(screen.getByRole('radio', { name: /Français/ })).toBeChecked(); - await user.click(screen.getByRole('radio', { name: /english/i })); + await user.click(screen.getByRole('radio', { name: /English/i })); await user.click(screen.getByRole('button', { name: /change/i })); expect(mockPostUserPropertiesOnline).toHaveBeenCalledWith( From 01c579032c391ae0094beaeecf94ed71c66c347e Mon Sep 17 00:00:00 2001 From: praneeth <141117659+Muppasanipraneeth@users.noreply.github.com> Date: Fri, 3 Jan 2025 20:03:35 +0530 Subject: [PATCH 3/7] modified the test --- .../change-language/change-language.test.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx index 2be5e0f93..a25eb9282 100644 --- a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx +++ b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx @@ -34,10 +34,10 @@ describe(`Change Language Modal`, () => { it('should correctly displays all allowed locales', () => { render(); - expect(screen.getByRole('radio', { name: /english/i })).toBeInTheDocument(); - expect(screen.getByRole('radio', { name: /français/i })).toBeInTheDocument(); - expect(screen.getByRole('radio', { name: /italiano/i })).toBeInTheDocument(); - expect(screen.getByRole('radio', { name: /português/i })).toBeInTheDocument(); + expect(screen.getByRole('radio', { name: /English/i })).toBeInTheDocument(); + expect(screen.getByRole('radio', { name: /Français/i })).toBeInTheDocument(); + expect(screen.getByRole('radio', { name: /Italiano/i })).toBeInTheDocument(); + expect(screen.getByRole('radio', { name: /Português/i })).toBeInTheDocument(); }); it('should close the modal when the cancel button is clicked', async () => { @@ -73,7 +73,7 @@ describe(`Change Language Modal`, () => { render(); - await user.click(screen.getByRole('radio', { name: /english/i })); + await user.click(screen.getByRole('radio', { name: /English/i })); await user.click(screen.getByRole('button', { name: /change/i })); expect(screen.getByText(/changing language.../i)).toBeInTheDocument(); @@ -85,7 +85,7 @@ describe(`Change Language Modal`, () => { render(); - await user.click(screen.getByRole('radio', { name: /english/i })); + await user.click(screen.getByRole('radio', { name: /English/i })); await user.click(screen.getByRole('button', { name: /change/i })); expect(mockPostUserPropertiesOffline).toHaveBeenCalledWith( From 504c7fab9840911d6d40dbe29d4006c3e46f74f2 Mon Sep 17 00:00:00 2001 From: praneeth <141117659+Muppasanipraneeth@users.noreply.github.com> Date: Sat, 4 Jan 2025 11:40:13 +0530 Subject: [PATCH 4/7] rather than using capitalze from lodash-es done with function --- .../components/change-language/change-language.modal.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx index 3ddb1fbb5..07cdbb3b3 100644 --- a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx +++ b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx @@ -12,7 +12,6 @@ import { import { useConnectivity, useSession } from '@openmrs/esm-framework'; import { postUserPropertiesOffline, postUserPropertiesOnline } from './change-language.resource'; import styles from './change-language.scss'; -import { capitalize } from 'lodash-es'; interface ChangeLanguageModalProps { close(): void; @@ -52,6 +51,9 @@ export default function ChangeLanguageModal({ close }: ChangeLanguageModalProps) ), [allowedLocales], ); + const Capitalize = (str: string) => { + return str.charAt(0).toUpperCase() + str.slice(1); + }; return ( <> @@ -70,7 +72,7 @@ export default function ChangeLanguageModal({ close }: ChangeLanguageModalProps) key={`locale-option-${locale}-${i}`} id={`locale-option-${locale}-${i}`} name={locale} - labelText={capitalize(languageNames[locale])} + labelText={Capitalize(languageNames[locale])} value={locale} /> ))} From 8089f0045d41783bc0085a7cde4975fb4f3744e4 Mon Sep 17 00:00:00 2001 From: praneeth <141117659+Muppasanipraneeth@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:00:18 +0530 Subject: [PATCH 5/7] used capitalize from lodash-es --- .../components/change-language/change-language.modal.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx index 07cdbb3b3..3ddb1fbb5 100644 --- a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx +++ b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx @@ -12,6 +12,7 @@ import { import { useConnectivity, useSession } from '@openmrs/esm-framework'; import { postUserPropertiesOffline, postUserPropertiesOnline } from './change-language.resource'; import styles from './change-language.scss'; +import { capitalize } from 'lodash-es'; interface ChangeLanguageModalProps { close(): void; @@ -51,9 +52,6 @@ export default function ChangeLanguageModal({ close }: ChangeLanguageModalProps) ), [allowedLocales], ); - const Capitalize = (str: string) => { - return str.charAt(0).toUpperCase() + str.slice(1); - }; return ( <> @@ -72,7 +70,7 @@ export default function ChangeLanguageModal({ close }: ChangeLanguageModalProps) key={`locale-option-${locale}-${i}`} id={`locale-option-${locale}-${i}`} name={locale} - labelText={Capitalize(languageNames[locale])} + labelText={capitalize(languageNames[locale])} value={locale} /> ))} From 982912922da2deef553e03abb3d1a9dd078d0ded Mon Sep 17 00:00:00 2001 From: praneeth <141117659+Muppasanipraneeth@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:08:20 +0530 Subject: [PATCH 6/7] updated the test --- .../change-language/change-language.test.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx index a25eb9282..6fc677473 100644 --- a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx +++ b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx @@ -34,10 +34,10 @@ describe(`Change Language Modal`, () => { it('should correctly displays all allowed locales', () => { render(); - expect(screen.getByRole('radio', { name: /English/i })).toBeInTheDocument(); - expect(screen.getByRole('radio', { name: /Français/i })).toBeInTheDocument(); - expect(screen.getByRole('radio', { name: /Italiano/i })).toBeInTheDocument(); - expect(screen.getByRole('radio', { name: /Português/i })).toBeInTheDocument(); + expect(screen.getByRole('radio', { name: /english/i })).toBeInTheDocument(); + expect(screen.getByRole('radio', { name: /français/i })).toBeInTheDocument(); + expect(screen.getByRole('radio', { name: /italiano/i })).toBeInTheDocument(); + expect(screen.getByRole('radio', { name: /português/i })).toBeInTheDocument(); }); it('should close the modal when the cancel button is clicked', async () => { @@ -55,9 +55,9 @@ describe(`Change Language Modal`, () => { render(); - expect(screen.getByRole('radio', { name: /Français/ })).toBeChecked(); + expect(screen.getByRole('radio', { name: /français/i })).toBeChecked(); - await user.click(screen.getByRole('radio', { name: /English/i })); + await user.click(screen.getByRole('radio', { name: /english/i })); await user.click(screen.getByRole('button', { name: /change/i })); expect(mockPostUserPropertiesOnline).toHaveBeenCalledWith( From fc5529f0a6e9c66f4bac664118cf4cdfbde57fcc Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Thu, 9 Jan 2025 23:28:05 +0300 Subject: [PATCH 7/7] Fixup --- .../src/components/change-language/change-language.modal.tsx | 2 +- .../src/components/change-language/change-language.test.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx index 3ddb1fbb5..543b6b7a2 100644 --- a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx +++ b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.modal.tsx @@ -1,5 +1,6 @@ import React, { useCallback, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; +import { capitalize } from 'lodash-es'; import { Button, InlineLoading, @@ -12,7 +13,6 @@ import { import { useConnectivity, useSession } from '@openmrs/esm-framework'; import { postUserPropertiesOffline, postUserPropertiesOnline } from './change-language.resource'; import styles from './change-language.scss'; -import { capitalize } from 'lodash-es'; interface ChangeLanguageModalProps { close(): void; diff --git a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx index 6fc677473..abff02978 100644 --- a/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx +++ b/packages/apps/esm-primary-navigation-app/src/components/change-language/change-language.test.tsx @@ -73,7 +73,7 @@ describe(`Change Language Modal`, () => { render(); - await user.click(screen.getByRole('radio', { name: /English/i })); + await user.click(screen.getByRole('radio', { name: /english/i })); await user.click(screen.getByRole('button', { name: /change/i })); expect(screen.getByText(/changing language.../i)).toBeInTheDocument(); @@ -85,7 +85,7 @@ describe(`Change Language Modal`, () => { render(); - await user.click(screen.getByRole('radio', { name: /English/i })); + await user.click(screen.getByRole('radio', { name: /english/i })); await user.click(screen.getByRole('button', { name: /change/i })); expect(mockPostUserPropertiesOffline).toHaveBeenCalledWith(