diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 12:10:14 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 12:10:14 +0000 |
commit | a27b8a5c104f492e4b0abac4c84385a615c4f6ba (patch) | |
tree | 3ec1a2cc06312b1999ce405905ab7881f68927d2 /qa | |
parent | 635d82b15d83a88a2d073fbf3bb56f6ff626020f (diff) | |
download | gitlab-ce-a27b8a5c104f492e4b0abac4c84385a615c4f6ba.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/page/merge_request/show.rb | 60 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_merge_ref_diff_spec.rb | 80 |
2 files changed, 122 insertions, 18 deletions
diff --git a/qa/qa/page/merge_request/show.rb b/qa/qa/page/merge_request/show.rb index 08796de7d73..c884b10b597 100644 --- a/qa/qa/page/merge_request/show.rb +++ b/qa/qa/page/merge_request/show.rb @@ -49,6 +49,18 @@ module QA element :diffs_tab end + view 'app/assets/javascripts/diffs/components/compare_dropdown_layout.vue' do + element :dropdown_content + end + + view 'app/assets/javascripts/diffs/components/compare_versions.vue' do + element :target_version_dropdown + end + + view 'app/assets/javascripts/diffs/components/diff_file_header.vue' do + element :file_name_content + end + view 'app/assets/javascripts/diffs/components/inline_diff_table_row.vue' do element :new_diff_line end @@ -79,46 +91,54 @@ module QA end def start_review - click_element :start_review_button + click_element(:start_review_button) # After clicking the button, wait for it to disappear # before moving on to the next part of the test - has_no_element? :start_review_button + has_no_element?(:start_review_button) + end + + def click_target_version_dropdown + click_element(:target_version_dropdown) end def comment_now - click_element :comment_now_button + click_element(:comment_now_button) # After clicking the button, wait for it to disappear # before moving on to the next part of the test - has_no_element? :comment_now_button + has_no_element?(:comment_now_button) + end + + def version_dropdown_content + find_element(:dropdown_content).text end def submit_pending_reviews - within_element :review_bar do - click_element :review_preview_toggle - click_element :submit_review + within_element(:review_bar) do + click_element(:review_preview_toggle) + click_element(:submit_review) # After clicking the button, wait for it to disappear # before moving on to the next part of the test - has_no_element? :submit_review + has_no_element?(:submit_review) end end def discard_pending_reviews - within_element :review_bar do - click_element :discard_review + within_element(:review_bar) do + click_element(:discard_review) end - click_element :modal_delete_pending_comments + click_element(:modal_delete_pending_comments) end def resolve_review_discussion - scroll_to_element :start_review_button - check_element :resolve_review_discussion_checkbox + scroll_to_element(:start_review_button) + check_element(:resolve_review_discussion_checkbox) end def unresolve_review_discussion - check_element :unresolve_review_discussion_checkbox + check_element(:unresolve_review_discussion_checkbox) end def add_comment_to_diff(text) @@ -156,6 +176,10 @@ module QA has_no_text?('Fast-forward merge is not possible') end + def has_file?(file_name) + has_element?(:file_name_content, text: file_name) + end + def has_merge_button? refresh @@ -186,7 +210,7 @@ module QA !find_element(:squash_checkbox).disabled? end - click_element :squash_checkbox + click_element(:squash_checkbox) end def merge! @@ -231,7 +255,7 @@ module QA !find_element(:mr_rebase_button).disabled? end - click_element :mr_rebase_button + click_element(:mr_rebase_button) success = wait_until do has_text?('Fast-forward merge without a merge commit') @@ -247,12 +271,12 @@ module QA end def view_email_patches - click_element :download_dropdown + click_element(:download_dropdown) visit_link_in_element(:download_email_patches) end def view_plain_diff - click_element :download_dropdown + click_element(:download_dropdown) visit_link_in_element(:download_plain_diff) end diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_merge_ref_diff_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_merge_ref_diff_spec.rb new file mode 100644 index 00000000000..ab675f517db --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_merge_ref_diff_spec.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'View merge request merge-ref diff' do + let(:merge_request) do + Resource::MergeRequest.fabricate_via_api! do |merge_request| + merge_request.title = 'This is a merge request' + merge_request.description = '... for viewing merge-ref and merge-base diffs' + merge_request.file_content = 'This exists on the source branch only' + end + end + + let(:new_file_name) { "added_file-#{SecureRandom.hex(8)}.txt" } + + before do + commit_to_branch(merge_request.target_branch, new_file_name) + commit_to_branch(merge_request.source_branch, new_file_name) + + Flow::Login.sign_in + end + + context 'when the feature flag default_merge_ref_for_diffs is enabled' do + before do + Runtime::Feature.enable('default_merge_ref_for_diffs', project: merge_request.project) + + merge_request.visit! + end + + it 'views the merge-ref diff by default' do + Page::MergeRequest::Show.perform do |mr_page| + mr_page.click_diffs_tab + mr_page.click_target_version_dropdown + + expect(mr_page.version_dropdown_content).to include('master (HEAD)') + expect(mr_page.version_dropdown_content).not_to include('master (base)') + expect(mr_page).to have_file(merge_request.file_name) + expect(mr_page).not_to have_file(new_file_name) + end + end + end + + context 'when the feature flag default_merge_ref_for_diffs is disabled' do + before do + Runtime::Feature.disable('default_merge_ref_for_diffs', project: merge_request.project) + + merge_request.visit! + end + + it 'views the merge-base diff by default' do + Page::MergeRequest::Show.perform do |mr_page| + mr_page.click_diffs_tab + mr_page.click_target_version_dropdown + + expect(mr_page.version_dropdown_content).to include('master (HEAD)') + expect(mr_page.version_dropdown_content).to include('master (base)') + expect(mr_page).to have_file(merge_request.file_name) + expect(mr_page).to have_file(new_file_name) + end + end + end + + def commit_to_branch(branch, file) + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = merge_request.project + commit.branch = branch + commit.commit_message = "Add new file on #{branch}" + commit.add_files( + [ + { + file_path: file, + content: "This exists on source and target branches" + } + ] + ) + end + end + end + end +end |