diff options
Diffstat (limited to 'spec/features/issues')
9 files changed, 222 insertions, 94 deletions
diff --git a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb index 4c4a5624d00..a671edb3ceb 100644 --- a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb +++ b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb @@ -47,7 +47,7 @@ RSpec.describe 'Resolving all open threads in a merge request from an issue', :j end end - context 'creating an issue for threads' do + context 'creating an issue for threads', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/420845' do before do find('.discussions-counter .gl-new-dropdown-toggle').click find(resolve_all_discussions_link_selector).click @@ -79,7 +79,9 @@ RSpec.describe 'Resolving all open threads in a merge request from an issue', :j end it 'shows a warning that the merge request contains unresolved threads' do - expect(page).to have_content 'all threads must be resolved' + click_button 'Expand merge checks' + + expect(page).to have_content 'Unresolved discussions must be resolved' end end end diff --git a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb index 73a920421a3..52a8f0b105a 100644 --- a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb +++ b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb @@ -57,6 +57,8 @@ RSpec.describe 'Resolve an open thread in a merge request by creating an issue', context 'creating the issue' do before do + allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(105) + find(resolve_discussion_selector, match: :first).click end diff --git a/spec/features/issues/discussion_lock_spec.rb b/spec/features/issues/discussion_lock_spec.rb index 04d59854ddc..2ef912061e6 100644 --- a/spec/features/issues/discussion_lock_spec.rb +++ b/spec/features/issues/discussion_lock_spec.rb @@ -6,104 +6,240 @@ RSpec.describe 'Discussion Lock', :js, feature_category: :team_planning do let(:user) { create(:user) } let(:issue) { create(:issue, project: project, author: user) } let(:project) { create(:project, :public) } + let(:more_dropdown) { find_by_testid('desktop-dropdown') } + let(:issuable_lock) { find_by_testid('issuable-lock') } + let(:locked_badge) { '[data-testid="locked-badge"]' } + let(:issuable_note_warning) { '[data-testid="issuable-note-warning"]' } - before do - sign_in(user) - stub_feature_flags(moved_mr_sidebar: false) - end - - context 'when a user is a team member' do + context 'when feature flag is disabled' do before do - project.add_developer(user) + sign_in(user) + stub_feature_flags(moved_mr_sidebar: false) end - context 'when the discussion is unlocked' do - it 'the user can lock the issue' do - visit project_issue_path(project, issue) + context 'when a user is a team member' do + before do + project.add_developer(user) + end - expect(find('.issuable-sidebar')).to have_content('Unlocked') + context 'when the discussion is unlocked' do + it 'the user can lock the issue' do + visit project_issue_path(project, issue) - page.within('.issuable-sidebar') do - find('.lock-edit').click - click_button('Lock') - end + expect(find('.issuable-sidebar')).to have_content('Unlocked') + + page.within('.issuable-sidebar') do + find('.lock-edit').click + click_button('Lock') + end - expect(find('#notes')).to have_content('locked the discussion in this issue') + expect(find('#notes')).to have_content('locked the discussion in this issue') + end end - end - context 'when the discussion is locked' do - before do - issue.update_attribute(:discussion_locked, true) - visit project_issue_path(project, issue) + context 'when the discussion is locked' do + before do + issue.update_attribute(:discussion_locked, true) + visit project_issue_path(project, issue) + end + + it 'the user can unlock the issue' do + expect(find('.issuable-sidebar')).to have_content('Locked') + + page.within('.issuable-sidebar') do + find('.lock-edit').click + click_button('Unlock') + end + + expect(find('#notes')).to have_content('unlocked the discussion in this issue') + expect(find('.issuable-sidebar')).to have_content('Unlocked') + end + + it 'the user can create a comment' do + page.within('#notes .js-main-target-form') do + fill_in 'note[note]', with: 'Some new comment' + click_button 'Comment' + end + + wait_for_requests + + expect(find('div#notes')).to have_content('Some new comment') + end end + end - it 'the user can unlock the issue' do - expect(find('.issuable-sidebar')).to have_content('Locked') + context 'when a user is not a team member' do + context 'when the discussion is unlocked' do + before do + visit project_issue_path(project, issue) + end - page.within('.issuable-sidebar') do - find('.lock-edit').click - click_button('Unlock') + it 'the user can not lock the issue' do + expect(find('.issuable-sidebar')).to have_content('Unlocked') + expect(find('.issuable-sidebar')).not_to have_selector('.lock-edit') end - expect(find('#notes')).to have_content('unlocked the discussion in this issue') - expect(find('.issuable-sidebar')).to have_content('Unlocked') + it 'the user can create a comment' do + page.within('#notes .js-main-target-form') do + fill_in 'note[note]', with: 'Some new comment' + click_button 'Comment' + end + + wait_for_requests + + expect(find('div#notes')).to have_content('Some new comment') + end end - it 'the user can create a comment' do - page.within('#notes .js-main-target-form') do - fill_in 'note[note]', with: 'Some new comment' - click_button 'Comment' + context 'when the discussion is locked' do + before do + issue.update_attribute(:discussion_locked, true) + visit project_issue_path(project, issue) end - wait_for_requests + it 'the user can not unlock the issue' do + expect(find('.issuable-sidebar')).to have_content('Locked') + expect(find('.issuable-sidebar')).not_to have_selector('.lock-edit') + end - expect(find('div#notes')).to have_content('Some new comment') + it 'the user can not create a comment' do + page.within('#notes') do + expect(page).not_to have_selector('.js-main-target-form') + expect(find_by_testid('disabled-comments')) + .to have_content('The discussion in this issue is locked. Only project members can comment.') + end + end end end - end - context 'when a user is not a team member' do - context 'when the discussion is unlocked' do + context 'for axe automated accessibility testing' do before do + project.add_developer(user) + issue.update_attribute(:discussion_locked, true) visit project_issue_path(project, issue) end - it 'the user can not lock the issue' do - expect(find('.issuable-sidebar')).to have_content('Unlocked') - expect(find('.issuable-sidebar')).not_to have_selector('.lock-edit') + it 'passes tests' do + # rubocop:disable Capybara/TestidFinders -- within_testid does not work here + expect(page).to be_axe_clean.within(locked_badge) + expect(page).to be_axe_clean.within(issuable_note_warning) + # rubocop:enable Capybara/TestidFinders + page.within('.issuable-sidebar') do + find('.lock-edit').click + expect(page).to be_axe_clean.within('.lock-edit') + end end + end + end + + context 'when feature flag is enabled' do + before do + sign_in(user) + stub_feature_flags(moved_mr_sidebar: true) + end + + context 'when a user is a team member' do + before do + project.add_developer(user) + end + + context 'when the discussion is unlocked' do + it 'the user can lock the issue' do + visit project_issue_path(project, issue) + + more_dropdown.click + expect(issuable_lock).to have_content('Lock discussion') - it 'the user can create a comment' do - page.within('#notes .js-main-target-form') do - fill_in 'note[note]', with: 'Some new comment' - click_button 'Comment' + issuable_lock.click + expect(find('#notes')).to have_content('locked the discussion in this issue') + end + end + + context 'when the discussion is locked' do + before do + issue.update_attribute(:discussion_locked, true) + visit project_issue_path(project, issue) end - wait_for_requests + it 'the user can unlock the issue' do + more_dropdown.click + expect(issuable_lock).to have_content('Unlock discussion') + + issuable_lock.click + expect(find('#notes')).to have_content('unlocked the discussion in this issue') + expect(issuable_lock).to have_content('Lock discussion') + end - expect(find('div#notes')).to have_content('Some new comment') + it 'the user can create a comment' do + page.within('#notes .js-main-target-form') do + fill_in 'note[note]', with: 'Some new comment' + click_button 'Comment' + end + + wait_for_requests + + expect(find('div#notes')).to have_content('Some new comment') + end end end - context 'when the discussion is locked' do - before do - issue.update_attribute(:discussion_locked, true) - visit project_issue_path(project, issue) - end + context 'when a user is not a team member' do + context 'when the discussion is unlocked' do + before do + visit project_issue_path(project, issue) + end - it 'the user can not unlock the issue' do - expect(find('.issuable-sidebar')).to have_content('Locked') - expect(find('.issuable-sidebar')).not_to have_selector('.lock-edit') + it 'the user can not lock the issue' do + more_dropdown.click + expect(issuable_lock).to have_content('Lock discussion') + end + + it 'the user can create a comment' do + page.within('#notes .js-main-target-form') do + fill_in 'note[note]', with: 'Some new comment' + click_button 'Comment' + end + + wait_for_requests + + expect(find('div#notes')).to have_content('Some new comment') + end end - it 'the user can not create a comment' do - page.within('#notes') do - expect(page).not_to have_selector('js-main-target-form') - expect(page.find('.disabled-comments')) - .to have_content('The discussion in this issue is locked. Only project members can comment.') + context 'when the discussion is locked' do + before do + issue.update_attribute(:discussion_locked, true) + visit project_issue_path(project, issue) + end + + it 'the user can not unlock the issue' do + more_dropdown.click + expect(issuable_lock).to have_content('Unlock discussion') + end + + it 'the user can not create a comment' do + page.within('#notes') do + expect(page).not_to have_selector('js-main-target-form') + expect(find_by_testid('disabled-comments')) + .to have_content('The discussion in this issue is locked. Only project members can comment.') + end end end end + + it 'passes axe automated accessibility testing' do + project.add_developer(user) + issue.update_attribute(:discussion_locked, true) + visit project_issue_path(project, issue) + wait_for_all_requests + + # rubocop:disable Capybara/TestidFinders -- within_testid does not work here + expect(page).to be_axe_clean.within(locked_badge) + expect(page).to be_axe_clean.within(issuable_note_warning) + + more_dropdown.click + expect(page).to be_axe_clean.within('[data-testid="lock-issue-toggle"] button') + # rubocop:enable Capybara/TestidFinders + end end end diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 2fb30469691..896d86e4004 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -148,12 +148,12 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do click_button _('Select label') wait_for_all_requests - page.within '[data-testid="sidebar-labels"]' do + within_testid('sidebar-labels') do click_button label.title click_button label2.title click_button _('Close') wait_for_requests - page.within('[data-testid="embedded-labels-list"]') do + within_testid('embedded-labels-list') do expect(page).to have_content(label.title) expect(page).to have_content(label2.title) end @@ -188,13 +188,13 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do wait_for_all_requests - page.within '[data-testid="sidebar-labels"]' do + within_testid 'sidebar-labels' do click_button label.title click_button _('Close') wait_for_requests - page.within('[data-testid="embedded-labels-list"]') do + within_testid('embedded-labels-list') do expect(page).to have_content(label.title) end @@ -205,7 +205,7 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do wait_for_all_requests - page.within '[data-testid="sidebar-labels"]' do + within_testid 'sidebar-labels' do click_button label.title, class: 'dropdown-item' click_button _('Close') @@ -221,7 +221,7 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do wait_for_all_requests - page.within '[data-testid="sidebar-labels"]' do + within_testid 'sidebar-labels' do search_field = find('input[type="search"]') search_field.native.send_keys(label.title) @@ -238,7 +238,7 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do it 'displays an error message when submitting an invalid form' do click_button 'Create issue' - page.within('[data-testid="issue-title-input-field"]') do + within_testid('issue-title-input-field') do expect(page).to have_text(_('This field is required.')) end end @@ -463,14 +463,14 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do wait_for_all_requests - page.within '[data-testid="sidebar-labels"]' do + within_testid 'sidebar-labels' do click_button label.title click_button label2.title click_button _('Close') wait_for_requests - page.within('[data-testid="embedded-labels-list"]') do + within_testid('embedded-labels-list') do expect(page).to have_content(label.title) expect(page).to have_content(label2.title) end @@ -580,14 +580,14 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do wait_for_all_requests - page.within '[data-testid="sidebar-labels"]' do + within_testid 'sidebar-labels' do click_button _('Create project label') wait_for_requests end page.within '.js-labels-create' do - find('[data-testid="label-title-input"]').fill_in with: 'test label' + find_by_testid('label-title-input').fill_in with: 'test label' first('.suggest-colors-dropdown a').click click_button 'Create' diff --git a/spec/features/issues/incident_issue_spec.rb b/spec/features/issues/incident_issue_spec.rb index 5197f5d1e33..9225ba03003 100644 --- a/spec/features/issues/incident_issue_spec.rb +++ b/spec/features/issues/incident_issue_spec.rb @@ -35,7 +35,7 @@ RSpec.describe 'Incident Detail', :js, feature_category: :team_planning do it 'shows incident and alert data' do page.within('.issuable-details') do - incident_tabs = find('[data-testid="incident-tabs"]') + incident_tabs = find_by_testid('incident-tabs') aggregate_failures 'shows title and Summary tab' do expect(find('h1')).to have_content(incident.title) diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb index c8802a9cc71..15cb1678c55 100644 --- a/spec/features/issues/issue_detail_spec.rb +++ b/spec/features/issues/issue_detail_spec.rb @@ -138,7 +138,7 @@ RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do it 'cannot see Incident option' do open_issue_edit_form - page.within('[data-testid="issuable-form"]') do + within_testid('issuable-form') do expect(page).to have_content('Issue') expect(page).not_to have_content('Incident') end @@ -151,7 +151,7 @@ RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do it 'routes the user to the incident details page when the `issue_type` is set to incident' do open_issue_edit_form - page.within('[data-testid="issuable-form"]') do + within_testid('issuable-form') do update_type_select('Issue', 'Incident') expect(page).to have_current_path(incident_project_issues_path(project, issue)) @@ -181,7 +181,7 @@ RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do it 'routes the user to the issue details page when the `issue_type` is set to issue' do open_issue_edit_form - page.within('[data-testid="issuable-form"]') do + within_testid('issuable-form') do update_type_select('Incident', 'Issue') expect(page).to have_current_path(project_issue_path(project, incident)) @@ -193,7 +193,7 @@ RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do def update_type_select(from, to) click_button from - find('[data-testid="issue-type-list-item"]', text: to).click + find_by_testid('issue-type-list-item', text: to).click click_button 'Save changes' wait_for_requests diff --git a/spec/features/issues/service_desk_spec.rb b/spec/features/issues/service_desk_spec.rb index 8662f0f98f5..3a2074b9b13 100644 --- a/spec/features/issues/service_desk_spec.rb +++ b/spec/features/issues/service_desk_spec.rb @@ -52,7 +52,7 @@ RSpec.describe 'Service Desk Issue Tracker', :js, feature_category: :service_des aggregate_failures do expect(page).to have_css('.empty-state') expect(page).to have_text('Use Service Desk to connect with your users') - expect(page).to have_link('Learn more.', href: help_page_path('user/project/service_desk')) + expect(page).to have_link('Learn more.', href: help_page_path('user/project/service_desk/index')) expect(page).not_to have_link('Enable Service Desk') expect(page).to have_content(project.service_desk_address) end @@ -71,7 +71,7 @@ RSpec.describe 'Service Desk Issue Tracker', :js, feature_category: :service_des aggregate_failures do expect(page).to have_css('.empty-state') expect(page).to have_text('Use Service Desk to connect with your users') - expect(page).to have_link('Learn more.', href: help_page_path('user/project/service_desk')) + expect(page).to have_link('Learn more.', href: help_page_path('user/project/service_desk/index')) expect(page).not_to have_link('Enable Service Desk') expect(page).not_to have_content(project.service_desk_address) end @@ -93,7 +93,7 @@ RSpec.describe 'Service Desk Issue Tracker', :js, feature_category: :service_des it 'displays the small info box, documentation, a button to configure service desk, and the address' do aggregate_failures do - expect(page).to have_link('Learn more.', href: help_page_path('user/project/service_desk')) + expect(page).to have_link('Learn more.', href: help_page_path('user/project/service_desk/index')) expect(page).not_to have_link('Enable Service Desk') expect(page).to have_content(project.service_desk_address) end diff --git a/spec/features/issues/user_interacts_with_awards_spec.rb b/spec/features/issues/user_interacts_with_awards_spec.rb index 813fdeea0a1..d47b6535688 100644 --- a/spec/features/issues/user_interacts_with_awards_spec.rb +++ b/spec/features/issues/user_interacts_with_awards_spec.rb @@ -306,18 +306,6 @@ RSpec.describe 'User interacts with awards', feature_category: :team_planning do expect(page).not_to have_selector(emoji_counter) end end - - context 'execute /award quick action' do - xit 'toggles the emoji award on noteable', :js do - execute_quick_action('/award :100:') - - expect(find(noteable_award_counter)).to have_text("1") - - execute_quick_action('/award :100:') - - expect(page).not_to have_selector(noteable_award_counter) - end - end end end diff --git a/spec/features/issues/user_sorts_issues_spec.rb b/spec/features/issues/user_sorts_issues_spec.rb index 206544b32a4..5c6198785d0 100644 --- a/spec/features/issues/user_sorts_issues_spec.rb +++ b/spec/features/issues/user_sorts_issues_spec.rb @@ -3,6 +3,7 @@ require "spec_helper" RSpec.describe "User sorts issues", feature_category: :team_planning do + include Features::SortingHelpers include SortingHelper include IssueHelpers @@ -46,8 +47,7 @@ RSpec.describe "User sorts issues", feature_category: :team_planning do it 'sorts by popularity', :js do visit(project_issues_path(project)) - click_button 'Created date' - click_on 'Popularity' + pajamas_sort_by 'Popularity', from: 'Created date' page.within(".issues-list") do page.within("li.issue:nth-child(1)") do |