-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(settings): show active forced locale or language instead of 'No locale set' (#41543) #53364
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: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Clarified the naming in the validate functions - Removed unnecessary mocks, and added stubs in tests. - Testing for existence of element with data-test attributes, and without relying on translated text. - Removed overly complex component mocking Signed-off-by: Annabel Church <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { mount } from '@vue/test-utils' | ||
| import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' | ||
| import { loadState } from '@nextcloud/initial-state' | ||
| import LanguageSection from './LanguageSection.vue' | ||
|
|
||
| /** | ||
| * Mock Nextcloud modules | ||
| */ | ||
| vi.mock('@nextcloud/initial-state', () => ({ | ||
| loadState: vi.fn(() => ({ | ||
| languageMap: { | ||
| activeLanguage: { code: 'en', name: 'English' }, | ||
| commonLanguages: [], | ||
| otherLanguages: [], | ||
| }, | ||
| })), | ||
| })) | ||
|
|
||
| describe('LanguageSection', () => { | ||
| let wrapper | ||
|
|
||
| const mountComponent = () => { | ||
| return mount(LanguageSection, { | ||
| stubs: { | ||
| Language: { | ||
| template: '<div data-test="language-select" />', | ||
| }, | ||
| HeaderBar: { | ||
| template: '<div data-test="header-bar" />', | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| describe('when the language is user-configurable', () => { | ||
| beforeEach(async () => { | ||
| const userConfigurableData = { | ||
| languageMap: { | ||
| activeLanguage: { code: 'en', name: 'English' }, | ||
| commonLanguages: [{ code: 'en', name: 'English' }], | ||
| otherLanguages: [{ code: 'de', name: 'German' }], | ||
| }, | ||
| } | ||
| vi.mocked(loadState).mockReturnValueOnce(userConfigurableData) | ||
| wrapper = mountComponent() | ||
| await wrapper.vm.$nextTick() | ||
| }) | ||
|
|
||
| it('shows the language select component', () => { | ||
| expect(wrapper.find('[data-test="language-select"]').exists()).toBe(true) | ||
| }) | ||
|
|
||
| }) | ||
|
|
||
| describe('when there is no language data', () => { | ||
| beforeEach(async () => { | ||
| const noLanguageData = { languageMap: {} } | ||
| vi.mocked(loadState).mockReturnValueOnce(noLanguageData) | ||
| wrapper = mountComponent() | ||
| await wrapper.vm.$nextTick() | ||
| }) | ||
|
|
||
| it('shows no language component', () => { | ||
| expect(wrapper.find('[data-test="no-language-message"]').exists()).toBe(true) | ||
| }) | ||
| }) | ||
|
|
||
| describe('when the language is forced by the administrator', () => { | ||
| beforeEach(async () => { | ||
| const forcedLanguageData = { | ||
| languageMap: { | ||
| forcedLanguage: { code: 'uk', name: 'Ukrainian' }, | ||
| }, | ||
| } | ||
| vi.mocked(loadState).mockReturnValueOnce(forcedLanguageData) | ||
| wrapper = mountComponent() | ||
| await wrapper.vm.$nextTick() | ||
| }) | ||
|
|
||
| it('shows forced language component', () => { | ||
| expect(wrapper.find('[data-test="forced-language-message"]').exists()).toBe(true) | ||
| }) | ||
|
|
||
| }) | ||
|
|
||
| afterEach(() => { | ||
| if (wrapper) { | ||
| wrapper.destroy() | ||
| wrapper = null | ||
| } | ||
| vi.resetAllMocks() | ||
| }) | ||
| }) |
|
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.