diff options
author | Linda Dai <3424400-lindai@users.noreply.gitlab.com> | 2019-03-06 01:47:01 +0300 |
---|---|---|
committer | Mark Lapierre <mlapierre@gitlab.com> | 2019-03-06 01:47:01 +0300 |
commit | a0c6d085d7838d36f0e65d33841c0ad32b8ce4e2 (patch) | |
tree | 4a8ea3b278c5ebbffa15cc6db7751cdb005317b0 | |
parent | d11b112664db578327d028cb4552f408e89222d0 (diff) |
Add QA test to download merge request patch/diffs
-rw-r--r-- | app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue | 14 | ||||
-rw-r--r-- | qa/qa/page/base.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/merge_request/show.rb | 16 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb | 34 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb (renamed from qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb) | 0 |
5 files changed, 65 insertions, 3 deletions
diff --git a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue index 3b9fc2661ef..50ab7ead582 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue @@ -135,7 +135,7 @@ export default { <span class="dropdown"> <button type="button" - class="btn dropdown-toggle" + class="btn dropdown-toggle qa-dropdown-toggle" data-toggle="dropdown" aria-label="Download as" aria-haspopup="true" @@ -145,12 +145,20 @@ export default { </button> <ul class="dropdown-menu dropdown-menu-right"> <li> - <a :href="mr.emailPatchesPath" class="js-download-email-patches" download> + <a + :href="mr.emailPatchesPath" + class="js-download-email-patches qa-download-email-patches" + download + > {{ s__('mrWidget|Email patches') }} </a> </li> <li> - <a :href="mr.plainDiffPath" class="js-download-plain-diff" download> + <a + :href="mr.plainDiffPath" + class="js-download-plain-diff qa-download-plain-diff" + download + > {{ s__('mrWidget|Plain diff') }} </a> </li> diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index 11ebd70292e..9fabf83e2ce 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -157,6 +157,10 @@ module QA find('body').click end + def visit_link_in_element(name) + visit find_element(name)['href'] + end + def self.path raise NotImplementedError end diff --git a/qa/qa/page/merge_request/show.rb b/qa/qa/page/merge_request/show.rb index 976e431186d..c0411db6505 100644 --- a/qa/qa/page/merge_request/show.rb +++ b/qa/qa/page/merge_request/show.rb @@ -27,6 +27,12 @@ module QA element :squash_checkbox end + view 'app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue' do + element :dropdown_toggle + element :download_email_patches + element :download_plain_diff + end + view 'app/views/projects/merge_requests/show.html.haml' do element :notes_tab element :diffs_tab @@ -159,6 +165,16 @@ module QA def edit! click_element :edit_button end + + def view_email_patches + click_element :dropdown_toggle + visit_link_in_element(:download_email_patches) + end + + def view_plain_diff + click_element :dropdown_toggle + visit_link_in_element(:download_plain_diff) + end end end end diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb new file mode 100644 index 00000000000..9e48ee7ca2a --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module QA + context 'Create' do + describe 'Download merge request patch and diff' do + before(:context) do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.perform(&:sign_in_using_credentials) + + @merge_request = Resource::MergeRequest.fabricate! do |merge_request| + merge_request.title = 'This is a merge request' + merge_request.description = 'For downloading patches and diffs' + end + end + + it 'user views merge request email patches' do + @merge_request.visit! + Page::MergeRequest::Show.perform(&:view_email_patches) + + expect(page.text).to start_with('From') + expect(page).to have_content('Subject: [PATCH] This is a test commit') + expect(page).to have_content('diff --git a/added_file.txt b/added_file.txt') + end + + it 'user views merge request plain diff' do + @merge_request.visit! + Page::MergeRequest::Show.perform(&:view_plain_diff) + + expect(page.text).to start_with('diff --git a/added_file.txt b/added_file.txt') + expect(page).to have_content('+File Added') + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb index b862a7bd1ed..b862a7bd1ed 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb |