Commit 207d0d1c authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'transient-test-suite' into 'master'

Add apply suggestion transient test

See merge request gitlab-org/gitlab!50454
parents e4225bca 28dc5d00
...@@ -172,6 +172,7 @@ export default { ...@@ -172,6 +172,7 @@ export default {
:cursor-offset="4" :cursor-offset="4"
:tag-content="lineContent" :tag-content="lineContent"
icon="doc-code" icon="doc-code"
data-qa-selector="suggestion_button"
class="js-suggestion-btn" class="js-suggestion-btn"
@click="handleSuggestDismissed" @click="handleSuggestDismissed"
/> />
......
...@@ -131,6 +131,7 @@ export default { ...@@ -131,6 +131,7 @@ export default {
<gl-button <gl-button
v-gl-tooltip.viewport="__('This also resolves all related threads')" v-gl-tooltip.viewport="__('This also resolves all related threads')"
class="btn-inverted js-apply-batch-btn btn-grouped" class="btn-inverted js-apply-batch-btn btn-grouped"
data-qa-selector="apply_suggestions_batch_button"
:disabled="isApplying" :disabled="isApplying"
variant="success" variant="success"
@click="applySuggestionBatch" @click="applySuggestionBatch"
...@@ -145,6 +146,7 @@ export default { ...@@ -145,6 +146,7 @@ export default {
<gl-button <gl-button
v-if="suggestionsCount > 1 && canBeBatched && !isDisableButton" v-if="suggestionsCount > 1 && canBeBatched && !isDisableButton"
class="btn-inverted js-add-to-batch-btn btn-grouped" class="btn-inverted js-add-to-batch-btn btn-grouped"
data-qa-selector="add_suggestion_batch_button"
:disabled="isDisableButton" :disabled="isDisableButton"
@click="addSuggestionToBatch" @click="addSuggestionToBatch"
> >
......
...@@ -90,6 +90,15 @@ module QA ...@@ -90,6 +90,15 @@ module QA
element :review_preview_toggle element :review_preview_toggle
end end
view 'app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue' do
element :apply_suggestions_batch_button
element :add_suggestion_batch_button
end
view 'app/assets/javascripts/vue_shared/components/markdown/header.vue' do
element :suggestion_button
end
def start_review def start_review
click_element(:start_review_button) click_element(:start_review_button)
...@@ -306,6 +315,24 @@ module QA ...@@ -306,6 +315,24 @@ module QA
click_element(:edit_in_ide_button) click_element(:edit_in_ide_button)
end end
end end
def add_suggestion_to_diff(suggestion, line)
find("a[data-linenumber='#{line}']").hover
click_element(:diff_comment)
click_element(:suggestion_button)
initial_content = find_element(:reply_field).value
fill_element(:reply_field, '')
fill_element(:reply_field, initial_content.gsub(/(```suggestion:-0\+0\n).*(\n```)/, "\\1#{suggestion}\\2"))
click_element(:comment_now_button)
end
def add_suggestion_to_batch
all_elements(:add_suggestion_batch_button, minimum: 1).first.click
end
def apply_suggestions_batch
all_elements(:apply_suggestions_batch_button, minimum: 1).first.click
end
end end
end end
end end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
context 'Transient tests', :transient do
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-for-transient-test'
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)
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(&:click_diffs_tab)
[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)
end
end
Flow::Login.sign_in
merge_request.visit!
end
it 'applies multiple suggestions', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1177' do
Page::MergeRequest::Show.perform do |merge_request|
merge_request.click_diffs_tab
4.times { merge_request.add_suggestion_to_batch }
merge_request.apply_suggestions_batch
expect(merge_request).to have_css('.badge-success', text: "Applied", count: 4)
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