Commit c356451a authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'ml-add-merge-trains-test' into 'master'

Add E2E test of merge trains

Closes gitlab-org/quality/testcases#204

See merge request gitlab-org/gitlab!17873
parents 613716b3 0c4d284a
......@@ -161,6 +161,12 @@ module QA
approvals_content.match(/Requires (\d+) more approvals/)[1].to_i
end
def merge_via_merge_train
raise ElementNotFound, "Not ready to merge" unless ready_to_merge?
click_element(:merge_button, text: "Start merge train")
end
private
def approvals_content
......
......@@ -129,17 +129,7 @@ module QA
end
def try_to_merge!
# The merge button is disabled on load
wait do
has_element?(:merge_button)
end
# The merge button is enabled via JS
wait(reload: false) do
!find_element(:merge_button).disabled?
end
merge_immediately
merge_immediately if ready_to_merge?
end
def merge!
......@@ -187,6 +177,18 @@ module QA
click_element :edit_button
end
def ready_to_merge?
# The merge button is disabled on load
wait do
has_element?(:merge_button)
end
# The merge button is enabled via JS
wait(reload: false) do
!find_element(:merge_button).disabled?
end
end
def view_email_patches
click_element :dropdown_toggle
visit_link_in_element(:download_email_patches)
......
......@@ -2,23 +2,21 @@
module QA
context 'Release', :docker do
describe 'Pipelines for merged results' do
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'pipelines-for-merged-results'
describe 'Pipelines for merged results and merge trains' do
before(:context) do
@project = Resource::Project.fabricate_via_api! do |project|
project.name = 'pipelines-for-merged-results-and-merge-trains'
end
end
let(:executor) { "qa-runner-#{Time.now.to_i}" }
@executor = "qa-runner-#{Time.now.to_i}"
before do
Resource::Runner.fabricate_via_api! do |runner|
runner.project = project
runner.name = executor
runner.project = @project
runner.name = @executor
runner.tags = %w[qa test]
end
Resource::Repository::ProjectPush.fabricate! do |project_push|
project_push.project = project
project_push.project = @project
project_push.file_name = '.gitlab-ci.yml'
project_push.commit_message = 'Add .gitlab-ci.yml'
project_push.file_content = <<~EOF
......@@ -28,42 +26,88 @@ module QA
- merge_requests
EOF
end
end
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
end
after do
Service::Runner.new(executor).remove!
end
it 'creates a pipeline with merged results' do
project.visit!
@project.visit!
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform do |main|
main.expand_merge_requests_settings do |settings|
settings.click_pipelines_for_merged_results_checkbox
settings.click_save_changes
end
end
end
after(:context) do
Service::Runner.new(@executor).remove!
end
it 'creates a pipeline with merged results' do
# Create a branch that will be merged into master
Resource::Repository::ProjectPush.fabricate! do |project_push|
project_push.project = @project
project_push.new_branch = true
project_push.branch_name = 'merged-results'
end
# Create a merge request to merge the branch we just created
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.target_new_branch = false
merge_request.project = @project
merge_request.source_branch = 'merged-results'
merge_request.no_preparation = true
end.visit!
Page::MergeRequest::Show.perform do |merge_request|
expect(merge_request).to have_pipeline_status(/Merged result pipeline #\d+ passed/)
Page::MergeRequest::Show.perform do |show|
expect(show).to have_pipeline_status(/Merged result pipeline #\d+ passed/)
# The default option is to merge via merge train,
# but that will be covered by another test
merge_request.merge_immediately
show.merge_immediately
end
expect(page).to have_content('The changes were merged')
end
it 'merges via a merge train' do
# Create a branch that will be merged into master
Resource::Repository::ProjectPush.fabricate! do |project_push|
project_push.project = @project
project_push.new_branch = true
project_push.branch_name = 'merge-train'
project_push.file_name = "another_file.txt"
project_push.file_content = "merge me"
end
# Create a merge request to merge the branch we just created
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = @project
merge_request.source_branch = 'merge-train'
merge_request.no_preparation = true
end.visit!
Page::MergeRequest::Show.perform do |show|
expect(show).to have_pipeline_status(/Merged result pipeline #\d+ passed/)
show.merge_via_merge_train
end
expect(page).to have_content('Added to the merge train')
expect(page).to have_content('The changes will be merged into master')
# It's faster to refresh the page than to wait for the UI to
# automatically refresh, so we reload if the merge status
# doesn't update quickly.
merged = Support::Retrier.retry_until(reload_page: page) do
page.has_content?('The changes were merged')
end
expect(merged).to be_truthy, "Expected content 'The changes were merged' but it did not appear."
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