Commit 7f17e99c authored by Mark Lapierre's avatar Mark Lapierre

Merge branch '6861-group-level-project-templates-QA-tests-take-2' into 'master'

e2e QA tests for Group level project templates

Closes #7392

See merge request gitlab-org/gitlab-ee!8863
parents c7c63b2f 09e233d2
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
%span.d-block.d-sm-none Blank %span.d-block.d-sm-none Blank
%li.nav-item{ role: 'presentation' } %li.nav-item{ role: 'presentation' }
%a.nav-link{ href: '#create-from-template-pane', id: 'create-from-template-tab', data: { toggle: 'tab', track_label: 'create_from_template', track_event: "click_tab" }, role: 'tab' } %a.nav-link{ href: '#create-from-template-pane', id: 'create-from-template-tab', data: { toggle: 'tab', track_label: 'create_from_template', track_event: "click_tab" }, role: 'tab' }
%span.d-none.d-sm-block Create from template %span.d-none.d-sm-block.qa-project-create-from-template-tab Create from template
%span.d-block.d-sm-none Template %span.d-block.d-sm-none Template
%li.nav-item{ role: 'presentation' } %li.nav-item{ role: 'presentation' }
%a.nav-link{ href: '#import-project-pane', id: 'import-project-tab', data: { toggle: 'tab', track_label: 'import_project', track_event: "click_tab" }, role: 'tab' } %a.nav-link{ href: '#import-project-pane', id: 'import-project-tab', data: { toggle: 'tab', track_label: 'import_project', track_event: "click_tab" }, role: 'tab' }
......
- return unless ::Gitlab::CurrentSettings.custom_project_templates_enabled? - return unless ::Gitlab::CurrentSettings.custom_project_templates_enabled?
- expanded = Rails.env.test? - expanded = Rails.env.test?
%section.settings.no-animate{ class: ('expanded' if expanded) } %section.settings.no-animate.qa-custom-project-templates{ class: ('expanded' if expanded) }
.settings-header .settings-header
%h4 %h4
= s_('GroupSettings|Custom project templates') = s_('GroupSettings|Custom project templates')
...@@ -19,6 +19,6 @@ ...@@ -19,6 +19,6 @@
.form-group .form-group
= f.label :custom_project_templates_group_id, class: 'label-bold' do = f.label :custom_project_templates_group_id, class: 'label-bold' do
= _('Custom project templates') = _('Custom project templates')
= groups_select_tag('group[custom_project_templates_group_id]', data: { parent_id: @group.id }, selected: @group.custom_project_templates_group_id, class: 'input-clamp allowClear', multiple: false) = groups_select_tag('group[custom_project_templates_group_id]', data: { parent_id: @group.id }, selected: @group.custom_project_templates_group_id, class: 'input-clamp allowClear qa-custom-project-template-select', multiple: false)
= f.submit _('Save changes'), class: 'btn btn-success' = f.submit _('Save changes'), class: 'btn btn-success qa-save-changes-button'
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
= _('Instance') = _('Instance')
%span.badge.badge-pill= project_template_count %span.badge.badge-pill= project_template_count
%li.custom-group-project-templates-tab %li.custom-group-project-templates-tab
%a.nav-link.js-custom-group-project-templates-nav-link{ href: "#custom-group-project-templates", data: { toggle: 'tab'} } %a.nav-link.js-custom-group-project-templates-nav-link.qa-group-templates-tab{ href: "#custom-group-project-templates", data: { toggle: 'tab'} }
= _('Group') = _('Group')
%span.badge.badge-pill %span.badge.badge-pill.qa-group-template-tab-badge
= group_project_templates_count(group_id) = group_project_templates_count(group_id)
.tab-content .tab-content
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
= group.projects.count = group.projects.count
- group.projects.each do |project| - group.projects.each do |project|
.template-option.align-items-center .template-option.align-items-center.qa-template-option-row
.avatar-container.s40 .avatar-container.s40
= project_icon(project, alt: project.name, class: 'btn-template-icon avatar s40 avatar-tile', lazy: false) = project_icon(project, alt: project.name, class: 'btn-template-icon avatar s40 avatar-tile', lazy: false)
.description.prepend-left-5 .description.prepend-left-5
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
= _('Preview') = _('Preview')
%label.btn.btn-success.custom-template-button.choose-template.append-bottom-0{ for: project.name } %label.btn.btn-success.custom-template-button.choose-template.append-bottom-0{ for: project.name }
%input{ type: "radio", autocomplete: "off", name: "project[template_name]", id: project.name, value: project.name, data: { subgroup_id: project.namespace_id } } %input{ type: "radio", autocomplete: "off", name: "project[template_name]", id: project.name, value: project.name, data: { subgroup_id: project.namespace_id } }
%span %span.qa-use-template-button
= _('Use template') = _('Use template')
= paginate groups_with_project_templates, params: {controller: 'users', action: 'available_templates', username: current_user.username}, theme: 'gitlab', remote: true = paginate groups_with_project_templates, params: {controller: 'users', action: 'available_templates', username: current_user.username}, theme: 'gitlab', remote: true
......
...@@ -22,6 +22,7 @@ module QA ...@@ -22,6 +22,7 @@ module QA
module Settings module Settings
autoload :SamlSSO, 'qa/ee/page/group/settings/saml_sso' autoload :SamlSSO, 'qa/ee/page/group/settings/saml_sso'
autoload :LDAPSync, 'qa/ee/page/group/settings/ldap_sync' autoload :LDAPSync, 'qa/ee/page/group/settings/ldap_sync'
autoload :General, 'qa/ee/page/group/settings/general'
end end
end end
...@@ -50,6 +51,7 @@ module QA ...@@ -50,6 +51,7 @@ module QA
end end
module Project module Project
autoload :New, 'qa/ee/page/project/new'
autoload :Show, 'qa/ee/page/project/show' autoload :Show, 'qa/ee/page/project/show'
module Issue module Issue
......
# frozen_string_literal: true
module QA
module EE
module Page
module Group
module Settings
class General < QA::Page::Base
include ::QA::Page::Component::Select2
include ::QA::Page::Settings::Common
view 'ee/app/views/groups/_custom_project_templates_setting.html.haml' do
element :custom_project_template_select
element :custom_project_templates
element :save_changes_button
end
def choose_custom_project_template(path)
expand_section(:custom_project_templates)
within_element(:custom_project_template_select) do
clear_current_selection_if_present
end
click_element :custom_project_template_select
search_and_select(path)
click_element :save_changes_button
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module New
def self.prepended(page)
page.module_eval do
view 'ee/app/views/projects/_project_templates.html.haml' do
element :group_templates_tab
element :group_template_tab_badge
end
view 'ee/app/views/users/_custom_project_templates_from_groups.html.haml' do
element :use_template_button
element :template_option_row
end
end
end
def go_to_create_from_template_group_tab
go_to_create_from_template
click_element(:group_templates_tab)
end
def group_template_tab_badge_text
find_element(:group_template_tab_badge).text
end
def use_template_for_project(project_name)
within find_element(:template_option_row, project_name) do
click_element :use_template_button
end
end
end
end
end
end
end
...@@ -18,6 +18,12 @@ module QA ...@@ -18,6 +18,12 @@ module QA
def wait_until_geo_max_replication_time(max_wait: Runtime::Geo.max_file_replication_time) def wait_until_geo_max_replication_time(max_wait: Runtime::Geo.max_file_replication_time)
wait(max: max_wait) { yield } wait(max: max_wait) { yield }
end end
def wait_for_import_success
wait(reload: false) do
has_text?('The project was successfully imported.')
end
end
end end
end end
end end
......
...@@ -6,6 +6,12 @@ module QA ...@@ -6,6 +6,12 @@ module QA
find('.select2-result-label', text: item_text).click find('.select2-result-label', text: item_text).click
end end
def clear_current_selection_if_present
if has_css?('a > abbr.select2-search-choice-close', wait: 1.0)
find('a > abbr.select2-search-choice-close').click
end
end
def search_and_select(item_text) def search_and_select(item_text)
find('.select2-input').set(item_text) find('.select2-input').set(item_text)
select_item(item_text) select_item(item_text)
......
...@@ -3,8 +3,10 @@ module QA ...@@ -3,8 +3,10 @@ module QA
module Project module Project
class New < Page::Base class New < Page::Base
include Page::Component::Select2 include Page::Component::Select2
prepend EE::Page::Project::New
view 'app/views/projects/new.html.haml' do view 'app/views/projects/new.html.haml' do
element :project_create_from_template_tab
element :import_project_tab, "Import project" # rubocop:disable QA/ElementWithPattern element :import_project_tab, "Import project" # rubocop:disable QA/ElementWithPattern
end end
...@@ -44,6 +46,10 @@ module QA ...@@ -44,6 +46,10 @@ module QA
click_on 'Create project' click_on 'Create project'
end end
def go_to_create_from_template
click_element(:project_create_from_template_tab)
end
def set_visibility(visibility) def set_visibility(visibility)
choose visibility choose visibility
end end
......
...@@ -11,7 +11,7 @@ module QA ...@@ -11,7 +11,7 @@ module QA
wait(reload: false) do wait(reload: false) do
click_button 'Expand' unless first('button', text: 'Collapse') click_button 'Expand' unless first('button', text: 'Collapse')
page.has_content?('Collapse') has_content?('Collapse')
end end
yield if block_given? yield if block_given?
......
# frozen_string_literal: true
require 'securerandom'
module QA
context :manage do
describe 'Group level project template' do
let(:files) do
[
{
name: 'file.txt',
content: 'foo'
},
{
name: 'README.md',
content: 'bar'
}
]
end
it 'user creates and uses group level project template' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
template_container_group_name = "template-container-group-#{SecureRandom.hex(8)}"
group = QA::Resource::Group.fabricate! do |group|
group.path = template_container_group_name
group.description = 'Template container group'
end
template_project = Resource::Project.fabricate! do |project|
project.name = 'template-project-1'
project.group = group
end
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = template_project
push.files = files
push.commit_message = 'Add test files'
end
Page::Main::Menu.perform(&:go_to_groups)
Page::Dashboard::Groups.perform { |page| page.go_to_group(Runtime::Namespace.sandbox_name) }
Page::Project::Menu.perform(&:go_to_settings)
EE::Page::Group::Settings::General.perform do |settings|
settings.choose_custom_project_template("#{template_container_group_name}")
end
Page::Main::Menu.perform(&:go_to_groups)
Page::Dashboard::Groups.perform { |page| page.go_to_group(Runtime::Namespace.sandbox_name) }
Page::Group::Show.perform(&:go_to_new_project)
Page::Project::New.perform do |page|
page.go_to_create_from_template_group_tab
expect(page.group_template_tab_badge_text).to eq "1"
expect(page).to have_text(template_container_group_name)
expect(page).to have_text(template_project.name)
page.use_template_for_project(template_project.name)
page.choose_name('Project using group level project template')
page.add_description('Project using group level project template')
page.set_visibility('Public')
page.create_new_project
end
Page::Project::Show.perform(&:wait_for_import_success)
files.each do |file|
expect(page).to have_content(file[:name])
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