diff --git a/ee/spec/features/incidents/user_uses_quick_actions_spec.rb b/ee/spec/features/incidents/user_uses_quick_actions_spec.rb index 16fc2095f3dac32ba6baa8b918ccf6fca61bfe3d..8d1083d8910433499e4a31d8c7fa2aeb1416e1d3 100644 --- a/ee/spec/features/incidents/user_uses_quick_actions_spec.rb +++ b/ee/spec/features/incidents/user_uses_quick_actions_spec.rb @@ -19,14 +19,10 @@ end before do + stub_feature_flags(work_item_view_for_issues: true) project.add_developer(user) sign_in(user) visit project_issue_path(project, incident) - wait_for_all_requests - end - - after do - wait_for_requests end it_behaves_like 'zoom quick actions ee' diff --git a/ee/spec/features/issues/epic_in_issue_sidebar_spec.rb b/ee/spec/features/issues/epic_in_issue_sidebar_spec.rb index 46874d5f9a4e8e411e2a938d57b04597ea707c16..b0b189df6feaeeebd65f632f81225286e91f90be 100644 --- a/ee/spec/features/issues/epic_in_issue_sidebar_spec.rb +++ b/ee/spec/features/issues/epic_in_issue_sidebar_spec.rb @@ -3,92 +3,57 @@ require 'spec_helper' RSpec.describe 'Epic in issue sidebar', :js, feature_category: :team_planning do + include ListboxHelpers + # Ensure support bot user is created so creation doesn't count towards query limit # See https://gitlab.com/gitlab-org/gitlab/-/issues/509629 let_it_be(:support_bot) { Users::Internal.support_bot } let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group, :public) } 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(:work_item_epic) { create(:work_item, :epic, namespace: group, title: 'Work item Epic') } + 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(:work_item_epic) { create(:work_item, :epic, namespace: group, title: 'Work item Epic') } - 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"]' } - before do create(:callout, user: user, feature_name: :duo_chat_callout) + stub_feature_flags(work_item_view_for_issues: true) end 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 visit project_issue_path(project, issue) - wait_for_all_requests end - it 'shows epic in issue sidebar' do - expect(page.find(sidebar_epic_selector)).to have_content(epic1.title) - end + it 'shows epics select dropdown and supports searching', :aggregate_failures do + within_testid('work-item-parent') do + expect(page).to have_link(epic1.title) - it 'shows edit button in issue sidebar' do - expect(page.find(sidebar_epic_selector)).to have_button('Edit') - end + click_button 'Edit' - it 'shows epics select dropdown' do - page.within(sidebar_epic_selector) do - click_edit - - aggregate_failures do - expect(page).to have_selector('.gl-dropdown-contents .gl-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 work_item_epic.title - end - end - end + expect_listbox_items([work_item_epic.title, epic3.title, epic2.title, epic1.title]) - it 'supports searching for an epic' do - page.within(sidebar_epic_selector) do - click_edit + send_keys 'Bar' - page.find('.gl-form-input').send_keys('Foo') + expect_no_listbox_item(work_item_epic.title) + expect_no_listbox_item(epic3.title) + expect_no_listbox_item(epic1.title) + expect_listbox_items([epic2.title]) - wait_for_all_requests + select_listbox_item(epic2.title) - aggregate_failures do - expect(page).to have_selector('.gl-dropdown-contents .gl-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(sidebar_epic_selector) do - click_edit - - find('.gl-dropdown-item', text: epic2.title).click - - wait_for_all_requests - - expect(find_by_testid('select-epic')).to have_content(epic2.title) + expect(page).to have_link(epic2.title) end end end @@ -96,46 +61,33 @@ 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-dropdown-contents .gl-dropdown-item', count: 6) - 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 - expect(page).to have_content work_item_epic.title - end + it 'shows all epics belonging to the sub group and its parents', :aggregate_failures do + within_testid('work-item-parent') do + click_button 'Edit' + + expect_listbox_items([subepic.title, work_item_epic.title, epic3.title, epic2.title, epic1.title]) end end end context 'personal projects' do + # TODO update test to not expect testid once https://gitlab.com/gitlab-org/gitlab/-/issues/553969 is complete it 'does not show epic in issue sidebar' do personal_project = create(:project, :public) other_issue = create(:issue, project: personal_project) - visit project_issue_path(personal_project, other_issue) - expect_no_epic + expect(page).to have_testid('work-item-parent') end end end context 'when epics available' do before do - # TODO: remove threshold after epic-work item sync - # issue: https://gitlab.com/gitlab-org/gitlab/-/issues/438295 - allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(135) - stub_licensed_features(epics: true) - + group.add_owner(user) sign_in(user) end @@ -155,70 +107,27 @@ end context 'group has no license' do + # TODO update test to not expect testid once https://gitlab.com/gitlab-org/gitlab/-/issues/553969 is complete it 'does not show epic for public projects and groups' do visit project_issue_path(project, issue) - expect_no_epic + expect(page).to have_testid('work-item-parent') end end end end - context 'when epics are available' do - before do - group.add_owner(user) - stub_licensed_features(epics: true) - - sign_in(user) - - visit project_issue_path(project, issue) - end - - it 'shows work item epic in select dropdown' do - page.within(sidebar_epic_selector) do - click_edit - - aggregate_failures do - expect(page).to have_selector('.gl-dropdown-contents .gl-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 work_item_epic.title - end - end - end - - it 'select a work item epic from the dropdown' do - page.within(sidebar_epic_selector) do - click_edit - - click_button work_item_epic.title - - expect(page).to have_link(work_item_epic.title) - end - end - end - context 'when epics unavailable' do before do stub_licensed_features(epics: false) + group.add_owner(user) + sign_in(user) end it 'does not show epic in issue sidebar' do visit project_issue_path(project, issue) - expect_no_epic + expect(page).not_to have_testid('work-item-parent') end end - - 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 diff --git a/ee/spec/features/promotion_spec.rb b/ee/spec/features/promotion_spec.rb index eb1ddecedfe1d86ac7484180cb90435e6889cf39..dce3a7691d4dd57ae77f7a6eac46d505cb5c6670 100644 --- a/ee/spec/features/promotion_spec.rb +++ b/ee/spec/features/promotion_spec.rb @@ -16,6 +16,10 @@ let!(:issue) { create(:issue, project: project, author: user) } let(:otherproject) { create(:project, :repository, namespace: otherdeveloper.namespace) } + before do + stub_feature_flags(work_item_view_for_issues: true) + end + describe 'for merge request improve', :js, feature_category: :code_review_workflow do before do allow(License).to receive(:current).and_return(nil) @@ -105,49 +109,6 @@ end describe 'for epics in issues sidebar', :js, feature_category: :source_code_management do - shared_examples 'Epics promotion' do - it 'appears on the page' do - visit project_issue_path(project, issue) - wait_for_requests - - click_epic_link - - expect(find('.promotion-issue-sidebar-message')).to have_content 'Epics let you manage your portfolio of projects more efficiently' - end - - it 'is removed after dismissal' do - visit project_issue_path(project, issue) - wait_for_requests - - click_epic_link - find('.js-epics-sidebar-callout .js-close-callout').click - - expect(page).not_to have_selector('.promotion-issue-sidebar-message') - end - - it 'does not appear on page after dismissal and reload' do - visit project_issue_path(project, issue) - wait_for_requests - - click_epic_link - find('.js-epics-sidebar-callout .js-close-callout').click - visit project_issue_path(project, issue) - - expect(page).not_to have_selector('.js-epics-sidebar-callout') - end - - it 'closes dialog when clicking on X, but not dismiss it' do - visit project_issue_path(project, issue) - wait_for_requests - - click_epic_link - find('.js-epics-sidebar-callout .dropdown-menu-close').click - - expect(page).to have_selector('.js-epics-sidebar-callout') - expect(page).to have_selector('.promotion-issue-sidebar-message', visible: false) - end - end - context 'when gitlab_com_subscriptions saas feature is available', :saas do let_it_be(:group) { create(:group_with_plan) } @@ -158,7 +119,12 @@ sign_in(user) end - it_behaves_like 'Epics promotion' + it 'shows promotion information in sidebar' do + visit project_issue_path(project, issue) + + expect(page).to have_text 'Unlock epics, advanced boards, status, weight, iterations, and more to seamlessly tie your strategy to your DevSecOps workflows with GitLab.' + expect(page).to have_link 'Try it for free' + end end context 'when self hosted' do @@ -170,11 +136,11 @@ sign_in(user) end - it 'does not appear on the page' do + it 'shows promotion information in sidebar' do visit project_issue_path(project, issue) - wait_for_requests - expect(page).not_to have_selector('.js-epics-sidebar-callout') + expect(page).to have_text 'Unlock epics, advanced boards, status, weight, iterations, and more to seamlessly tie your strategy to your DevSecOps workflows with GitLab.' + expect(page).to have_link 'Try it for free' end end end @@ -188,53 +154,11 @@ sign_in(user) end - it 'appears on the page', :js do + it 'shows promotion information in sidebar' do visit project_issue_path(project, issue) - wait_for_requests - - page.within('.js-weight-sidebar-callout') do - click_link 'Learn more' - end - - expect(find('.promotion-issue-weight-sidebar-message')).to have_content 'Improve issues management with Issue weight and GitLab Enterprise Edition' - end - - it 'is removed after dismissal' do - visit project_issue_path(project, issue) - wait_for_requests - - page.within('.js-weight-sidebar-callout') do - click_link 'Learn more' - click_link 'Not now, thanks' - end - expect(page).not_to have_content('.js-weight-sidebar-callout') - end - - it 'does not appear on page after dismissal and reload' do - visit project_issue_path(project, issue) - wait_for_requests - - page.within('.js-weight-sidebar-callout') do - click_link 'Learn more' - click_link 'Not now, thanks' - end - - visit project_issue_path(project, issue) - - expect(page).not_to have_selector('.js-weight-sidebar-callout') - end - - it 'closes dialog when clicking on X, but not dismiss it' do - visit project_issue_path(project, issue) - wait_for_requests - - page.within('.js-weight-sidebar-callout') do - click_link 'Learn more' - click_link 'Learn more' - end - - expect(page).to have_selector('.js-weight-sidebar-callout') + expect(page).to have_text 'Unlock epics, advanced boards, status, weight, iterations, and more to seamlessly tie your strategy to your DevSecOps workflows with GitLab.' + expect(page).to have_link 'Try it for free' end context 'when gitlab_com_subscriptions is available', :saas do @@ -244,17 +168,11 @@ stub_saas_features(gitlab_com_subscriptions: true) end - it 'appears on the page', :js do + it 'shows promotion information in sidebar' do visit project_issue_path(project, issue) - wait_for_requests - - page.within('.js-weight-sidebar-callout') do - click_link 'Learn more' - end - expect(page).to have_link 'Try it for free', - href: new_trial_registration_path(glm_source: Gitlab.config.gitlab.host, glm_content: 'issue_weights'), class: 'promotion-trial-cta' - expect(find('.js-close-callout.js-close-session.tr-issue-weights-not-now-cta')).to have_content 'Not now, thanks!' + expect(page).to have_text 'Unlock epics, advanced boards, status, weight, iterations, and more to seamlessly tie your strategy to your DevSecOps workflows with GitLab.' + expect(page).to have_link 'Try it for free' end end end diff --git a/ee/spec/features/work_items/epics/issue_promotion_spec.rb b/ee/spec/features/work_items/epics/issue_promotion_spec.rb index 1204d439221cb55ed6470449db9399882cbe1741..d62b74c0d14f44ade04b7bb704150205d3cd8615 100644 --- a/ee/spec/features/work_items/epics/issue_promotion_spec.rb +++ b/ee/spec/features/work_items/epics/issue_promotion_spec.rb @@ -14,6 +14,7 @@ let(:user) { create(:user) } before do + stub_feature_flags(work_item_view_for_issues: true) sign_in(user) end @@ -21,7 +22,11 @@ it 'does not promote the issue' do visit project_issue_path(project, issue) - expect(page).not_to have_content 'Promoted issue to an epic.' + fill_in 'Add a reply', with: '/promote_to Epic' + click_button 'Comment' + + expect(page).to have_testid('success-alert', + text: 'Failed to promote this work item: Provided type is not supported.') expect(issue.reload).to be_open expect(Epic.count).to eq(1) @@ -39,7 +44,11 @@ end it 'does not promote the issue' do - expect(page).not_to have_content 'Promoted issue to an epic.' + fill_in 'Add a reply', with: '/promote_to Epic' + click_button 'Comment' + + expect(page).to have_testid('success-alert', + text: 'Failed to promote this work item: Provided type is not supported.') expect(issue.reload).to be_open expect(Epic.count).to eq(1) @@ -52,18 +61,14 @@ visit project_issue_path(project, issue) end - it 'displays description' do - fill_in 'Comment', with: '/promote' - - expect(find_autocomplete_menu).to have_text 'Promote issue to an epic' - end - it 'promotes the issue' do - add_note('/promote') + fill_in 'Add a reply', with: '/promote_to Epic' + click_button 'Comment' epic = Epic.last - expect(page).to have_content 'Promoted issue to an epic.' + expect(page).to have_testid('success-alert', text: 'Promoted successfully.') + expect(page).to have_text('Closed ( promoted )') expect(issue.reload).to be_closed expect(epic.title).to eq(issue.title) expect(epic.description).to eq(issue.description) @@ -78,11 +83,13 @@ end it 'promotes the issue' do - add_note('/promote') + fill_in 'Add a reply', with: '/promote_to Epic' + click_button 'Comment' epic = Epic.last - expect(page).to have_content 'Promoted issue to an epic.' + expect(page).to have_testid('success-alert', text: 'Promoted successfully.') + expect(page).to have_text('Closed ( promoted )') expect(issue.reload).to be_closed expect(epic.title).to eq(issue.title) expect(epic.description).to eq(issue.description) diff --git a/ee/spec/features/work_items/epics/referencing_epics_spec.rb b/ee/spec/features/work_items/epics/referencing_epics_spec.rb index 37009cf9fb68eea7b5af9c96f49e406f362a4672..befa5ff4f4791ce83bf226d7e0410ad276608272 100644 --- a/ee/spec/features/work_items/epics/referencing_epics_spec.rb +++ b/ee/spec/features/work_items/epics/referencing_epics_spec.rb @@ -14,10 +14,13 @@ let(:full_reference) { epic.to_reference(full: true) } + before do + stub_feature_flags(work_item_view_for_issues: true) + stub_licensed_features(epics: true) + end + describe 'reference on an issue' do before do - stub_licensed_features(epics: true) - sign_in(user) end @@ -31,7 +34,7 @@ it 'displays link to the reference' do visit project_issue_path(child_project, issue) - page.within('.issuable-details .description') do + within_testid('work-item-description-wrapper') do expect(page).to have_link(epic.to_reference, href: group_epic_path(group, epic)) expect(page).to have_link(short_reference, href: group_epic_path(group, epic2)) end @@ -47,7 +50,7 @@ it 'displays link to the reference' do visit project_issue_path(project, issue) - page.within('.issuable-details .description') do + within_testid('work-item-description-wrapper') do expect(page).to have_link(full_reference, href: group_epic_path(group, epic)) end end @@ -61,7 +64,7 @@ it 'does not display link to the reference' do visit project_issue_path(project, issue) - page.within('.issuable-details .description') do + within_testid('work-item-description-wrapper') do expect(page).not_to have_link end end @@ -78,7 +81,7 @@ it 'displays link to the reference' do visit project_issue_path(project, issue) - page.within('.issuable-details .description') do + within_testid('work-item-description-wrapper') do expect(page).to have_link(full_reference, href: group_epic_path(group, epic)) end end @@ -91,9 +94,7 @@ let(:issue) { create(:issue, project: project) } before do - stub_licensed_features(epics: true) group.add_developer(user) - sign_in(user) end @@ -103,23 +104,21 @@ before do visit project_issue_path(project, issue) - fill_in 'note[note]', with: note_text + fill_in 'Add a reply', with: note_text click_button 'Comment' - - wait_for_requests end it 'creates a note with reference and cross references the epic', :sidekiq_might_not_need_inline do - page.within('div#notes li.note div.note-text') do - expect(page).to have_content(note_text) - expect(page.find('a')).to have_content(epic.to_reference(full: true)) + page.within('li.note') do + expect(page).to have_text(note_text) + expect(page).to have_link(epic.to_reference(full: true)) end - find('div#notes li.note div.note-text a').click + click_link(epic.to_reference(full: true)) within_testid('system-note-content') do expect(page).to have_content('mentioned in issue') - expect(page.find('a')).to have_content(issue.to_reference(full: true)) + expect(page).to have_link(issue.to_reference(full: true)) end end @@ -129,10 +128,8 @@ before do visit group_epic_path(group, epic) - find_by_testid('markdown-editor-form-field').native.send_keys(note_text) + fill_in 'Add a reply', with: note_text click_button 'Comment' - - wait_for_requests end it 'creates a note with reference and cross references the issue', :sidekiq_might_not_need_inline do @@ -142,9 +139,9 @@ visit project_issue_path(project, issue) - page.within('div#notes li.system-note .system-note-message') do + page.within('li.system-note') do expect(page).to have_content('mentioned in epic') - expect(page.find('a')).to have_content(epic.work_item.to_reference(full: true)) + expect(page).to have_link(epic.work_item.to_reference(full: true)) end end end diff --git a/ee/spec/support/shared_examples/quick_actions/incidents/status_page_quick_actions_shared_examples.rb b/ee/spec/support/shared_examples/quick_actions/incidents/status_page_quick_actions_shared_examples.rb index ca93ae21d88706991b2a2e3bd67755658be21aff..311514a58a7d6a6bfa137308a5f1d83e6c078ff4 100644 --- a/ee/spec/support/shared_examples/quick_actions/incidents/status_page_quick_actions_shared_examples.rb +++ b/ee/spec/support/shared_examples/quick_actions/incidents/status_page_quick_actions_shared_examples.rb @@ -34,14 +34,14 @@ it 'publishes the issue' do visit new_project_issue_path(project) + select('Incident', from: 'Type') fill_in('Title', with: 'Title') fill_in('Description', with: "Published issue \n\n/publish") - click_button('Create issue') - - wait_for_requests + click_button('Create incident') expect(page).to have_content('Published issue') - expect(page).to have_content("#{user.name} published this issue to the status page") + # TODO update this to show the text once https://gitlab.com/gitlab-org/gitlab/-/issues/577908 is complete + expect(page).not_to have_content("#{user.name} published this issue to the status page") end end