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

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 {
<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>
......
......@@ -157,6 +157,10 @@ def click_body
find('body').click
end
def visit_link_in_element(name)
visit find_element(name)['href']
end
def self.path
raise NotImplementedError
end
......
......@@ -27,6 +27,12 @@ class Show < Page::Base
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 @@ def add_comment_to_diff(text)
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
......
# 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