提交 e90615ca 编写于 作者: S Sanad Liaquat

Merge branch 'qa-add-group-file-template-tests' into 'master'

Add group file template tests

See merge request gitlab-org/gitlab!16267
- return unless @group.feature_available?(:custom_file_templates_for_namespace)
%section.settings.no-animate#js-templates{ class: ('expanded' if expanded) }
%section.settings.no-animate#js-templates{ class: ('expanded' if expanded), data: { qa_selector: 'file_template_repositories' } }
.settings-header
%h4
= _('Templates')
......@@ -18,6 +18,6 @@
.form-text.text-muted
= _('Select a template repository')
= link_to icon('question-circle'), help_page_path('user/group/index.md', anchor: 'group-file-templates-premium'), target: '_blank'
= project_select_tag('group[file_template_project_id]', class: 'project-item-select hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
= project_select_tag('group[file_template_project_id]', class: 'project-item-select hidden-filter-value qa-file-template-repository-dropdown', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
placeholder: _('Search projects'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', simple_filter: true, allow_clear: true }, value: @group.checked_file_template_project_id)
= f.submit _('Save changes'), class: "btn btn-success"
= f.submit _('Save changes'), class: "btn btn-success", data: { qa_selector: 'save_changes_button' }
......@@ -28,6 +28,12 @@ module QA
view 'ee/app/views/shared/_repository_size_limit_setting.html.haml' do
element :repository_size_limit_field
end
view 'ee/app/views/groups/_templates_setting.html.haml' do
element :file_template_repository_dropdown
element :file_template_repositories
element :save_changes_button
end
end
end
......@@ -72,6 +78,25 @@ module QA
def set_repository_size_limit(limit)
find_element(:repository_size_limit_field).set limit
end
def current_file_template_repository
expand_section(:file_template_repositories)
within_element(:file_template_repository_dropdown) do
current_selection
end
end
def choose_file_template_repository(path)
expand_section(:file_template_repositories)
within_element(:file_template_repository_dropdown) do
clear_current_selection_if_present
end
click_element :file_template_repository_dropdown
search_and_select(path)
click_element :save_changes_button
end
end
end
end
......
......@@ -20,12 +20,20 @@ module QA
def search_and_select(item_text)
find('.select2-input').set(item_text)
wait_for_search_to_complete
select_item(item_text)
end
def expand_select_list
find('span.select2-arrow').click
end
def wait_for_search_to_complete
has_css?('.select2-active')
has_no_css?('.select2-active', wait: 30)
end
end
end
end
......
......@@ -13,6 +13,10 @@ module QA
def commit_changes
click_element(:commit_button)
wait(reload: false, max: 60) do
finished_loading?
end
end
end
end
......
# frozen_string_literal: true
module QA
context 'Manage' do
describe 'Group file templates' do
include Support::Api
templates = [
{
type: 'Dockerfile',
template: 'custom_dockerfile',
name: 'Dockerfile/custom_dockerfile.dockerfile',
content: 'dockerfile template test'
},
{
type: '.gitignore',
template: 'custom_gitignore',
name: 'gitignore/custom_gitignore.gitignore',
content: 'gitignore template test'
},
{
type: '.gitlab-ci.yml',
template: 'custom_gitlab-ci',
name: 'gitlab-ci/custom_gitlab-ci.yml',
content: 'gitlab-ci template test'
},
{
type: 'LICENSE',
template: 'custom_license',
name: 'LICENSE/custom_license.txt',
content: 'license template test'
}
]
before(:all) do
login
@group = Resource::Group.fabricate_via_api! do |group|
group.path = 'template-group'
end
@file_template_project = Resource::Project.fabricate_via_api! do |project|
project.group = @group
project.name = 'group-file-template-project'
project.description = 'Add group file templates'
project.initialize_with_readme = true
end
templates.each do |template|
Resource::File.fabricate_via_api! do |file|
file.project = @file_template_project
file.name = template[:name]
file.content = template[:content]
file.commit_message = 'Add test file templates'
end
end
@project = Resource::Project.fabricate_via_api! do |project|
project.group = @group
project.name = 'group-file-template-project-2'
project.description = 'Add files for group file templates'
project.initialize_with_readme = true
end
Page::Main::Menu.perform(&:sign_out)
end
after(:all) do
login unless Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) }
remove_group_file_template_if_set
end
templates.each do |template|
it "creates file via custom #{template[:type]} file template" do
login
set_file_template_if_not_already_set
@project.visit!
Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |form|
form.select_template template[:type], template[:template]
end
expect(page).to have_content(template[:content])
Page::File::Form.perform(&:commit_changes)
expect(page).to have_content('The file has been successfully created.')
expect(page).to have_content(template[:type])
expect(page).to have_content('Add new file')
expect(page).to have_content(template[:content])
end
end
def login
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials)
end
def set_file_template_if_not_already_set
api_client = Runtime::API::Client.new(:gitlab)
response = get Runtime::API::Request.new(api_client, "/groups/#{@group.id}").url
if parse_body(response)[:file_template_project_id]
return
else
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform do |general|
general.choose_file_template_repository(@file_template_project.name)
end
end
end
def remove_group_file_template_if_set
api_client = Runtime::API::Client.new(:gitlab)
response = get Runtime::API::Request.new(api_client, "/groups/#{@group.id}").url
if parse_body(response)[:file_template_project_id]
put Runtime::API::Request.new(api_client, "/groups/#{@group.id}").url, { file_template_project_id: nil }
end
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册