Commit 360976b9 authored by Tiffany Rea's avatar Tiffany Rea Committed by Sanad Liaquat

E2E discussion not dropping merge trains MR

(cherry picked from commit d20eef6250476c217fd796b557f67559bb50059e)
parent c5307cca
......@@ -21,6 +21,6 @@
.text-secondary
= s_('ProjectSettings|This introduces the risk of merging changes that will not pass the pipeline.')
.form-check.mb-2
= form.check_box :only_allow_merge_if_all_discussions_are_resolved, class: 'form-check-input'
= form.check_box :only_allow_merge_if_all_discussions_are_resolved, class: 'form-check-input', data: { qa_selector: 'allow_merge_if_all_discussions_are_resolved_checkbox' }
= form.label :only_allow_merge_if_all_discussions_are_resolved, class: 'form-check-label' do
= s_('ProjectSettings|All discussions must be resolved')
......@@ -23,6 +23,11 @@ module QA
def click_pipelines_for_merged_results_checkbox
check_element :merged_results_pipeline_checkbox
end
def enable_merge_train
click_pipelines_for_merged_results_checkbox
click_save_changes
end
end
end
end
......
......@@ -15,6 +15,10 @@ module QA
element :radio_button_merge_ff
end
view 'app/views/projects/_merge_request_merge_checks_settings.html.haml' do
element :allow_merge_if_all_discussions_are_resolved_checkbox
end
def click_save_changes
click_element :save_merge_request_changes
end
......@@ -23,6 +27,11 @@ module QA
click_element :radio_button_merge_ff
click_save_changes
end
def enable_merge_if_all_disscussions_are_resolved
click_element :allow_merge_if_all_discussions_are_resolved_checkbox
click_save_changes
end
end
end
end
......
# frozen_string_literal: true
require 'faker'
module QA
RSpec.describe 'Verify', :docker, :runner do
describe 'In merge trains' do
context 'new thread discussion' do
let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
let!(:runner) do
Resource::Runner.fabricate! do |runner|
runner.project = project
runner.name = executor
runner.tags = [executor]
end
end
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'pipeline-for-merge-trains'
end
end
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.description = Faker::Lorem.sentence
merge_request.target_new_branch = false
merge_request.file_name = 'custom_file.txt'
merge_request.file_content = Faker::Lorem.sentence
end
end
before do
Flow::Login.sign_in
project.visit!
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform(&:expand_merge_requests_settings)
Page::Project::Settings::MergeRequest.perform do |setting|
setting.enable_merge_train
setting.enable_merge_if_all_disscussions_are_resolved
end
commit_ci_file
merge_request.visit!
Page::MergeRequest::Show.perform do |show|
show.has_pipeline_status?('passed')
show.try_to_merge!
end
end
after do
runner.remove_via_api!
end
it 'does not drop MR', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1010' do
start_discussion
Page::MergeRequest::Show.perform do |show|
show.has_pipeline_status?('passed')
expect(show).to be_merged
end
end
private
def commit_ci_file
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files(
[
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
test_merge_train:
tags:
- #{executor}
script: echo 'OK!'
only:
- merge_requests
YAML
}
]
)
end
end
def start_discussion
Page::MergeRequest::Show.perform do |show|
show.wait_until(reload: false) do
show.has_content? 'started a merge train'
end
show.click_discussions_tab
show.start_discussion(Faker::Lorem.sentence)
end
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