diff options
Diffstat (limited to 'spec/features/projects/files')
-rw-r--r-- | spec/features/projects/files/template_type_dropdown_spec.rb | 143 | ||||
-rw-r--r-- | spec/features/projects/files/undo_template_spec.rb | 19 |
2 files changed, 0 insertions, 162 deletions
diff --git a/spec/features/projects/files/template_type_dropdown_spec.rb b/spec/features/projects/files/template_type_dropdown_spec.rb deleted file mode 100644 index 990b118d172..00000000000 --- a/spec/features/projects/files/template_type_dropdown_spec.rb +++ /dev/null @@ -1,143 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Projects > Files > Template type dropdown selector', :js, feature_category: :projects do - let(:project) { create(:project, :repository) } - let(:user) { project.first_owner } - - before do - sign_in user - end - - context 'editing a non-matching file' do - before do - create_and_edit_file('.random-file.js') - end - - it 'not displayed' do - check_type_selector_display(false) - end - - it 'selects every template type correctly' do - fill_in 'file_path', with: '.gitignore' - try_selecting_all_types - end - - it 'updates template type toggle value when template is chosen' do - fill_in 'file_path', with: '.gitignore' - select_template('gitignore', 'Actionscript') - check_type_selector_toggle_text('.gitignore') - end - end - - context 'editing a matching file' do - before do - visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE')) - end - - it 'displayed' do - check_type_selector_display(true) - end - - it 'selects every template type correctly' do - try_selecting_all_types - end - - context 'user previews changes' do - before do - click_link 'Preview changes' - end - - it 'type selector is hidden and shown correctly' do - check_type_selector_display(false) - click_link 'Write' - check_type_selector_display(true) - end - end - end - - context 'creating a matching file' do - before do - visit project_new_blob_path(project, 'master', file_name: '.gitignore') - end - - it 'is displayed' do - check_type_selector_display(true) - end - - it 'toggle is set to the correct value' do - select_template('gitignore', 'Actionscript') - check_type_selector_toggle_text('.gitignore') - end - - it 'sets the toggle text when selecting the template type' do - select_template_type('.gitignore') - check_type_selector_toggle_text('.gitignore') - end - - it 'selects every template type correctly' do - try_selecting_all_types - end - end - - context 'creating a file' do - before do - visit project_new_blob_path(project, project.default_branch) - end - - it 'type selector is shown' do - check_type_selector_display(true) - end - - it 'toggle is set to the proper value' do - check_type_selector_toggle_text('Select a template type') - end - - it 'selects every template type correctly' do - try_selecting_all_types - end - end -end - -def check_type_selector_display(is_visible) - count = is_visible ? 1 : 0 - expect(page).to have_css('.js-template-type-selector', count: count) -end - -def try_selecting_all_types - try_selecting_template_type('LICENSE', 'Apply a template') - try_selecting_template_type('Dockerfile', 'Apply a template') - try_selecting_template_type('.gitlab-ci.yml', 'Apply a template') - try_selecting_template_type('.gitignore', 'Apply a template') -end - -def try_selecting_template_type(template_type, selector_label) - select_template_type(template_type) - check_template_selector_display(selector_label) -end - -def select_template_type(template_type) - find('.js-template-type-selector').click - find('.dropdown-content li', text: template_type).click -end - -def select_template(type, template) - find(".js-#{type}-selector-wrap").click - find('.dropdown-content li', text: template).click -end - -def check_template_selector_display(content) - expect(page).to have_content(content) -end - -def check_type_selector_toggle_text(template_type) - dropdown_toggle_button = find('.template-type-selector .dropdown-toggle-text') - expect(dropdown_toggle_button).to have_content(template_type) -end - -def create_and_edit_file(file_name) - visit project_new_blob_path(project, 'master', file_name: file_name) - click_button "Commit changes" - visit project_edit_blob_path(project, File.join(project.default_branch, file_name)) -end diff --git a/spec/features/projects/files/undo_template_spec.rb b/spec/features/projects/files/undo_template_spec.rb index afc9a5fd232..0dfed209ce9 100644 --- a/spec/features/projects/files/undo_template_spec.rb +++ b/spec/features/projects/files/undo_template_spec.rb @@ -13,19 +13,6 @@ RSpec.describe 'Projects > Files > Template Undo Button', :js, feature_category: context 'editing a matching file and applying a template' do before do visit project_edit_blob_path(project, File.join(project.default_branch, "LICENSE")) - select_file_template_type('LICENSE') - select_file_template('.js-license-selector', 'Apache License 2.0') - end - - it 'reverts template application' do - try_template_undo('http://www.apache.org/licenses/', 'Apply a template') - end - end - - context 'creating a non-matching file' do - before do - visit project_new_blob_path(project, 'master') - select_file_template_type('LICENSE') select_file_template('.js-license-selector', 'Apache License 2.0') end @@ -53,7 +40,6 @@ end def check_content_reverted(template_content) find('.b-toaster a', text: 'Undo').click expect(page).not_to have_content(template_content) - expect(page).to have_css('.template-type-selector .dropdown-toggle-text') end def select_file_template(template_selector_selector, template_name) @@ -61,8 +47,3 @@ def select_file_template(template_selector_selector, template_name) find('.dropdown-content li', text: template_name).click wait_for_requests end - -def select_file_template_type(template_type) - find('.js-template-type-selector').click - find('.dropdown-content li', text: template_type).click -end |