Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 committed Nov 19, 2024
1 parent 243eb34 commit 614fe21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,16 @@ describe('SystemLanguagePreferenceModal', () => {
'zh-Hant'
)
})

it('should not open update modal when system language changes to an unsuppported language', () => {
vi.mocked(getSystemLanguage).mockReturnValue('es-MX')
render()

expect(screen.queryByRole('button', { name: 'Don’t change' })).toBeNull()
expect(
screen.queryByRole('button', {
name: 'Use system language',
})
).toBeNull()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@ export function SystemLanguagePreferenceModal(): JSX.Element | null {
const storedSystemLanguage = useSelector(getStoredSystemLanguage)

const showBootModal = appLanguage == null && systemLanguage != null

// only show update modal if we support the language their system has updated to
const showUpdateModal =
appLanguage != null &&
systemLanguage != null &&
LANGUAGES.find(language => language.value === systemLanguage) != null &&
storedSystemLanguage != null &&
systemLanguage !== storedSystemLanguage
const [showUpdateModal, setShowUpdateModal] = useState(false)

const title = showUpdateModal
? t('system_language_preferences_update')
Expand Down Expand Up @@ -123,6 +116,13 @@ export function SystemLanguagePreferenceModal(): JSX.Element | null {
void i18n.changeLanguage(systemLanguage)
}
}
// only show update modal if we support the language their system has updated to
setShowUpdateModal(
appLanguage != null &&
matchedSystemLanguageOption != null &&
storedSystemLanguage != null &&
systemLanguage !== storedSystemLanguage
)
}
}, [i18n, systemLanguage, showBootModal])

Expand Down

0 comments on commit 614fe21

Please sign in to comment.