diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-18 12:10:41 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-18 12:10:41 +0000 |
commit | f23a9a17ed6237c346d2e9210c6841e319e8d030 (patch) | |
tree | 7b46c0ff193c445f35774a86ec3d0ff000d2ff77 /qa/qa/specs/features/browser_ui/3_create/web_ide | |
parent | d7432b66ff241af3f39d82da581832a084983378 (diff) | |
download | gitlab-ce-f23a9a17ed6237c346d2e9210c6841e319e8d030.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa/qa/specs/features/browser_ui/3_create/web_ide')
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb | 89 |
1 files changed, 89 insertions, 0 deletions
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 new file mode 100644 index 00000000000..d62f894279f --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Upload a file in Web IDE' do + let(:file_path) { File.absolute_path(File.join('qa', 'fixtures', 'web_ide', file_name)) } + + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'upload-file-project' + project.initialize_with_readme = true + end + end + + before do + Flow::Login.sign_in + + project.visit! + Page::Project::Show.perform(&:open_web_ide!) + end + + context 'when a file with the same name already exists' do + let(:file_name) { 'README.md' } + + it 'throws an error' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.upload_file(file_path) + end + + expect(page).to have_content('The name "README.md" is already taken in this directory.') + end + end + + context 'when the file is a text file' do + let(:file_name) { 'text_file.txt' } + + it 'shows the Edit tab with the text' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.upload_file(file_path) + + expect(ide).to have_file(file_name) + expect(ide).to have_file_addition_icon(file_name) + expect(ide).to have_text('Simple text') + + ide.commit_changes + + expect(ide).to have_file(file_name) + end + end + end + + context 'when the file is binary' do + let(:file_name) { 'logo_sample.svg' } + + it 'shows a Download button' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.upload_file(file_path) + + expect(ide).to have_file(file_name) + expect(ide).to have_file_addition_icon(file_name) + expect(ide).to have_download_button(file_name) + + ide.commit_changes + + expect(ide).to have_file(file_name) + end + end + end + + context 'when the file is an image' do + let(:file_name) { 'dk.png' } + + it 'shows an image viewer' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.upload_file(file_path) + + expect(ide).to have_file(file_name) + expect(ide).to have_file_addition_icon(file_name) + expect(ide).to have_image_viewer(file_name) + + ide.commit_changes + + expect(ide).to have_file(file_name) + end + end + end + end + end +end |