diff options
Diffstat (limited to 'spec/features/merge_request')
13 files changed, 115 insertions, 129 deletions
diff --git a/spec/features/merge_request/batch_comments_spec.rb b/spec/features/merge_request/batch_comments_spec.rb index 736c986d0fe..ddbcb04fa80 100644 --- a/spec/features/merge_request/batch_comments_spec.rb +++ b/spec/features/merge_request/batch_comments_spec.rb @@ -210,7 +210,8 @@ RSpec.describe 'Merge request > Batch comments', :js, feature_category: :code_re page.find('.js-diff-comment-avatar').click end - it 'publishes comment right away and unresolves the thread' do + it 'publishes comment right away and unresolves the thread', + quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/337931' do expect(active_discussion.resolved?).to eq(true) write_reply_to_discussion(button_text: 'Add comment now', unresolve: true) @@ -220,7 +221,8 @@ RSpec.describe 'Merge request > Batch comments', :js, feature_category: :code_re end end - it 'publishes review and unresolves the thread' do + it 'publishes review and unresolves the thread', + quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/337931' do expect(active_discussion.resolved?).to eq(true) wait_for_requests @@ -252,10 +254,10 @@ RSpec.describe 'Merge request > Batch comments', :js, feature_category: :code_re wait_for_requests end - def write_diff_comment(**params) + def write_diff_comment(...) click_diff_line(find_by_scrolling("[id='#{sample_compare.changes[0][:line_code]}']")) - write_comment(**params) + write_comment(...) end def write_parallel_comment(line, **params) diff --git a/spec/features/merge_request/user_can_see_draft_toggle_spec.rb b/spec/features/merge_request/user_can_see_draft_toggle_spec.rb new file mode 100644 index 00000000000..ac7b5cdab04 --- /dev/null +++ b/spec/features/merge_request/user_can_see_draft_toggle_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Merge request > User sees draft toggle', feature_category: :code_review_workflow do + let_it_be(:project) { create(:project, :public, :repository) } + let(:user) { project.creator } + + before do + project.add_maintainer(user) + sign_in(user) + end + + context 'with draft commits' do + it 'shows the draft toggle' do + visit project_new_merge_request_path( + project, + merge_request: { + source_project_id: project.id, + target_project_id: project.id, + source_branch: 'wip', + target_branch: 'master' + }) + + expect(page).to have_css('input[type="checkbox"].js-toggle-draft', count: 1) + expect(page).to have_text('Mark as draft') + expect(page).to have_text('Drafts cannot be merged until marked ready.') + end + end + + context 'without draft commits' do + it 'shows the draft toggle' do + visit project_new_merge_request_path( + project, + merge_request: { + source_project_id: project.id, + target_project_id: project.id, + source_branch: 'fix', + target_branch: 'master' + }) + + expect(page).to have_css('input[type="checkbox"].js-toggle-draft', count: 1) + expect(page).to have_text('Mark as draft') + expect(page).to have_text('Drafts cannot be merged until marked ready.') + end + end +end diff --git a/spec/features/merge_request/user_creates_merge_request_spec.rb b/spec/features/merge_request/user_creates_merge_request_spec.rb index 1717069a259..97b423f2cc2 100644 --- a/spec/features/merge_request/user_creates_merge_request_spec.rb +++ b/spec/features/merge_request/user_creates_merge_request_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'User creates a merge request', :js, feature_category: :code_review_workflow do include ProjectForksHelper + include ListboxHelpers shared_examples 'creates a merge request' do specify do @@ -73,19 +74,9 @@ RSpec.describe 'User creates a merge request', :js, feature_category: :code_revi expect(page).to have_content('You must select source and target branch') - first('.js-source-project').click - first('.dropdown-source-project a', text: forked_project.full_path) - - first('.js-target-project').click - first('.dropdown-target-project li', text: project.full_path) - - first('.js-source-branch').click - - wait_for_requests - - source_branch = 'fix' - - first('.js-source-branch-dropdown .dropdown-content a', text: source_branch).click + select_project('.js-source-project', forked_project) + select_project('.js-target-project', project) + select_branch('.js-source-branch', 'fix') click_button('Compare branches and continue') @@ -107,7 +98,7 @@ RSpec.describe 'User creates a merge request', :js, feature_category: :code_revi click_button('Create merge request') - expect(page).to have_content(title).and have_content("requested to merge #{forked_project.full_path}:#{source_branch} into master") + expect(page).to have_content(title).and have_content("requested to merge #{forked_project.full_path}:fix into master") end end end @@ -153,12 +144,27 @@ RSpec.describe 'User creates a merge request', :js, feature_category: :code_revi private def compare_source_and_target(source_branch, target_branch) - find('.js-source-branch').click - click_link(source_branch) - - find('.js-target-branch').click - click_link(target_branch) + select_branch('.js-source-branch', source_branch) + select_branch('.js-target-branch', target_branch) click_button('Compare branches') end + + def select_project(selector, project) + first(selector).click + + wait_for_requests + + find('.gl-listbox-search-input').set(project.full_path) + select_listbox_item(project.full_path) + end + + def select_branch(selector, branch) + first(selector).click + + wait_for_requests + + find('.gl-listbox-search-input').set(branch) + select_listbox_item(branch, exact_text: true) + end end diff --git a/spec/features/merge_request/user_creates_mr_spec.rb b/spec/features/merge_request/user_creates_mr_spec.rb index 523027582b3..6ee20a08a47 100644 --- a/spec/features/merge_request/user_creates_mr_spec.rb +++ b/spec/features/merge_request/user_creates_mr_spec.rb @@ -59,9 +59,9 @@ RSpec.describe 'Merge request > User creates MR', feature_category: :code_review it 'filters source project' do find('.js-source-project').click - find('.dropdown-source-project input').set('source') + find('.gl-listbox-search-input').set('source') - expect(find('.dropdown-source-project .dropdown-content')).not_to have_content(source_project.name) + expect(first('.merge-request-select .gl-new-dropdown-panel')).not_to have_content(source_project.name) end end end diff --git a/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb b/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb index 60631027d9d..cf5024ad59e 100644 --- a/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb +++ b/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe 'Merge request > User edits assignees sidebar', :js, feature_category: :code_review_workflow do + include Spec::Support::Helpers::Features::InviteMembersModalHelper + let(:project) { create(:project, :public, :repository) } let(:protected_branch) { create(:protected_branch, :maintainers_can_push, name: 'master', project: project) } let(:merge_request) { create(:merge_request, :simple, source_project: project, target_branch: protected_branch.name) } @@ -15,11 +17,17 @@ RSpec.describe 'Merge request > User edits assignees sidebar', :js, feature_cate # DOM finders to simplify and improve readability let(:sidebar_assignee_block) { page.find('.js-issuable-sidebar .assignee') } - let(:sidebar_assignee_avatar_link) { sidebar_assignee_block.find_all('a').find { |a| a['href'].include? assignee.username } } + let(:sidebar_assignee_avatar_link) do + sidebar_assignee_block.find_all('a').find { |a| a['href'].include? assignee.username } + end + let(:sidebar_assignee_tooltip) { sidebar_assignee_avatar_link['title'] || '' } context 'when GraphQL assignees widget feature flag is disabled' do - let(:sidebar_assignee_dropdown_item) { sidebar_assignee_block.find(".dropdown-menu li[data-user-id=\"#{assignee.id}\"]") } + let(:sidebar_assignee_dropdown_item) do + sidebar_assignee_block.find(".dropdown-menu li[data-user-id=\"#{assignee.id}\"]") + end + let(:sidebar_assignee_dropdown_tooltip) { sidebar_assignee_dropdown_item.find('a')['data-title'] || '' } before do @@ -156,11 +164,13 @@ RSpec.describe 'Merge request > User edits assignees sidebar', :js, feature_cate expect(page).to have_link('Invite members') expect(page).to have_selector('[data-track-action="click_invite_members"]') expect(page).to have_selector('[data-track-label="edit_assignee"]') - end - click_link 'Invite members' + click_link 'Invite members' + end - expect(page).to have_content("You're inviting members to the") + page.within invite_modal_selector do + expect(page).to have_content("You're inviting members to the #{project.name} project") + end end end diff --git a/spec/features/merge_request/user_merges_immediately_spec.rb b/spec/features/merge_request/user_merges_immediately_spec.rb index 79c166434aa..d47968ebc6b 100644 --- a/spec/features/merge_request/user_merges_immediately_spec.rb +++ b/spec/features/merge_request/user_merges_immediately_spec.rb @@ -38,7 +38,7 @@ RSpec.describe 'Merge requests > User merges immediately', :js, feature_category end end - expect(find('.media-body h4')).to have_content('Merging!') + expect(find('[data-testid="merging-state"]')).to have_content('Merging!') wait_for_requests end diff --git a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb index c73ba1bdbe5..cdc00017ab3 100644 --- a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb +++ b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb @@ -57,7 +57,7 @@ RSpec.describe 'Merge request > User merges only if pipeline succeeds', :js, fea wait_for_requests expect(page).not_to have_button('Merge') - expect(page).to have_content('Merge blocked: pipeline must succeed. Push a commit that fixes the failure, or learn about other solutions.') + expect(page).to have_content('Merge blocked: pipeline must succeed. Push a commit that fixes the failure or learn about other solutions.') end end @@ -70,7 +70,7 @@ RSpec.describe 'Merge request > User merges only if pipeline succeeds', :js, fea wait_for_requests expect(page).not_to have_button 'Merge' - expect(page).to have_content('Merge blocked: pipeline must succeed. Push a commit that fixes the failure, or learn about other solutions.') + expect(page).to have_content('Merge blocked: pipeline must succeed. Push a commit that fixes the failure or learn about other solutions.') end end diff --git a/spec/features/merge_request/user_resolves_wip_mr_spec.rb b/spec/features/merge_request/user_resolves_wip_mr_spec.rb index 8a19a72f6ae..01cc6bd5167 100644 --- a/spec/features/merge_request/user_resolves_wip_mr_spec.rb +++ b/spec/features/merge_request/user_resolves_wip_mr_spec.rb @@ -33,7 +33,7 @@ RSpec.describe 'Merge request > User resolves Draft', :js, feature_category: :co it 'retains merge request data after clicking Resolve WIP status' do expect(page.find('.ci-widget-content')).to have_content("Pipeline ##{pipeline.id}") - expect(page).to have_content "Merge blocked: merge request must be marked as ready. It's still marked as draft." + expect(page).to have_content "Merge blocked: Select Mark as ready to remove it from Draft status." page.within('.mr-state-widget') do click_button('Mark as ready') @@ -45,7 +45,7 @@ RSpec.describe 'Merge request > User resolves Draft', :js, feature_category: :co # merge request widget refreshes, which masks missing elements # that should already be present. expect(page.find('.ci-widget-content', wait: 0)).to have_content("Pipeline ##{pipeline.id}") - expect(page).not_to have_content("Merge blocked: merge request must be marked as ready. It's still marked as draft.") + expect(page).not_to have_content("Merge blocked: Select Mark as ready to remove it from Draft status.") end end end diff --git a/spec/features/merge_request/user_sees_diff_spec.rb b/spec/features/merge_request/user_sees_diff_spec.rb index daeeaa1bd88..12fdcf4859e 100644 --- a/spec/features/merge_request/user_sees_diff_spec.rb +++ b/spec/features/merge_request/user_sees_diff_spec.rb @@ -32,7 +32,7 @@ RSpec.describe 'Merge request > User sees diff', :js, feature_category: :code_re visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}" end - it 'shows expanded note' do + it 'shows expanded note', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391239' do expect(page).to have_selector(fragment, visible: true) end end diff --git a/spec/features/merge_request/user_sees_discussions_navigation_spec.rb b/spec/features/merge_request/user_sees_discussions_navigation_spec.rb index 9d3046a9a72..6e6c2cddfbf 100644 --- a/spec/features/merge_request/user_sees_discussions_navigation_spec.rb +++ b/spec/features/merge_request/user_sees_discussions_navigation_spec.rb @@ -58,7 +58,7 @@ RSpec.describe 'Merge request > User sees discussions navigation', :js, feature_ expect(page).to have_selector(second_discussion_selector, obscured: false) end - it 'cycles back to the first thread' do + it 'cycles back to the first thread', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391604' do goto_next_thread goto_next_thread goto_next_thread @@ -92,7 +92,8 @@ RSpec.describe 'Merge request > User sees discussions navigation', :js, feature_ page.execute_script("window.scrollTo(0,0)") end - it 'excludes resolved threads during navigation' do + it 'excludes resolved threads during navigation', + quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/383687' do goto_next_thread goto_next_thread goto_next_thread diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb index 0297bb5b935..acf2893b513 100644 --- a/spec/features/merge_request/user_sees_merge_widget_spec.rb +++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb @@ -18,7 +18,6 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: end before do - stub_feature_flags(refactor_security_extension: false) project.add_maintainer(user) project_only_mwps.add_maintainer(user) sign_in(user) @@ -90,12 +89,12 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: click_button 'master' end - page.within("#{modal_selector} .dropdown-menu") do - find('[data-testid="dropdown-search-box"]').set('') + page.within("#{modal_selector} [data-testid=\"base-dropdown-menu\"]") do + fill_in 'Search branches', with: '' wait_for_requests - expect(page.all('[data-testid="dropdown-item"]').size).to be > 1 + expect(page).to have_selector('[data-testid="listbox-item-master"]', visible: true) end end end @@ -149,7 +148,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: click_button 'Merge unverified changes' end - expect(find('.media-body h4')).to have_content('Merging!') + expect(find('[data-testid="merging-state"]')).to have_content('Merging!') end end diff --git a/spec/features/merge_request/user_sees_wip_help_message_spec.rb b/spec/features/merge_request/user_sees_wip_help_message_spec.rb deleted file mode 100644 index fdefe5ffb06..00000000000 --- a/spec/features/merge_request/user_sees_wip_help_message_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Merge request > User sees draft help message', feature_category: :code_review_workflow do - let(:project) { create(:project, :public, :repository) } - let(:user) { project.creator } - - before do - project.add_maintainer(user) - sign_in(user) - end - - context 'with draft commits' do - it 'shows a specific draft hint' do - visit project_new_merge_request_path( - project, - merge_request: { - source_project_id: project.id, - target_project_id: project.id, - source_branch: 'wip', - target_branch: 'master' - }) - - within_wip_explanation do - expect(page).to have_text( - 'It looks like you have some draft commits in this branch' - ) - end - end - end - - context 'without draft commits' do - it 'shows the regular draft message' do - visit project_new_merge_request_path( - project, - merge_request: { - source_project_id: project.id, - target_project_id: project.id, - source_branch: 'fix', - target_branch: 'master' - }) - - within_wip_explanation do - expect(page).not_to have_text( - 'It looks like you have some draft commits in this branch' - ) - expect(page).to have_text( - "Start the title with Draft: to prevent a merge request draft \ -from merging before it's ready." - ) - end - end - end - - def within_wip_explanation(&block) - page.within '.js-no-wip-explanation' do - yield - end - end -end diff --git a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb index b7784de12b9..0de59ea21c5 100644 --- a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb +++ b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb @@ -3,13 +3,15 @@ require 'spec_helper' RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_category: :code_review_workflow do + include ListboxHelpers + let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } def select_source_branch(branch_name) find('.js-source-branch', match: :first).click - find('.js-source-branch-dropdown .dropdown-input-field').native.send_keys branch_name - find('.js-source-branch-dropdown .dropdown-content a', text: branch_name, match: :first).click + find('.gl-listbox-search-input').native.send_keys branch_name + select_listbox_item(branch_name) end before do @@ -27,7 +29,7 @@ RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_ expect(page).to have_content('Target branch') first('.js-source-branch').click - find('.js-source-branch-dropdown .dropdown-content a', match: :first).click + find('.gl-new-dropdown-item', match: :first).click expect(page).to have_content "b83d6e3" end @@ -43,7 +45,8 @@ RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_ expect(page).to have_content('Target branch') first('.js-target-branch').click - find('.js-target-branch-dropdown .dropdown-content a', text: 'v1.1.0', match: :first).click + find('.gl-listbox-search-input').native.send_keys 'v1.1.0' + select_listbox_item('v1.1.0') expect(page).to have_content "b83d6e3" end @@ -68,27 +71,6 @@ RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_ expect(page).to have_content 'git checkout -b \'orphaned-branch\' \'origin/orphaned-branch\'' end - it 'allows filtering multiple dropdowns' do - visit project_new_merge_request_path(project) - - first('.js-source-branch').click - - page.within '.js-source-branch-dropdown' do - input = find('.dropdown-input-field') - input.click - input.send_keys('orphaned-branch') - - expect(page).to have_css('.dropdown-content li', count: 1) - end - - first('.js-target-branch').click - - find('.js-target-branch-dropdown .dropdown-content li', match: :first) - target_items = all('.js-target-branch-dropdown .dropdown-content li') - - expect(target_items.count).to be > 1 - end - context 'when target project cannot be viewed by the current user' do it 'does not leak the private project name & namespace' do private_project = create(:project, :private, :repository) |