diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-28 09:08:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-28 09:08:59 +0300 |
commit | fd01ef494eca13de9767e697280c6387f0fbb328 (patch) | |
tree | 72fb28f4c2ef2a61205e986838cf89fa7cdc2187 /qa | |
parent | deb09d4cc12ea6302ef0b7534e1a1b5789732472 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
3 files changed, 108 insertions, 8 deletions
diff --git a/qa/qa/page/project/web_ide/edit.rb b/qa/qa/page/project/web_ide/edit.rb index 2fc67b29f74..45c46004790 100644 --- a/qa/qa/page/project/web_ide/edit.rb +++ b/qa/qa/page/project/web_ide/edit.rb @@ -18,7 +18,8 @@ module QA end view 'app/assets/javascripts/ide/components/ide_tree.vue' do - element :new_file + element :new_file_button + element :new_directory_button end view 'app/assets/javascripts/ide/components/ide_tree_list.vue' do @@ -83,6 +84,10 @@ module QA element :changed_file_icon_content end + view 'app/assets/javascripts/vue_shared/components/file_icon.vue' do + element :folder_icon_content + end + view 'app/assets/javascripts/vue_shared/components/content_viewer/content_viewer.vue' do element :preview_container end @@ -99,12 +104,20 @@ module QA element :file_upload_field end + view 'app/assets/javascripts/ide/components/commit_sidebar/list_item.vue' do + element :file_to_commit_content + end + def has_file?(file_name) within_element(:file_list) do - has_text?(file_name) + has_element?(:file_name_content, file_name: file_name) end end + def has_file_to_commit?(file_name) + has_element?(:file_to_commit_content, file_name: file_name) + end + def has_project_path?(project_path) has_element?(:project_path_content, project_path: project_path) end @@ -115,6 +128,12 @@ module QA end end + def has_folder_icon?(file_name) + within_element(:file_row_container, file_name: file_name) do + has_element?(:folder_icon_content) + end + end + def has_download_button?(file_name) click_element(:file_row_container, file_name: file_name) within_element(:preview_container) do @@ -141,7 +160,7 @@ module QA end def create_new_file_from_template(file_name, template) - click_element(:new_file, Page::Component::WebIDE::Modal::CreateNewFile) + click_element(:new_file_button, Page::Component::WebIDE::Modal::CreateNewFile) within_element(:template_list) do click_on file_name @@ -234,7 +253,7 @@ module QA end def add_file(file_name, file_text) - click_element(:new_file, Page::Component::WebIDE::Modal::CreateNewFile) + click_element(:new_file_button, Page::Component::WebIDE::Modal::CreateNewFile) fill_element(:file_name_field, file_name) click_button('Create file') wait_until(reload: false) { has_file?(file_name) } @@ -243,6 +262,13 @@ module QA end end + def add_directory(directory_name) + click_element(:new_directory_button, Page::Component::WebIDE::Modal::CreateNewFile) + fill_element(:file_name_field, directory_name) + click_button('Create directory') + wait_until(reload: false) { has_file?(directory_name) } + end + def rename_file(file_name, new_file_name) click_element(:file_name_content, file_name: file_name) click_element(:dropdown_button) @@ -273,6 +299,10 @@ module QA click_element(:dropdown_button) click_element(:delete_button) end + + def switch_to_commit_tab + click_element(:commit_mode_tab) + end end end end diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb new file mode 100644 index 00000000000..206b8e9aa71 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Add a directory in Web IDE' do + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'add-directory-project' + project.initialize_with_readme = true + end + end + + before do + Flow::Login.sign_in + + project.visit! + end + + context 'when a directory with the same name already exists' do + let(:directory_name) { 'first_directory' } + + before do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.add_files([ + { + file_path: 'first_directory/test_file.txt', + content: "Test file content" + } + ]) + end + + project.visit! + + Page::Project::Show.perform(&:open_web_ide!) + end + + it 'throws an error' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.add_directory(directory_name) + end + + expect(page).to have_content('The name "first_directory" is already taken in this directory.') + end + end + + context 'when user adds a new empty directory' do + let(:directory_name) { 'new_empty_directory' } + + before do + Page::Project::Show.perform(&:open_web_ide!) + end + + it 'shows in the tree view but cannot be committed' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.add_directory(directory_name) + + expect(ide).to have_file(directory_name) + expect(ide).to have_folder_icon(directory_name) + expect(ide).not_to have_file_addition_icon(directory_name) + + ide.switch_to_commit_tab + + expect(ide).not_to have_file_to_commit(directory_name) + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb index d62f894279f..0a342664dd2 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb @@ -22,7 +22,7 @@ module QA context 'when a file with the same name already exists' do let(:file_name) { 'README.md' } - it 'throws an error' do + it 'throws an error', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1136' do Page::Project::WebIDE::Edit.perform do |ide| ide.upload_file(file_path) end @@ -34,7 +34,7 @@ module QA context 'when the file is a text file' do let(:file_name) { 'text_file.txt' } - it 'shows the Edit tab with the text' do + it 'shows the Edit tab with the text', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1138' do Page::Project::WebIDE::Edit.perform do |ide| ide.upload_file(file_path) @@ -52,7 +52,7 @@ module QA context 'when the file is binary' do let(:file_name) { 'logo_sample.svg' } - it 'shows a Download button' do + it 'shows a Download button', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1137' do Page::Project::WebIDE::Edit.perform do |ide| ide.upload_file(file_path) @@ -70,7 +70,7 @@ module QA context 'when the file is an image' do let(:file_name) { 'dk.png' } - it 'shows an image viewer' do + it 'shows an image viewer', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1139' do Page::Project::WebIDE::Edit.perform do |ide| ide.upload_file(file_path) |