diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /spec/support/shared_examples/features | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/support/shared_examples/features')
3 files changed, 59 insertions, 30 deletions
diff --git a/spec/support/shared_examples/features/container_registry_shared_examples.rb b/spec/support/shared_examples/features/container_registry_shared_examples.rb new file mode 100644 index 00000000000..06b2b8c621c --- /dev/null +++ b/spec/support/shared_examples/features/container_registry_shared_examples.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'handling feature network errors with the container registry' do + it 'displays the error message' do + visit_container_registry + + expect(page).to have_content 'We are having trouble connecting to the Container Registry' + end +end diff --git a/spec/support/shared_examples/features/discussion_comments_shared_example.rb b/spec/support/shared_examples/features/discussion_comments_shared_example.rb index 318ba67b9e9..6c06cbf9082 100644 --- a/spec/support/shared_examples/features/discussion_comments_shared_example.rb +++ b/spec/support/shared_examples/features/discussion_comments_shared_example.rb @@ -3,9 +3,9 @@ RSpec.shared_examples 'thread comments for commit and snippet' do |resource_name| let(:form_selector) { '.js-main-target-form' } let(:dropdown_selector) { "#{form_selector} .comment-type-dropdown" } - let(:toggle_selector) { "#{dropdown_selector} .dropdown-toggle" } + let(:toggle_selector) { "#{dropdown_selector} .gl-dropdown-toggle" } let(:menu_selector) { "#{dropdown_selector} .dropdown-menu" } - let(:submit_selector) { "#{form_selector} .js-comment-submit-button" } + let(:submit_selector) { "#{form_selector} .js-comment-submit-button > button:first-child" } let(:close_selector) { "#{form_selector} .btn-comment-and-close" } let(:comments_selector) { '.timeline > .note.timeline-entry:not(.being-posted)' } let(:comment) { 'My comment' } @@ -43,13 +43,11 @@ RSpec.shared_examples 'thread comments for commit and snippet' do |resource_name expect(items.first).to have_content 'Comment' expect(items.first).to have_content "Add a general comment to this #{resource_name}." - expect(items.first).to have_selector '[data-testid="check-icon"]' - expect(items.first['class']).to match 'droplab-item-selected' + expect(items.first).to have_selector '[data-testid="dropdown-item-checkbox"]' expect(items.last).to have_content 'Start thread' expect(items.last).to have_content "Discuss a specific suggestion or question#{' that needs to be resolved' if resource_name == 'merge request'}." - expect(items.last).not_to have_selector '[data-testid="check-icon"]' - expect(items.last['class']).not_to match 'droplab-item-selected' + expect(items.last).not_to have_selector '[data-testid="dropdown-item-checkbox"]' end it 'closes the menu when clicking the toggle or body' do @@ -75,14 +73,14 @@ RSpec.shared_examples 'thread comments for commit and snippet' do |resource_name expect(find(dropdown_selector)).to have_content 'Comment' find(toggle_selector).click - execute_script("document.querySelector('#{menu_selector} .divider').click()") + execute_script("document.querySelector('#{menu_selector} .dropdown-divider').click()") else execute_script("document.querySelector('#{menu_selector}').click()") expect(page).to have_selector menu_selector expect(find(dropdown_selector)).to have_content 'Comment' - execute_script("document.querySelector('#{menu_selector} .divider').click()") + execute_script("document.querySelector('#{menu_selector} .dropdown-divider').click()") expect(page).to have_selector menu_selector end @@ -97,7 +95,7 @@ RSpec.shared_examples 'thread comments for commit and snippet' do |resource_name end it 'updates the submit button text and closes the dropdown' do - expect(find(submit_selector).value).to eq 'Start thread' + expect(find(submit_selector).text).to eq 'Start thread' expect(page).not_to have_selector menu_selector end @@ -137,12 +135,10 @@ RSpec.shared_examples 'thread comments for commit and snippet' do |resource_name items = all("#{menu_selector} li") expect(items.first).to have_content 'Comment' - expect(items.first).not_to have_selector '[data-testid="check-icon"]' - expect(items.first['class']).not_to match 'droplab-item-selected' + expect(items.first).not_to have_selector '[data-testid="dropdown-item-checkbox"]' expect(items.last).to have_content 'Start thread' - expect(items.last).to have_selector '[data-testid="check-icon"]' - expect(items.last['class']).to match 'droplab-item-selected' + expect(items.last).to have_selector '[data-testid="dropdown-item-checkbox"]' end describe 'when selecting "Comment"' do @@ -153,7 +149,7 @@ RSpec.shared_examples 'thread comments for commit and snippet' do |resource_name it 'updates the submit button text and closes the dropdown' do button = find(submit_selector) - expect(button.value).to eq 'Comment' + expect(button.text).to eq 'Comment' expect(page).not_to have_selector menu_selector end @@ -166,12 +162,10 @@ RSpec.shared_examples 'thread comments for commit and snippet' do |resource_name aggregate_failures do expect(items.first).to have_content 'Comment' - expect(items.first).to have_selector '[data-testid="check-icon"]' - expect(items.first['class']).to match 'droplab-item-selected' + expect(items.first).to have_selector '[data-testid="dropdown-item-checkbox"]' expect(items.last).to have_content 'Start thread' - expect(items.last).not_to have_selector '[data-testid="check-icon"]' - expect(items.last['class']).not_to match 'droplab-item-selected' + expect(items.last).not_to have_selector '[data-testid="dropdown-item-checkbox"]' end end end diff --git a/spec/support/shared_examples/features/project_upload_files_shared_examples.rb b/spec/support/shared_examples/features/project_upload_files_shared_examples.rb index 7adf303bde4..85434ba7afd 100644 --- a/spec/support/shared_examples/features/project_upload_files_shared_examples.rb +++ b/spec/support/shared_examples/features/project_upload_files_shared_examples.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.shared_examples 'it uploads and commits a new text file' do +RSpec.shared_examples 'it uploads and commits a new text file' do |drop: false| it 'uploads and commits a new text file', :js do find('.add-to-tree').click @@ -10,7 +10,11 @@ RSpec.shared_examples 'it uploads and commits a new text file' do wait_for_requests end - attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'), make_visible: true) + 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 page.within('#modal-upload-blob') do fill_in(:commit_message, with: 'New commit message') @@ -32,7 +36,7 @@ RSpec.shared_examples 'it uploads and commits a new text file' do end end -RSpec.shared_examples 'it uploads and commits a new image file' do +RSpec.shared_examples 'it uploads and commits a new image file' do |drop: false| it 'uploads and commits a new image file', :js do find('.add-to-tree').click @@ -42,7 +46,11 @@ RSpec.shared_examples 'it uploads and commits a new image file' do wait_for_requests end - attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg'), make_visible: true) + 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 page.within('#modal-upload-blob') do fill_in(:commit_message, with: 'New commit message') @@ -58,7 +66,7 @@ RSpec.shared_examples 'it uploads and commits a new image file' do end end -RSpec.shared_examples 'it uploads and commits a new pdf file' do +RSpec.shared_examples 'it uploads and commits a new pdf file' do |drop: false| it 'uploads and commits a new pdf file', :js do find('.add-to-tree').click @@ -68,7 +76,11 @@ RSpec.shared_examples 'it uploads and commits a new pdf file' do wait_for_requests end - attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'git-cheat-sheet.pdf'), make_visible: true) + 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 page.within('#modal-upload-blob') do fill_in(:commit_message, with: 'New commit message') @@ -84,7 +96,7 @@ RSpec.shared_examples 'it uploads and commits a new pdf file' do end end -RSpec.shared_examples 'it uploads and commits a new file to a forked project' do +RSpec.shared_examples 'it uploads and commits a new file to a forked project' do |drop: false| 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." @@ -100,7 +112,12 @@ RSpec.shared_examples 'it uploads and commits a new file to a forked project' do find('.add-to-tree').click click_link('Upload file') - attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'), make_visible: true) + + 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 page.within('#modal-upload-blob') do fill_in(:commit_message, with: 'New commit message') @@ -123,7 +140,7 @@ RSpec.shared_examples 'it uploads and commits a new file to a forked project' do end end -RSpec.shared_examples 'it uploads a file to a sub-directory' do +RSpec.shared_examples 'it uploads a file to a sub-directory' do |drop: false| it 'uploads a file to a sub-directory', :js do click_link 'files' @@ -133,7 +150,12 @@ RSpec.shared_examples 'it uploads a file to a sub-directory' do find('.add-to-tree').click click_link('Upload file') - attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'), make_visible: true) + + 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 page.within('#modal-upload-blob') do fill_in(:commit_message, with: 'New commit message') @@ -150,11 +172,15 @@ RSpec.shared_examples 'it uploads a file to a sub-directory' do end end -RSpec.shared_examples 'uploads and commits a new text file via "upload file" button' do +RSpec.shared_examples 'uploads and commits a new text file via "upload file" button' do |drop: false| it 'uploads and commits a new text file via "upload file" button', :js do find('[data-testid="upload-file-button"]').click - attach_file('upload_file', File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'), make_visible: true) + 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 page.within('#details-modal-upload-blob') do fill_in(:commit_message, with: 'New commit message') |