Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
fix: do not show translation warning for EN (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler authored Jan 16, 2022
1 parent 801d412 commit 84f811b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 19 additions & 1 deletion web/src/components/profile/settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ beforeEach(() => {
(redux.useSelector as jest.Mock).mockImplementation(() => ({
showErrorMessage: false,
skippedSentences: [1],
currentUiLanguage: 'en',
currentUILocale: 'en',
allLanguages: [],
}));
});
Expand All @@ -34,6 +34,24 @@ test('should render ui language section', async () => {
expect(screen.getByText('Interface Language')).toBeTruthy();
});

test('should render potentially not translated warning', async () => {
(redux.useSelector as jest.Mock).mockImplementation(() => ({
showErrorMessage: false,
skippedSentences: [],
currentUILocale: 'de',
allLanguages: [],
}));

await renderWithLocalization(<Settings />);
expect(screen.getByText(/might not be fully translated/)).toBeTruthy();
});

test('should not render potentially not translated warning for English', async () => {
await renderWithLocalization(<Settings />);
expect(screen.getByText('Interface Language')).toBeTruthy();
expect(screen.queryByText(/might not be fully translated/)).toBeNull();
});

test('should render error message', async () => {
(redux.useSelector as jest.Mock).mockImplementation(() => ({
showErrorMessage: true,
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/profile/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Localized } from '@fluent/react';

import cvTranslatedLocales from '../../../../locales/translated.json';
import { resetSkippedSentences } from '../../actions/sentences';
import { DEFAULT_LOCALE } from '../../l10n';
import type { RootState } from '../../types';

import LanguageSelector from '../language-selector';
Expand All @@ -29,7 +30,8 @@ export default function Settings() {
};

useEffect(() => {
const possiblyUntranslated = !CV_TRANSLATED_LOCALES.includes(currentUILocale);
const possiblyUntranslated =
currentUILocale !== DEFAULT_LOCALE && !CV_TRANSLATED_LOCALES.includes(currentUILocale);
setShowTranslatedWarning(possiblyUntranslated);
}, [currentUILocale]);

Expand Down

0 comments on commit 84f811b

Please sign in to comment.