Commit 6e713077 authored by Desiree Chevalier's avatar Desiree Chevalier

Add default issue template e2e test

Adds an e2e test for default issue templates
parent c77acf7f
- if @project.feature_available?(:issuable_default_templates)
- expanded = expanded_by_default?
%section.settings.issues-feature.no-animate#js-issue-settings{ class: [('expanded' if expanded), ('hidden' if @project.project_feature.send(:issues_access_level) == 0)] }
%section.settings.issues-feature.no-animate#js-issue-settings{ class: [('expanded' if expanded), ('hidden' if @project.project_feature.send(:issues_access_level) == 0)], data: { qa_selector: 'issue_template_settings_content' } }
.settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Default description template for issues')
%button.gl-button.btn.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _('Collapse') : _('Expand')
......@@ -12,8 +12,8 @@
%input{ type: 'hidden', name: 'update_section', value: 'js-issue-settings' }
.row
.form-group.col-md-9
= f.text_area :issues_template, class: "form-control", rows: 3, aria: { labelledby: 'issue-settings-default-template-label'}
= f.text_area :issues_template, class: "form-control", rows: 3, aria: { labelledby: 'issue-settings-default-template-label'}, data: { qa_selector: 'issue_template_field' }
.text-secondary
- 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 }
= f.submit _('Save changes'), class: "gl-button btn btn-success"
= f.submit _('Save changes'), class: "gl-button btn btn-success", data: { qa_selector: 'save_issue_template_button' }
......@@ -141,6 +141,7 @@ module QA
autoload :Repository, 'qa/ee/page/project/settings/repository'
autoload :PushRules, 'qa/ee/page/project/settings/push_rules'
autoload :LicenseCompliance, 'qa/ee/page/project/settings/license_compliance'
autoload :IssueTemplateDefault, 'qa/ee/page/project/settings/issue_template_default.rb'
end
module Operations
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Settings
class IssueTemplateDefault < QA::Page::Base
view 'ee/app/views/projects/settings/_default_issue_template.html.haml' do
element :issue_template_field
element :save_issue_template_button
end
def set_default_issue_template(template)
fill_element(:issue_template_field, template)
click_element(:save_issue_template_button)
wait_for_requests
end
end
end
end
end
end
end
......@@ -12,12 +12,22 @@ module QA
super
base.class_eval do
view 'ee/app/views/projects/settings/_default_issue_template.html.haml' do
element :issue_template_settings_content
end
view 'ee/app/views/projects/_merge_request_approvals_settings.html.haml' do
element :merge_request_approvals_settings
end
end
end
def expand_default_description_template_for_issues(&block)
expand_content(:issue_template_settings_content) do
IssueTemplateDefault.perform(&block)
end
end
def expand_merge_request_approvals_settings(&block)
expand_content(:merge_request_approvals_settings) do
MergeRequestApprovals.perform(&block)
......
# frozen_string_literal: true
module QA
RSpec.describe 'Plan' do
describe 'Default issue templates' do
let(:default_template_project) do
Resource::Project.fabricate_via_api! do |project|
project.name = "default-issue-template-project-#{SecureRandom.hex(8)}"
end
end
let(:template) { 'This is a default issue template' }
before do
Flow::Login.sign_in
end
it 'uses default template when creating an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1231' do
default_template_project.visit!
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform(&:expand_default_description_template_for_issues)
EE::Page::Project::Settings::IssueTemplateDefault.perform do |issue_settings|
issue_settings.set_default_issue_template(template)
end
Resource::Issue.fabricate_via_api! do |issue|
issue.project = default_template_project
end.visit!
expect(page).to have_content(template)
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