diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-24 03:07:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-24 03:07:46 +0300 |
commit | fb59bd894060548bee04b6761796921f18512c44 (patch) | |
tree | 3faadf6d549fc1e00fd158dad60791616b8094de /spec | |
parent | 7e26b627ca9f79b34c91f17c2b0eb42ec5c591b0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/dashboard/issues_spec.rb | 17 | ||||
-rw-r--r-- | spec/frontend/vue_shared/components/new_issue_dropdown/new_issue_dropdown_spec.js | 60 | ||||
-rw-r--r-- | spec/requests/api/graphql/issues_spec.rb | 12 |
3 files changed, 65 insertions, 24 deletions
diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index ae375bd3e13..654cc9978a7 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -51,29 +51,26 @@ RSpec.describe 'Dashboard Issues', feature_category: :team_planning do describe 'new issue dropdown' do it 'shows projects only with issues feature enabled', :js do - click_button 'Toggle project select' + click_button _('Select project to create issue') - page.within('.select2-results') do + page.within('[data-testid="new-resource-dropdown"] [role="menu"]') do expect(page).to have_content(project.full_name) expect(page).not_to have_content(project_with_issues_disabled.full_name) end end it 'shows the new issue page', :js do - click_button 'Toggle project select' + click_button _('Select project to create issue') wait_for_requests project_path = "/#{project.full_path}" - project_json = { name: project.full_name, url: project_path }.to_json - # simulate selection, and prevent overlap by dropdown menu - first('.project-item-select', visible: false) - execute_script("$('.project-item-select').val('#{project_json}').trigger('change');") - find('#select2-drop-mask', visible: false) - execute_script("$('#select2-drop-mask').remove();") + page.within('[data-testid="new-resource-dropdown"]') do + find_button(project.full_name).click + end - find('.js-new-project-item-link').click + click_link format(_('New issue in %{project}'), project: project.name) expect(page).to have_current_path("#{project_path}/-/issues/new") diff --git a/spec/frontend/vue_shared/components/new_issue_dropdown/new_issue_dropdown_spec.js b/spec/frontend/vue_shared/components/new_issue_dropdown/new_issue_dropdown_spec.js index 5af4e5d3346..be9529202a7 100644 --- a/spec/frontend/vue_shared/components/new_issue_dropdown/new_issue_dropdown_spec.js +++ b/spec/frontend/vue_shared/components/new_issue_dropdown/new_issue_dropdown_spec.js @@ -1,6 +1,6 @@ import { GlDropdown, GlDropdownItem, GlSearchBoxByType } from '@gitlab/ui'; import { mount, shallowMount } from '@vue/test-utils'; -import Vue from 'vue'; +import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; @@ -9,6 +9,7 @@ import searchUserProjectsQuery from '~/vue_shared/components/new_issue_dropdown/ import searchProjectsWithinGroupQuery from '~/issues/list/queries/search_projects.query.graphql'; import { DASH_SCOPE, joinPaths } from '~/lib/utils/url_utility'; import { DEBOUNCE_DELAY } from '~/vue_shared/components/filtered_search_bar/constants'; +import { useLocalStorageSpy } from 'helpers/local_storage_helper'; import { emptySearchProjectsQueryResponse, emptySearchProjectsWithinGroupQueryResponse, @@ -18,7 +19,11 @@ import { searchProjectsWithinGroupQueryResponse, } from './mock_data'; +jest.mock('~/flash'); + describe('NewIssueDropdown component', () => { + useLocalStorageSpy(); + let wrapper; Vue.use(VueApollo); @@ -59,7 +64,7 @@ describe('NewIssueDropdown component', () => { }; afterEach(() => { - wrapper.destroy(); + localStorage.clear(); }); it('renders a split dropdown', () => { @@ -146,4 +151,55 @@ describe('NewIssueDropdown component', () => { }); }); }); + + describe('without localStorage', () => { + beforeEach(() => { + wrapper = mountComponent({ mountFn: mount }); + }); + + it('does not attempt to save the selected project to the localStorage', async () => { + await showDropdown(); + wrapper.findComponent(GlDropdownItem).vm.$emit('click', project1); + + expect(localStorage.setItem).not.toHaveBeenCalled(); + }); + }); + + describe('with localStorage', () => { + it('retrieves the selected project from the localStorage', async () => { + localStorage.setItem( + 'group--new-issue-recent-project', + JSON.stringify({ + webUrl: project1.webUrl, + name: project1.name, + }), + ); + wrapper = mountComponent({ mountFn: mount, propsData: { withLocalStorage: true } }); + await nextTick(); + const dropdown = findDropdown(); + + expect(dropdown.attributes('split-href')).toBe( + joinPaths(project1.webUrl, DASH_SCOPE, 'issues/new'), + ); + expect(dropdown.props('text')).toBe(`New issue in ${project1.name}`); + }); + + it('retrieves legacy cache from the localStorage', async () => { + localStorage.setItem( + 'group--new-issue-recent-project', + JSON.stringify({ + url: `${project1.webUrl}/issues/new`, + name: project1.name, + }), + ); + wrapper = mountComponent({ mountFn: mount, propsData: { withLocalStorage: true } }); + await nextTick(); + const dropdown = findDropdown(); + + expect(dropdown.attributes('split-href')).toBe( + joinPaths(project1.webUrl, DASH_SCOPE, 'issues/new'), + ); + expect(dropdown.props('text')).toBe(`New issue in ${project1.name}`); + }); + }); }); diff --git a/spec/requests/api/graphql/issues_spec.rb b/spec/requests/api/graphql/issues_spec.rb index e67c92d6c33..3dc79ef4d81 100644 --- a/spec/requests/api/graphql/issues_spec.rb +++ b/spec/requests/api/graphql/issues_spec.rb @@ -109,18 +109,6 @@ RSpec.describe 'getting an issue list at root level', feature_category: :team_pl end end - context 'when the root_level_issues_query feature flag is disabled' do - before do - stub_feature_flags(root_level_issues_query: false) - end - - it 'the field returns null' do - post_graphql(query, current_user: developer) - - expect(graphql_data).to eq('issues' => nil) - end - end - context 'when no filters are provided' do let(:all_query_params) { {} } |