Commit 773989c6 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'test-57693-download-mr-patch-diffs' into 'master'

Add QA test to download merge request patch/diffs

See merge request gitlab-org/gitlab-ce!25451
parents d11b1126 a0c6d085
...@@ -135,7 +135,7 @@ export default { ...@@ -135,7 +135,7 @@ export default {
<span class="dropdown"> <span class="dropdown">
<button <button
type="button" type="button"
class="btn dropdown-toggle" class="btn dropdown-toggle qa-dropdown-toggle"
data-toggle="dropdown" data-toggle="dropdown"
aria-label="Download as" aria-label="Download as"
aria-haspopup="true" aria-haspopup="true"
...@@ -145,12 +145,20 @@ export default { ...@@ -145,12 +145,20 @@ export default {
</button> </button>
<ul class="dropdown-menu dropdown-menu-right"> <ul class="dropdown-menu dropdown-menu-right">
<li> <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') }} {{ s__('mrWidget|Email patches') }}
</a> </a>
</li> </li>
<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') }} {{ s__('mrWidget|Plain diff') }}
</a> </a>
</li> </li>
......
...@@ -157,6 +157,10 @@ module QA ...@@ -157,6 +157,10 @@ module QA
find('body').click find('body').click
end end
def visit_link_in_element(name)
visit find_element(name)['href']
end
def self.path def self.path
raise NotImplementedError raise NotImplementedError
end end
......
...@@ -27,6 +27,12 @@ module QA ...@@ -27,6 +27,12 @@ module QA
element :squash_checkbox element :squash_checkbox
end 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 view 'app/views/projects/merge_requests/show.html.haml' do
element :notes_tab element :notes_tab
element :diffs_tab element :diffs_tab
...@@ -159,6 +165,16 @@ module QA ...@@ -159,6 +165,16 @@ module QA
def edit! def edit!
click_element :edit_button click_element :edit_button
end 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 end
end end
......
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment