Commit 72b234ba authored by Dan Davison's avatar Dan Davison

Merge branch 'ml-add-e2e-test-of-pipelines-for-merged-results' into 'master'

Add E2E test of pipelines for merged results

Closes gitlab-org/quality/testcases#203

See merge request gitlab-org/gitlab!17321
parents 8132d4b2 e7d6a494
......@@ -110,7 +110,10 @@ export default {
<div class="ci-widget-container d-flex">
<div class="ci-widget-content">
<div class="media-body">
<div class="font-weight-bold js-pipeline-info-container">
<div
class="font-weight-bold js-pipeline-info-container"
data-qa-selector="merge_request_pipeline_info_content"
>
{{ pipeline.details.name }}
<gl-link :href="pipeline.path" class="pipeline-id font-weight-normal pipeline-number"
>#{{ pipeline.id }}</gl-link
......
- return unless merge_pipelines_available?
.form-check.builds-feature
= form.check_box :merge_pipelines_enabled, class: 'form-check-input js-merge-options-merge-pipelines'
= form.check_box :merge_pipelines_enabled, class: 'form-check-input js-merge-options-merge-pipelines', data: { qa_selector: 'merged_results_pipeline_checkbox' }
= form.label :merge_pipelines_enabled, class: 'form-check-label' do
= s_('ProjectSettings|Merge pipelines will try to validate the post-merge result prior to merging')
.text-secondary.mb-2
......
......@@ -114,6 +114,7 @@ module QA
autoload :ProtectedBranches, 'qa/ee/page/project/settings/protected_branches'
autoload :MirroringRepositories, 'qa/ee/page/project/settings/mirroring_repositories'
autoload :Main, 'qa/ee/page/project/settings/main'
autoload :MergeRequest, 'qa/ee/page/project/settings/merge_request'
autoload :MergeRequestApproval, 'qa/ee/page/project/settings/merge_request_approval'
autoload :Repository, 'qa/ee/page/project/settings/repository'
autoload :PushRules, 'qa/ee/page/project/settings/push_rules'
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Settings
module MergeRequest
def self.prepended(page)
page.module_eval do
view 'ee/app/views/projects/_merge_pipelines_settings.html.haml' do
element :merged_results_pipeline_checkbox
end
end
end
def click_pipelines_for_merged_results_checkbox
check_element :merged_results_pipeline_checkbox
end
end
end
end
end
end
end
......@@ -6,6 +6,16 @@ module QA
class Show < Page::Base
include Page::Component::Note
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/assets/javascripts/vue_merge_request_widget/components/mr_widget_pipeline.vue' do
element :merge_request_pipeline_info_content
end
view 'app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue' do
element :merge_button
element :fast_forward_message, 'Fast-forward merge without a merge commit' # rubocop:disable QA/ElementWithPattern
......@@ -27,12 +37,6 @@ module QA
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
......@@ -111,6 +115,11 @@ module QA
end
end
def has_pipeline_status?(text)
# Pipelines can be slow, so we wait a bit longer than the usual 10 seconds
has_element?(:merge_request_pipeline_info_content, text: text, wait: 30)
end
def has_title?(title)
has_element?(:title, text: title)
end
......
......@@ -11,6 +11,7 @@ module QA
view 'app/views/projects/edit.html.haml' do
element :advanced_settings
element :merge_request_settings
end
view 'app/views/projects/settings/_general.html.haml' do
......@@ -41,6 +42,12 @@ module QA
end
end
def expand_merge_requests_settings(&block)
expand_section(:merge_request_settings) do
MergeRequest.perform(&block)
end
end
def expand_visibility_project_features_permissions(&block)
expand_section(:visibility_features_permissions_content) do
VisibilityFeaturesPermissions.perform(&block)
......
......@@ -8,7 +8,6 @@ module QA
include Common
view 'app/views/projects/edit.html.haml' do
element :merge_request_settings
element :save_merge_request_changes
end
......@@ -16,14 +15,18 @@ module QA
element :radio_button_merge_ff
end
def click_save_changes
click_element :save_merge_request_changes
end
def enable_ff_only
expand_section(:merge_request_settings) do
click_element :radio_button_merge_ff
click_element :save_merge_request_changes
end
click_element :radio_button_merge_ff
click_save_changes
end
end
end
end
end
end
QA::Page::Project::Settings::MergeRequest.prepend_if_ee("QA::EE::Page::Project::Settings::MergeRequest")
......@@ -13,8 +13,12 @@ module QA
end
project.visit!
Page::Project::Menu.perform(&:click_settings)
Page::Project::Settings::MergeRequest.perform(&:enable_ff_only)
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform do |main|
main.expand_merge_requests_settings do |settings|
settings.enable_ff_only
end
end
merge_request = Resource::MergeRequest.fabricate! do |merge_request|
merge_request.project = project
......
# frozen_string_literal: true
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'
end
end
let(:executor) { "qa-runner-#{Time.now.to_i}" }
before do
Resource::Runner.fabricate_via_api! do |runner|
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.file_name = '.gitlab-ci.yml'
project_push.commit_message = 'Add .gitlab-ci.yml'
project_push.file_content = <<~EOF
test:
script: echo 'OK'
only:
- merge_requests
EOF
end
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!
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
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.target_new_branch = false
end.visit!
Page::MergeRequest::Show.perform do |merge_request|
expect(merge_request).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
end
expect(page).to have_content('The changes were merged')
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