Commit 46a68359 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch...

Merge branch '332820-epics-from-all-parent-groups-should-be-fetched-in-issue-sidebar-frontend' into 'master'

Include epics from ancestor groups in issue epic dropdown

See merge request gitlab-org/gitlab!63618
parents 17eebf53 8a8d2017
......@@ -2,7 +2,12 @@
query issueEpics($fullPath: ID!, $title: String, $state: EpicState) {
workspace: group(fullPath: $fullPath) {
attributes: epics(search: $title, state: $state) {
attributes: epics(
search: $title
state: $state
includeAncestorGroups: true
includeDescendantGroups: false
) {
nodes {
...EpicFragment
state
......
......@@ -5,59 +5,73 @@ require 'spec_helper'
RSpec.describe 'Epic in issue sidebar', :js do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, :public) }
let_it_be(:epic1) { create(:epic, group: group, title: 'Foo') }
let_it_be(:epic2) { create(:epic, group: group, title: 'Bar') }
let_it_be(:epic3) { create(:epic, group: group, title: 'Baz') }
let_it_be(:epic1) { create(:epic, group: group, title: 'Epic Foo') }
let_it_be(:epic2) { create(:epic, group: group, title: 'Epic Bar') }
let_it_be(:epic3) { create(:epic, group: group, title: 'Epic Baz') }
let_it_be(:project) { create(:project, :public, group: group) }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:epic_issue) { create(:epic_issue, epic: epic1, issue: issue) }
let_it_be(:subgroup) { create(:group, :public, parent: group) }
let_it_be(:subproject) { create(:project, :public, group: subgroup) }
let_it_be(:subepic) { create(:epic, group: subgroup, title: 'Subgroup epic') }
let_it_be(:subissue) { create(:issue, project: subproject) }
let_it_be(:sidebar_epic_selector) { '[data-testid="sidebar-epic"]' }
shared_examples 'epic in issue sidebar' do
before do
group.add_owner(user)
sign_in user
end
context 'projects within a group' do
before do
group.add_owner(user)
sign_in user
visit project_issue_path(project, issue)
wait_for_all_requests
end
it 'shows epic in issue sidebar' do
expect(page.find('[data-testid="sidebar-epic"]')).to have_content(epic1.title)
expect(page.find(sidebar_epic_selector)).to have_content(epic1.title)
end
it 'shows edit button in issue sidebar' do
expect(page.find('[data-testid="sidebar-epic"]')).to have_button('Edit')
expect(page.find(sidebar_epic_selector)).to have_button('Edit')
end
it 'shows epics select dropdown' do
page.within(find('[data-testid="sidebar-epic"]')) do
click_button 'Edit'
wait_for_all_requests
expect(page).to have_selector('.gl-new-dropdown-contents .gl-new-dropdown-item', count: 4) # `No Epic` + 3 epics
page.within(sidebar_epic_selector) do
click_edit
aggregate_failures do
expect(page).to have_selector('.gl-new-dropdown-contents .gl-new-dropdown-item', count: 4)
expect(page).to have_content 'No epic'
expect(page).to have_content epic1.title
expect(page).to have_content epic2.title
expect(page).to have_content epic3.title
end
end
end
it 'supports searching for an epic' do
page.within(find('[data-testid="sidebar-epic"]')) do
click_button 'Edit'
wait_for_all_requests
page.within(sidebar_epic_selector) do
click_edit
page.find('.gl-form-input').send_keys('Foo')
wait_for_all_requests
expect(page).to have_selector('.gl-new-dropdown-contents .gl-new-dropdown-item', count: 2) # `No Epic` + 1 matching epic
aggregate_failures do
expect(page).to have_selector('.gl-new-dropdown-contents .gl-new-dropdown-item', count: 2)
expect(page).to have_content 'No epic'
expect(page).to have_content epic1.title
end
end
end
it 'select an epic from the dropdown' do
page.within(find('[data-testid="sidebar-epic"]')) do
click_button 'Edit'
wait_for_all_requests
page.within(sidebar_epic_selector) do
click_edit
find('.gl-new-dropdown-item', text: epic2.title).click
......@@ -68,6 +82,28 @@ RSpec.describe 'Epic in issue sidebar', :js do
end
end
context 'project within a subgroup' do
before do
visit project_issue_path(subproject, issue)
wait_for_all_requests
end
it 'shows all epics belonging to the sub group and its parents' do
page.within(sidebar_epic_selector) do
click_edit
aggregate_failures do
expect(page).to have_selector('.gl-new-dropdown-contents .gl-new-dropdown-item', count: 5)
expect(page).to have_content 'No epic'
expect(page).to have_content epic1.title
expect(page).to have_content epic2.title
expect(page).to have_content epic3.title
expect(page).to have_content subepic.title
end
end
end
end
context 'personal projects' do
it 'does not show epic in issue sidebar' do
personal_project = create(:project, :public)
......@@ -127,4 +163,10 @@ RSpec.describe 'Epic in issue sidebar', :js do
def expect_no_epic
expect(page).not_to have_selector('.block.epic')
end
def click_edit
click_button 'Edit'
wait_for_all_requests
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment