Commit e6034c9a authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'add-custom-issue-template-e2e-spec' into 'master'

Add e2e test for custom issue templates

See merge request gitlab-org/gitlab!52256
parents d987e5a0 337cc118
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
- return unless issuable && issuable_templates(issuable).any? - return unless issuable && issuable_templates(issuable).any?
.issuable-form-select-holder.selectbox.form-group .issuable-form-select-holder.selectbox.form-group
.js-issuable-selector-wrap{ data: { issuable_type: issuable.to_ability_name } } .js-issuable-selector-wrap{ data: { issuable_type: issuable.to_ability_name, qa_selector: 'template_dropdown' } }
= template_dropdown_tag(issuable) do = template_dropdown_tag(issuable) do
%ul.dropdown-footer-list %ul.dropdown-footer-list
%li %li
......
...@@ -28,6 +28,10 @@ module QA ...@@ -28,6 +28,10 @@ module QA
element :assign_to_me_link element :assign_to_me_link
end end
view 'app/views/shared/issuable/form/_template_selector.html.haml' do
element :template_dropdown
end
def fill_title(title) def fill_title(title)
fill_element :issuable_form_title, title fill_element :issuable_form_title, title
end end
...@@ -43,6 +47,13 @@ module QA ...@@ -43,6 +47,13 @@ module QA
end end
end end
def choose_template(template_name)
click_element :template_dropdown
within_element(:template_dropdown) do
click_on template_name
end
end
def select_label(label) def select_label(label)
click_element :issuable_label click_element :issuable_label
......
...@@ -5,7 +5,7 @@ require 'securerandom' ...@@ -5,7 +5,7 @@ require 'securerandom'
module QA module QA
module Resource module Resource
class Issue < Base class Issue < Base
attr_writer :description, :milestone, :weight attr_writer :description, :milestone, :template, :weight
attribute :project do attribute :project do
Project.fabricate! do |resource| Project.fabricate! do |resource|
...@@ -33,7 +33,8 @@ module QA ...@@ -33,7 +33,8 @@ module QA
Page::Project::Issue::New.perform do |new_page| Page::Project::Issue::New.perform do |new_page|
new_page.fill_title(@title) new_page.fill_title(@title)
new_page.fill_description(@description) new_page.choose_template(@template) if @template
new_page.fill_description(@description) if @description
new_page.choose_milestone(@milestone) if @milestone new_page.choose_milestone(@milestone) if @milestone
new_page.create_new_issue new_page.create_new_issue
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
RSpec.describe 'Plan', :smoke do RSpec.describe 'Plan' do
describe 'Issue creation' do describe 'Issue creation' do
let(:closed_issue) { Resource::Issue.fabricate_via_api! } let(:closed_issue) { Resource::Issue.fabricate_via_api! }
...@@ -9,7 +9,7 @@ module QA ...@@ -9,7 +9,7 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end end
it 'creates an issue', :reliable, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1167' do it 'creates an issue', :smoke, :reliable, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1167' do
issue = Resource::Issue.fabricate_via_browser_ui! issue = Resource::Issue.fabricate_via_browser_ui!
Page::Project::Menu.perform(&:click_issues) Page::Project::Menu.perform(&:click_issues)
...@@ -19,7 +19,7 @@ module QA ...@@ -19,7 +19,7 @@ module QA
end end
end end
it 'closes an issue', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1085' do it 'closes an issue', :smoke, testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1085' do
closed_issue.visit! closed_issue.visit!
Page::Project::Issue::Show.perform do |issue_page| Page::Project::Issue::Show.perform do |issue_page|
...@@ -38,7 +38,7 @@ module QA ...@@ -38,7 +38,7 @@ module QA
end end
end end
context 'when using attachments in comments', :object_storage do context 'when using attachments in comments', :smoke, :object_storage do
let(:gif_file_name) { 'banana_sample.gif' } let(:gif_file_name) { 'banana_sample.gif' }
let(:file_to_attach) do let(:file_to_attach) do
File.absolute_path(File.join('qa', 'fixtures', 'designs', gif_file_name)) File.absolute_path(File.join('qa', 'fixtures', 'designs', gif_file_name))
...@@ -56,6 +56,42 @@ module QA ...@@ -56,6 +56,42 @@ module QA
end end
end end
end end
context 'when using custom issue templates' do
let(:template_name) { 'custom_issue_template'}
let(:template_content) { 'This is a custom issue template test' }
let(:template_project) do
Resource::Project.fabricate_via_api! do |project|
project.name = "custom-issue-template-project-#{SecureRandom.hex(8)}"
project.initialize_with_readme = true
end
end
before do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = template_project
commit.commit_message = 'Add custom issue template'
commit.add_files([
{
file_path: ".gitlab/issue_templates/#{template_name}.md",
content: template_content
}
])
end
end
it 'creates an issue via custom template', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1229' do
Resource::Issue.fabricate_via_browser_ui! do |issue|
issue.project = template_project
issue.template = template_name
end
Page::Project::Issue::Show.perform do |issue_page|
expect(issue_page).to have_content(template_content)
end
end
end
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