Commit ced47ed4 authored by Desiree Chevalier's avatar Desiree Chevalier

Add e2e test for default mr templates

Adds an e2e test for default mr templates and updates qa selectors.
parent 2a366afb
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
= s_('ProjectSettings|When conflicts arise the user is given the option to rebase') = s_('ProjectSettings|When conflicts arise the user is given the option to rebase')
.form-check.mb-2 .form-check.mb-2
= form.radio_button :merge_method, :ff, class: "js-merge-method-radio qa-radio-button-merge-ff form-check-input" = form.radio_button :merge_method, :ff, class: "js-merge-method-radio form-check-input", data: { qa_selector: 'merge_ff_radio_button' }
= label_tag :project_merge_method_ff, class: 'form-check-label' do = label_tag :project_merge_method_ff, class: 'form-check-label' do
= s_('ProjectSettings|Fast-forward merge') = s_('ProjectSettings|Fast-forward merge')
.text-secondary .text-secondary
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
= render "visibility_modal" = render "visibility_modal"
= f.submit _('Save changes'), class: "btn gl-button btn-success #{('js-confirm-danger' if show_visibility_confirm_modal?(@project))}", data: { qa_selector: 'visibility_features_permissions_save_button', check_field_name: ("project[visibility_level]" if show_visibility_confirm_modal?(@project)), check_compare_value: @project.visibility_level } = f.submit _('Save changes'), class: "btn gl-button btn-success #{('js-confirm-danger' if show_visibility_confirm_modal?(@project))}", data: { qa_selector: 'visibility_features_permissions_save_button', check_field_name: ("project[visibility_level]" if show_visibility_confirm_modal?(@project)), check_compare_value: @project.visibility_level }
%section.qa-merge-request-settings.rspec-merge-request-settings.settings.merge-requests-feature.no-animate#js-merge-request-settings{ class: [('expanded' if expanded), ('hidden' if @project.project_feature.send(:merge_requests_access_level) == 0)] } %section.rspec-merge-request-settings.settings.merge-requests-feature.no-animate#js-merge-request-settings{ class: [('expanded' if expanded), ('hidden' if @project.project_feature.send(:merge_requests_access_level) == 0)], data: { qa_selector: 'merge_request_settings_content' } }
.settings-header .settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Merge requests') %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Merge requests')
%button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _('Collapse') : _('Expand') %button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _('Collapse') : _('Expand')
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
= form_for @project, remote: true, html: { multipart: true, class: "merge-request-settings-form js-mr-settings-form" }, authenticity_token: true do |f| = form_for @project, remote: true, html: { multipart: true, class: "merge-request-settings-form js-mr-settings-form" }, authenticity_token: true do |f|
%input{ name: 'update_section', type: 'hidden', value: 'js-merge-request-settings' } %input{ name: 'update_section', type: 'hidden', value: 'js-merge-request-settings' }
= render 'projects/merge_request_settings', form: f = render 'projects/merge_request_settings', form: f
= f.submit _('Save changes'), class: "btn gl-button btn-success qa-save-merge-request-changes rspec-save-merge-request-changes" = f.submit _('Save changes'), class: "btn gl-button btn-success rspec-save-merge-request-changes", data: { qa_selector: 'save_merge_request_changes_button' }
= render_if_exists 'projects/merge_request_approvals_settings', expanded: expanded = render_if_exists 'projects/merge_request_approvals_settings', expanded: expanded
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
= render 'projects/service_desk_settings' = render 'projects/service_desk_settings'
%section.qa-advanced-settings.settings.advanced-settings.no-animate#js-project-advanced-settings{ class: ('expanded' if expanded) } %section.settings.advanced-settings.no-animate#js-project-advanced-settings{ class: ('expanded' if expanded), data: { qa_selector: 'advanced_settings_content' } }
.settings-header .settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Advanced') %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Advanced')
%button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _('Collapse') : _('Expand') %button.btn.gl-button.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _('Collapse') : _('Expand')
...@@ -96,8 +96,8 @@ ...@@ -96,8 +96,8 @@
.input-group-prepend .input-group-prepend
.input-group-text .input-group-text
#{Gitlab::Utils.append_path(root_url, @project.namespace.full_path)}/ #{Gitlab::Utils.append_path(root_url, @project.namespace.full_path)}/
= f.text_field :path, class: 'form-control qa-project-path-field h-auto' = f.text_field :path, class: 'form-control h-auto', data: { qa_selector: 'project_path_field' }
= f.submit _('Change path'), class: "gl-button btn btn-warning qa-change-path-button" = f.submit _('Change path'), class: "gl-button btn btn-warning", data: { qa_selector: 'change_path_button' }
= render 'transfer', project: @project = render 'transfer', project: @project
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
.form-group.col-md-5 .form-group.col-md-5
= f.label :name, class: 'label-bold', for: 'project_name_edit' do = f.label :name, class: 'label-bold', for: 'project_name_edit' do
= _('Project name') = _('Project name')
= f.text_field :name, class: 'form-control gl-form-input qa-project-name-field', id: "project_name_edit" = f.text_field :name, class: 'form-control gl-form-input', id: "project_name_edit", data: { qa_selector: 'project_name_field' }
.form-group.col-md-7 .form-group.col-md-7
= f.label :id, class: 'label-bold' do = f.label :id, class: 'label-bold' do
...@@ -40,4 +40,4 @@ ...@@ -40,4 +40,4 @@
%hr %hr
= link_to _('Remove avatar'), project_avatar_path(@project), data: { confirm: _('Avatar will be removed. Are you sure?')}, method: :delete, class: 'btn btn-link' = link_to _('Remove avatar'), project_avatar_path(@project), data: { confirm: _('Avatar will be removed. Are you sure?')}, method: :delete, class: 'btn btn-link'
= f.submit _('Save changes'), class: "gl-button btn btn-success gl-mt-6 qa-save-naming-topics-avatar-button" = f.submit _('Save changes'), class: "gl-button btn btn-success gl-mt-6", data: { qa_selector: 'save_naming_topics_avatar_button' }
- return unless @project.feature_available?(:merge_requests, current_user) - return unless @project.feature_available?(:merge_requests, current_user)
- return unless @project.feature_available?(:merge_request_approvers, current_user) - return unless @project.feature_available?(:merge_request_approvers, current_user)
%section.settings.merge-requests-feature.no-animate#js-merge-request-approval-settings{ class: [('expanded' if expanded)], data: { qa_selector: 'merge_request_approvals_settings' } } %section.settings.merge-requests-feature.no-animate#js-merge-request-approval-settings{ class: [('expanded' if expanded)], data: { qa_selector: 'merge_request_approvals_settings_content' } }
.settings-header .settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _("Merge request approvals") %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _("Merge request approvals")
%button.gl-button.btn.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _("Collapse") : _("Expand") %button.gl-button.btn.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _("Collapse") : _("Expand")
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
= form_for @project, remote: true, html: { class: "merge-request-approval-settings-form js-mr-approvals-form" }, authenticity_token: true do |f| = form_for @project, remote: true, html: { class: "merge-request-approval-settings-form js-mr-approvals-form" }, authenticity_token: true do |f|
%input{ name: 'update_section', type: 'hidden', value: 'js-merge-request-approval-settings' } %input{ name: 'update_section', type: 'hidden', value: 'js-merge-request-approval-settings' }
= render 'projects/merge_request_approvals_settings_form', form: f, project: @project = render 'projects/merge_request_approvals_settings_form', form: f, project: @project
= f.submit _("Save changes"), class: "btn gl-button btn-success qa-save-merge-request-approval-settings-button gl-mt-4" = f.submit _("Save changes"), class: "btn gl-button btn-success gl-mt-4", data: { qa_selector: 'save_merge_request_approval_settings_button' }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
= form.label :merge_requests_template, class: 'label-bold' do = form.label :merge_requests_template, class: 'label-bold' do
= _('Default description template for merge requests') = _('Default description template for merge requests')
= link_to sprite_icon('question-o'), help_page_path('user/project/description_templates'), target: '_blank' = link_to sprite_icon('question-o'), help_page_path('user/project/description_templates'), target: '_blank'
= form.text_area :merge_requests_template, class: "form-control", rows: 3 = form.text_area :merge_requests_template, class: "form-control", rows: 3, data: { qa_selector: 'default_merge_request_template_field' }
.text-secondary .text-secondary
- link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: help_page_path('user/markdown') } - link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: help_page_path('user/markdown') }
= _('Description parsed with %{link_start}GitLab Flavored Markdown%{link_end}').html_safe % { link_start: link_start, link_end: '</a>'.html_safe } = _('Description parsed with %{link_start}GitLab Flavored Markdown%{link_end}').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
...@@ -17,7 +17,7 @@ module QA ...@@ -17,7 +17,7 @@ module QA
end end
view 'ee/app/views/projects/_merge_request_approvals_settings.html.haml' do view 'ee/app/views/projects/_merge_request_approvals_settings.html.haml' do
element :merge_request_approvals_settings element :merge_request_approvals_settings_content
end end
end end
end end
...@@ -29,7 +29,7 @@ module QA ...@@ -29,7 +29,7 @@ module QA
end end
def expand_merge_request_approvals_settings(&block) def expand_merge_request_approvals_settings(&block)
expand_content(:merge_request_approvals_settings) do expand_content(:merge_request_approvals_settings_content) do
MergeRequestApprovals.perform(&block) MergeRequestApprovals.perform(&block)
end end
end end
......
...@@ -18,6 +18,10 @@ module QA ...@@ -18,6 +18,10 @@ module QA
element :merged_results_pipeline_checkbox element :merged_results_pipeline_checkbox
end end
view 'ee/app/views/projects/_merge_request_settings.html.haml' do
element :default_merge_request_template_field
end
view 'ee/app/views/projects/_merge_trains_settings.html.haml' do view 'ee/app/views/projects/_merge_trains_settings.html.haml' do
element :merge_trains_checkbox element :merge_trains_checkbox
end end
...@@ -37,6 +41,13 @@ module QA ...@@ -37,6 +41,13 @@ module QA
click_merge_trains_checkbox click_merge_trains_checkbox
click_save_changes click_save_changes
end end
def set_default_merge_request_template(template)
fill_element(:default_merge_request_template_field, template)
click_save_changes
wait_for_requests
end
end end
end end
end end
......
...@@ -11,8 +11,9 @@ module QA ...@@ -11,8 +11,9 @@ module QA
include Component::Breadcrumbs include Component::Breadcrumbs
view 'app/views/projects/edit.html.haml' do view 'app/views/projects/edit.html.haml' do
element :advanced_settings element :advanced_settings_content
element :merge_request_settings element :merge_request_settings_content
element :visibility_features_permissions_content
end end
view 'app/views/projects/settings/_general.html.haml' do view 'app/views/projects/settings/_general.html.haml' do
...@@ -20,10 +21,6 @@ module QA ...@@ -20,10 +21,6 @@ module QA
element :save_naming_topics_avatar_button element :save_naming_topics_avatar_button
end end
view 'app/views/projects/edit.html.haml' do
element :visibility_features_permissions_content
end
def rename_project_to(name) def rename_project_to(name)
fill_project_name(name) fill_project_name(name)
click_save_changes click_save_changes
...@@ -38,13 +35,13 @@ module QA ...@@ -38,13 +35,13 @@ module QA
end end
def expand_advanced_settings(&block) def expand_advanced_settings(&block)
expand_content(:advanced_settings) do expand_content(:advanced_settings_content) do
Advanced.perform(&block) Advanced.perform(&block)
end end
end end
def expand_merge_requests_settings(&block) def expand_merge_requests_settings(&block)
expand_content(:merge_request_settings) do expand_content(:merge_request_settings_content) do
MergeRequest.perform(&block) MergeRequest.perform(&block)
end end
end end
......
...@@ -8,11 +8,11 @@ module QA ...@@ -8,11 +8,11 @@ module QA
include QA::Page::Settings::Common include QA::Page::Settings::Common
view 'app/views/projects/edit.html.haml' do view 'app/views/projects/edit.html.haml' do
element :save_merge_request_changes element :save_merge_request_changes_button
end end
view 'app/views/projects/_merge_request_merge_method_settings.html.haml' do view 'app/views/projects/_merge_request_merge_method_settings.html.haml' do
element :radio_button_merge_ff element :merge_ff_radio_button
end end
view 'app/views/projects/_merge_request_merge_checks_settings.html.haml' do view 'app/views/projects/_merge_request_merge_checks_settings.html.haml' do
...@@ -20,11 +20,11 @@ module QA ...@@ -20,11 +20,11 @@ module QA
end end
def click_save_changes def click_save_changes
click_element :save_merge_request_changes click_element :save_merge_request_changes_button
end end
def enable_ff_only def enable_ff_only
click_element :radio_button_merge_ff click_element :merge_ff_radio_button
click_save_changes click_save_changes
end end
......
...@@ -75,7 +75,7 @@ module QA ...@@ -75,7 +75,7 @@ module QA
Page::MergeRequest::New.perform do |new_page| Page::MergeRequest::New.perform do |new_page|
new_page.fill_title(@title) new_page.fill_title(@title)
new_page.choose_template(@template) if @template new_page.choose_template(@template) if @template
new_page.fill_description(@description) unless @template new_page.fill_description(@description) if @description && !@template
new_page.choose_milestone(@milestone) if @milestone new_page.choose_milestone(@milestone) if @milestone
new_page.assign_to_me if @assignee == 'me' new_page.assign_to_me if @assignee == 'me'
labels.each do |label| labels.each do |label|
......
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
describe 'Default merge request templates' do
let(:default_template_project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'default-mr-template-project'
end
end
let(:template_content) { 'This is a default merge request template' }
before do
Flow::Login.sign_in
end
it 'uses default template when creating a merge request', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1232' do
default_template_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 |mr_settings|
mr_settings.set_default_merge_request_template(template_content)
end
Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request|
merge_request.project = default_template_project
merge_request.description = nil
end
Page::MergeRequest::Show.perform do |merge_request|
expect(merge_request).to have_description(template_content)
end
end
end
end
end
...@@ -133,7 +133,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do ...@@ -133,7 +133,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
it 'when unchecked sets :remove_source_branch_after_merge to false' do it 'when unchecked sets :remove_source_branch_after_merge to false' do
uncheck('project_remove_source_branch_after_merge') uncheck('project_remove_source_branch_after_merge')
within('.merge-request-settings-form') do within('.merge-request-settings-form') do
find('.qa-save-merge-request-changes') find('.rspec-save-merge-request-changes')
click_on('Save changes') click_on('Save changes')
end end
...@@ -157,7 +157,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do ...@@ -157,7 +157,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
choose('project_project_setting_attributes_squash_option_default_on') choose('project_project_setting_attributes_squash_option_default_on')
within('.merge-request-settings-form') do within('.merge-request-settings-form') do
find('.qa-save-merge-request-changes') find('.rspec-save-merge-request-changes')
click_on('Save changes') click_on('Save changes')
end end
...@@ -172,7 +172,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do ...@@ -172,7 +172,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
choose('project_project_setting_attributes_squash_option_always') choose('project_project_setting_attributes_squash_option_always')
within('.merge-request-settings-form') do within('.merge-request-settings-form') do
find('.qa-save-merge-request-changes') find('.rspec-save-merge-request-changes')
click_on('Save changes') click_on('Save changes')
end end
...@@ -187,7 +187,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do ...@@ -187,7 +187,7 @@ RSpec.describe 'Projects > Settings > User manages merge request settings' do
choose('project_project_setting_attributes_squash_option_never') choose('project_project_setting_attributes_squash_option_never')
within('.merge-request-settings-form') do within('.merge-request-settings-form') do
find('.qa-save-merge-request-changes') find('.rspec-save-merge-request-changes')
click_on('Save changes') click_on('Save changes')
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