Commit 8c70f4c2 authored by Tomislav Nikić's avatar Tomislav Nikić Committed by Mark Lapierre

Suggestions on a Merge Request | E2E & Cleanup

parent c624b1e0
......@@ -34,6 +34,7 @@ export default {
boundary="window"
right
menu-class="gl-w-full!"
data-qa-selector="apply_suggestion_button"
@shown="$refs.commitMessage.$el.focus()"
>
<gl-dropdown-form class="gl-px-4! gl-m-0!">
......@@ -44,12 +45,14 @@ export default {
v-model="message"
:placeholder="defaultCommitMessage"
submit-on-enter
data-qa-selector="commit_message_textbox"
@submit="onApply"
/>
<gl-button
class="gl-w-auto! gl-mt-3 gl-text-center! gl-hover-text-white! gl-transition-medium! float-right"
category="primary"
variant="success"
data-qa-selector="commit_with_custom_message_button"
@click="onApply"
>
{{ __('Apply') }}
......
......@@ -28,7 +28,7 @@
= _("Overview")
%span.badge.badge-pill= @merge_request.related_notes.user.count
- if @merge_request.source_project
= render "projects/merge_requests/tabs/tab", name: "commits", class: "commits-tab" do
= render "projects/merge_requests/tabs/tab", name: "commits", class: "commits-tab", qa_selector: "commits_tab" do
= tab_link_for @merge_request, :commits do
= _("Commits")
%span.badge.badge-pill= @commits_count
......
......@@ -49,6 +49,7 @@ module QA
view 'app/views/projects/merge_requests/show.html.haml' do
element :notes_tab
element :commits_tab
element :diffs_tab
end
......@@ -111,6 +112,12 @@ module QA
element :cherry_pick_button
end
view 'app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue' do
element :apply_suggestion_button
element :commit_message_textbox
element :commit_with_custom_message_button
end
def start_review
click_element(:start_review_button)
......@@ -177,6 +184,10 @@ module QA
wait_for_requests
end
def click_commits_tab
click_element(:commits_tab)
end
def click_diffs_tab
click_element(:diffs_tab)
click_element(:dismiss_popover_button) if has_element?(:dismiss_popover_button, wait: 1)
......@@ -356,6 +367,12 @@ module QA
click_element(:comment_now_button)
end
def apply_suggestion_with_message(message)
click_element(:apply_suggestion_button)
fill_element(:commit_message_textbox, message)
click_element(:commit_with_custom_message_button)
end
def add_suggestion_to_batch
all_elements(:add_suggestion_batch_button, minimum: 1).first.click
end
......
......@@ -2,25 +2,23 @@
module QA
RSpec.describe 'Create' do
context 'Transient tests', :transient do
context 'Add batch suggestions to a Merge Request', :transient do
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-for-transient-test'
project.name = 'suggestions_project'
end
end
let(:code_for_merge) do
Pathname
.new(__dir__)
.join('../../../../../fixtures/metrics_dashboards/templating.yml')
end
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.title = 'Transient MR'
merge_request.description = 'detecting transient bugs'
merge_request.file_content = File.read(code_for_merge)
merge_request.title = 'Needs some suggestions'
merge_request.description = '... so please add them.'
merge_request.file_content = File.read(
Pathname
.new(__dir__)
.join('../../../../../../fixtures/metrics_dashboards/templating.yml')
)
end
end
......@@ -30,6 +28,7 @@ module QA
before do
project.add_member(dev_user)
Flow::Login.sign_in(as: dev_user, skip_page_validation: true)
merge_request.visit!
......@@ -38,7 +37,7 @@ module QA
[4, 6, 10, 13].each do |line_number|
Page::MergeRequest::Show.perform do |merge_request|
merge_request.add_suggestion_to_diff("This is the #{line_number} suggestion!", line_number)
merge_request.add_suggestion_to_diff("This is the suggestion for line number #{line_number}!", line_number)
end
end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
context 'Add suggestions to a Merge Request' do
let(:commit_message) { 'Applying suggested change for testing purposes.' }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'suggestions_project'
end
end
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.title = 'Needs some suggestions'
merge_request.description = '... so please add them.'
merge_request.file_content = File.read(
Pathname
.new(__dir__)
.join('../../../../../../fixtures/metrics_dashboards/templating.yml')
)
end
end
let(:dev_user) do
Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
end
before do
project.add_member(dev_user)
Flow::Login.sign_in(as: dev_user, skip_page_validation: true)
merge_request.visit!
Page::MergeRequest::Show.perform do |merge_request|
merge_request.click_diffs_tab
merge_request.add_suggestion_to_diff('This is the suggestion for line number 4!', 4)
end
Flow::Login.sign_in
merge_request.visit!
end
it 'applies a single suggestion with a custom message' do
Page::MergeRequest::Show.perform do |merge_request|
merge_request.click_diffs_tab
merge_request.apply_suggestion_with_message(commit_message)
expect(merge_request).to have_css('.badge-success', text: 'Applied')
merge_request.click_commits_tab
expect(merge_request).to have_content(commit_message)
end
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