diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-07 06:10:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-07 06:10:12 +0300 |
commit | b34fdc03bd8a2242aa422f3319937b0e0864ced2 (patch) | |
tree | 34660dbf621dba69234ed4ff5fcbcba79188e5d5 /spec | |
parent | d8f61f6383a930a4b25455fd8ccf624fa313bb07 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
5 files changed, 90 insertions, 12 deletions
diff --git a/spec/controllers/concerns/preferred_language_switcher_spec.rb b/spec/controllers/concerns/preferred_language_switcher_spec.rb index 40d6ac10c37..4ceb6fa312e 100644 --- a/spec/controllers/concerns/preferred_language_switcher_spec.rb +++ b/spec/controllers/concerns/preferred_language_switcher_spec.rb @@ -13,13 +13,79 @@ RSpec.describe PreferredLanguageSwitcher, type: :controller do end end + subject { cookies[:preferred_language] } + context 'when first visit' do + let(:glm_source) { 'about.gitlab.com' } + let(:accept_language_header) { nil } + before do - get :new + request.env['HTTP_ACCEPT_LANGUAGE'] = accept_language_header + + get :new, params: { glm_source: glm_source } end it 'sets preferred_language to default' do - expect(cookies[:preferred_language]).to eq Gitlab::CurrentSettings.default_preferred_language + expect(subject).to eq Gitlab::CurrentSettings.default_preferred_language + end + + context 'when language param is valid' do + let(:glm_source) { 'about.gitlab.com/fr-fr/' } + + it 'sets preferred_language accordingly' do + expect(subject).to eq 'fr' + end + + context 'when language param is invalid' do + let(:glm_source) { 'about.gitlab.com/ko-ko/' } + + it 'sets preferred_language to default' do + expect(subject).to eq Gitlab::CurrentSettings.default_preferred_language + end + end + end + + context 'when browser preferred language is not english' do + context 'with selectable language' do + let(:accept_language_header) { 'zh-CN,zh;q=0.8,zh-TW;q=0.7' } + + it 'sets preferred_language accordingly' do + expect(subject).to eq 'zh_CN' + end + end + + context 'with unselectable language' do + let(:accept_language_header) { 'nl-NL;q=0.8' } + + it 'sets preferred_language to default' do + expect(subject).to eq Gitlab::CurrentSettings.default_preferred_language + end + end + + context 'with empty string in language header' do + let(:accept_language_header) { '' } + + it 'sets preferred_language to default' do + expect(subject).to eq Gitlab::CurrentSettings.default_preferred_language + end + end + + context 'with language header without dashes' do + let(:accept_language_header) { 'fr;q=8' } + + it 'sets preferred_language accordingly' do + expect(subject).to eq 'fr' + end + end + end + + context 'when language params and language header are both valid' do + let(:accept_language_header) { 'zh-CN,zh;q=0.8,zh-TW;q=0.7' } + let(:glm_source) { 'about.gitlab.com/fr-fr/' } + + it 'sets preferred_language according to language params' do + expect(subject).to eq 'fr' + end end end @@ -36,7 +102,7 @@ RSpec.describe PreferredLanguageSwitcher, type: :controller do let(:user_preferred_language) { 'zh_CN' } it 'keeps preferred language unchanged' do - expect(cookies[:preferred_language]).to eq user_preferred_language + expect(subject).to eq user_preferred_language end end @@ -44,7 +110,7 @@ RSpec.describe PreferredLanguageSwitcher, type: :controller do let(:user_preferred_language) { 'xxx' } it 'sets preferred_language to default' do - expect(cookies[:preferred_language]).to eq Gitlab::CurrentSettings.default_preferred_language + expect(subject).to eq Gitlab::CurrentSettings.default_preferred_language end end end diff --git a/spec/frontend/boards/components/boards_selector_spec.js b/spec/frontend/boards/components/boards_selector_spec.js index b17a5589c07..fa18b47cf54 100644 --- a/spec/frontend/boards/components/boards_selector_spec.js +++ b/spec/frontend/boards/components/boards_selector_spec.js @@ -87,6 +87,7 @@ describe('BoardsSelector', () => { isGroupBoard = false, isProjectBoard = false, provide = {}, + props = {}, } = {}) => { fakeApollo = createMockApollo([ [projectBoardsQuery, projectBoardsQueryHandler], @@ -100,6 +101,7 @@ describe('BoardsSelector', () => { apolloProvider: fakeApollo, propsData: { throttleDuration, + ...props, }, attachTo: document.body, provide: { @@ -307,4 +309,14 @@ describe('BoardsSelector', () => { }); }); }); + + describe('Apollo boards', () => { + it('displays loading state of dropdown while current board is being fetched', () => { + createComponent({ + props: { isCurrentBoardLoading: true }, + provide: { isApolloBoard: true }, + }); + expect(findDropdown().props('loading')).toBe(true); + }); + }); }); diff --git a/spec/frontend/super_sidebar/components/sidebar_menu_spec.js b/spec/frontend/super_sidebar/components/sidebar_menu_spec.js index 1ba4b34ada0..dd780b172f5 100644 --- a/spec/frontend/super_sidebar/components/sidebar_menu_spec.js +++ b/spec/frontend/super_sidebar/components/sidebar_menu_spec.js @@ -201,11 +201,4 @@ describe('Sidebar Menu', () => { expect(findMainMenuSeparator().exists()).toBe(false); }); }); - - describe('ARIA attributes', () => { - it('adds aria-label attribute to nav element', () => { - createWrapper(); - expect(wrapper.find('nav').attributes('aria-label')).toBe('Main navigation'); - }); - }); }); diff --git a/spec/frontend/super_sidebar/components/super_sidebar_spec.js b/spec/frontend/super_sidebar/components/super_sidebar_spec.js index 2e2dfe7e94a..7a364299c72 100644 --- a/spec/frontend/super_sidebar/components/super_sidebar_spec.js +++ b/spec/frontend/super_sidebar/components/super_sidebar_spec.js @@ -274,4 +274,11 @@ describe('SuperSidebar component', () => { expect(findTrialStatusPopover().exists()).toBe(true); }); }); + + describe('ARIA attributes', () => { + it('adds aria-label attribute to nav element', () => { + createWrapper(); + expect(wrapper.find('nav').attributes('aria-label')).toBe('Primary'); + }); + }); }); diff --git a/spec/frontend/super_sidebar/components/super_sidebar_toggle_spec.js b/spec/frontend/super_sidebar/components/super_sidebar_toggle_spec.js index 23b735c2773..5a659c2a89a 100644 --- a/spec/frontend/super_sidebar/components/super_sidebar_toggle_spec.js +++ b/spec/frontend/super_sidebar/components/super_sidebar_toggle_spec.js @@ -53,7 +53,7 @@ describe('SuperSidebarToggle component', () => { it('has aria-label attribute', () => { createWrapper(); - expect(findButton().attributes('aria-label')).toBe(__('Navigation sidebar')); + expect(findButton().attributes('aria-label')).toBe(__('Primary navigation sidebar')); }); it('is disabled when isPeek is true', () => { |