2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
RSpec.shared_examples 'it uploads and commits a new text file' do |drop: false|
|
2021-04-29 21:17:54 +05:30
|
|
|
it 'uploads and commits a new text file', :js do
|
2020-04-22 19:07:51 +05:30
|
|
|
find('.add-to-tree').click
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
page.within('.dropdown-menu') do
|
|
|
|
click_link('Upload file')
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
if drop
|
|
|
|
find(".upload-dropzone-card").drop(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
|
|
|
|
else
|
|
|
|
attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'), make_visible: true)
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
page.within('#modal-upload-blob') do
|
|
|
|
fill_in(:commit_message, with: 'New commit message')
|
|
|
|
end
|
|
|
|
|
|
|
|
fill_in(:branch_name, with: 'upload_text', visible: true)
|
|
|
|
click_button('Upload file')
|
|
|
|
|
|
|
|
expect(page).to have_content('New commit message')
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path(project_new_merge_request_path(project), ignore_query: true)
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
click_link('Changes')
|
|
|
|
find("a[data-action='diffs']", text: 'Changes').click
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content('Lorem ipsum dolor sit amet')
|
|
|
|
expect(page).to have_content('Sed ut perspiciatis unde omnis')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
RSpec.shared_examples 'it uploads and commits a new image file' do |drop: false|
|
2021-04-29 21:17:54 +05:30
|
|
|
it 'uploads and commits a new image file', :js do
|
2020-04-22 19:07:51 +05:30
|
|
|
find('.add-to-tree').click
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
page.within('.dropdown-menu') do
|
|
|
|
click_link('Upload file')
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
if drop
|
|
|
|
find(".upload-dropzone-card").drop(File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg'))
|
|
|
|
else
|
|
|
|
attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg'), make_visible: true)
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
page.within('#modal-upload-blob') do
|
|
|
|
fill_in(:commit_message, with: 'New commit message')
|
|
|
|
fill_in(:branch_name, with: 'upload_image', visible: true)
|
|
|
|
click_button('Upload file')
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_all_requests
|
|
|
|
|
|
|
|
visit(project_blob_path(project, 'upload_image/logo_sample.svg'))
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
expect(page).to have_css('.file-holder img')
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
RSpec.shared_examples 'it uploads and commits a new pdf file' do |drop: false|
|
2021-04-29 21:17:54 +05:30
|
|
|
it 'uploads and commits a new pdf file', :js do
|
|
|
|
find('.add-to-tree').click
|
|
|
|
|
|
|
|
page.within('.dropdown-menu') do
|
|
|
|
click_link('Upload file')
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
if drop
|
|
|
|
find(".upload-dropzone-card").drop(File.join(Rails.root, 'spec', 'fixtures', 'git-cheat-sheet.pdf'))
|
|
|
|
else
|
|
|
|
attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'git-cheat-sheet.pdf'), make_visible: true)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
page.within('#modal-upload-blob') do
|
|
|
|
fill_in(:commit_message, with: 'New commit message')
|
|
|
|
fill_in(:branch_name, with: 'upload_image', visible: true)
|
|
|
|
click_button('Upload file')
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_all_requests
|
|
|
|
|
|
|
|
visit(project_blob_path(project, 'upload_image/git-cheat-sheet.pdf'))
|
|
|
|
|
|
|
|
expect(page).to have_css('.js-pdf-viewer')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
RSpec.shared_examples 'it uploads and commits a new file to a forked project' do |drop: false|
|
2020-04-22 19:07:51 +05:30
|
|
|
let(:fork_message) do
|
|
|
|
"You're not allowed to make changes to this project directly. "\
|
|
|
|
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
|
|
|
|
end
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
it 'uploads and commits a new file to a forked project', :js, :sidekiq_might_not_need_inline do
|
2020-04-22 19:07:51 +05:30
|
|
|
find('.add-to-tree').click
|
|
|
|
click_link('Upload file')
|
|
|
|
|
|
|
|
expect(page).to have_content(fork_message)
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
wait_for_all_requests
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
find('.add-to-tree').click
|
|
|
|
click_link('Upload file')
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
if drop
|
|
|
|
find(".upload-dropzone-card").drop(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
|
|
|
|
else
|
|
|
|
attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'), make_visible: true)
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
page.within('#modal-upload-blob') do
|
|
|
|
fill_in(:commit_message, with: 'New commit message')
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button('Upload file')
|
|
|
|
|
|
|
|
expect(page).to have_content('New commit message')
|
|
|
|
|
|
|
|
fork = user.fork_of(project2.reload)
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path(project_new_merge_request_path(fork), ignore_query: true)
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
find("a[data-action='diffs']", text: 'Changes').click
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content('Lorem ipsum dolor sit amet')
|
|
|
|
expect(page).to have_content('Sed ut perspiciatis unde omnis')
|
|
|
|
end
|
|
|
|
end
|
2021-04-17 20:07:23 +05:30
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
RSpec.shared_examples 'it uploads a file to a sub-directory' do |drop: false|
|
2021-04-29 21:17:54 +05:30
|
|
|
it 'uploads a file to a sub-directory', :js do
|
|
|
|
click_link 'files'
|
|
|
|
|
|
|
|
page.within('.repo-breadcrumb') do
|
|
|
|
expect(page).to have_content('files')
|
|
|
|
end
|
|
|
|
|
|
|
|
find('.add-to-tree').click
|
|
|
|
click_link('Upload file')
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
if drop
|
|
|
|
find(".upload-dropzone-card").drop(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
|
|
|
|
else
|
|
|
|
attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'), make_visible: true)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
page.within('#modal-upload-blob') do
|
|
|
|
fill_in(:commit_message, with: 'New commit message')
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button('Upload file')
|
|
|
|
|
|
|
|
expect(page).to have_content('New commit message')
|
|
|
|
|
|
|
|
page.within('.repo-breadcrumb') do
|
|
|
|
expect(page).to have_content('files')
|
|
|
|
expect(page).to have_content('doc_sample.txt')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
RSpec.shared_examples 'uploads and commits a new text file via "upload file" button' do |drop: false|
|
2021-04-17 20:07:23 +05:30
|
|
|
it 'uploads and commits a new text file via "upload file" button', :js do
|
|
|
|
find('[data-testid="upload-file-button"]').click
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
if drop
|
|
|
|
find(".upload-dropzone-card").drop(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
|
|
|
|
else
|
|
|
|
attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'), make_visible: true)
|
|
|
|
end
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
page.within('#details-modal-upload-blob') do
|
|
|
|
fill_in(:commit_message, with: 'New commit message')
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button('Upload file')
|
|
|
|
|
|
|
|
expect(page).to have_content('New commit message')
|
|
|
|
expect(page).to have_content('Lorem ipsum dolor sit amet')
|
|
|
|
expect(page).to have_content('Sed ut perspiciatis unde omnis')
|
|
|
|
end
|
|
|
|
end
|