Commit fff1ad81 authored by Jay Swain's avatar Jay Swain

Adding additional test case for upload file button

After some recent breakage in the upload file button, I noticed that I
failed to test the breaking context (nonempty repo).

This MR backfills that context.

part of:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52755
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53623
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55548
parent e367975a
......@@ -34,33 +34,23 @@ RSpec.describe 'Projects > Show > User uploads files' do
include_examples 'it uploads and commit a new file to a forked project'
end
context 'with an empty repo' do
let(:project) { create(:project, :empty_repo, creator: user) }
context 'when in the empty_repo_upload experiment' do
before do
stub_experiments(empty_repo_upload: :candidate)
visit(project_path(project))
end
it 'uploads and commits a new text file', :js do
click_link('Upload file')
context 'when in the empty_repo_upload experiment' do
before do
stub_experiments(empty_repo_upload: :candidate)
drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
visit(project_path(project))
end
page.within('#modal-upload-blob') do
fill_in(:commit_message, with: 'New commit message')
end
context 'with an empty repo' do
let(:project) { create(:project, :empty_repo, creator: user) }
click_button('Upload file')
include_examples 'uploads and commits a new text file via "upload file" button'
end
wait_for_requests
context 'with a nonempty repo' do
let(:project) { create(:project, :repository, creator: user) }
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
include_examples 'uploads and commits a new text file via "upload file" button'
end
end
end
......@@ -94,3 +94,23 @@ RSpec.shared_examples 'it uploads and commit a new file to a forked project' do
expect(page).to have_content('Sed ut perspiciatis unde omnis')
end
end
RSpec.shared_examples 'uploads and commits a new text file via "upload file" button' do
it 'uploads and commits a new text file via "upload file" button', :js do
find('.js-upload-file-experiment-trigger', text: 'Upload file').click
drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
page.within('#modal-upload-blob') do
fill_in(:commit_message, with: 'New commit message')
end
click_button('Upload file')
wait_for_requests
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment