diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/support/shared_examples/features | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/support/shared_examples/features')
9 files changed, 120 insertions, 19 deletions
diff --git a/spec/support/shared_examples/features/dependency_proxy_shared_examples.rb b/spec/support/shared_examples/features/dependency_proxy_shared_examples.rb new file mode 100644 index 00000000000..d29c677a962 --- /dev/null +++ b/spec/support/shared_examples/features/dependency_proxy_shared_examples.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'a successful blob pull' do + it 'sends a file' do + expect(controller).to receive(:send_file).with(blob.file.path, {}) + + subject + end + + it 'returns Content-Disposition: attachment', :aggregate_failures do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response.headers['Content-Disposition']).to match(/^attachment/) + end +end + +RSpec.shared_examples 'a successful manifest pull' do + it 'sends a file' do + expect(controller).to receive(:send_file).with(manifest.file.path, type: manifest.content_type) + + subject + end + + it 'returns Content-Disposition: attachment', :aggregate_failures do + subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response.headers['Docker-Content-Digest']).to eq(manifest.digest) + expect(response.headers['Content-Length']).to eq(manifest.size) + expect(response.headers['Docker-Distribution-Api-Version']).to eq(DependencyProxy::DISTRIBUTION_API_VERSION) + expect(response.headers['Etag']).to eq("\"#{manifest.digest}\"") + expect(response.headers['Content-Disposition']).to match(/^attachment/) + 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 ff2878f77b4..fb2e422559d 100644 --- a/spec/support/shared_examples/features/discussion_comments_shared_example.rb +++ b/spec/support/shared_examples/features/discussion_comments_shared_example.rb @@ -308,7 +308,7 @@ RSpec.shared_examples 'thread comments for issue, epic and merge request' do |re let(:reply_id) { find("#{comments_selector} .note:last-of-type", match: :first)['data-note-id'] } it 'can be replied to after resolving' do - find('button[data-qa-selector="resolve_discussion_button"]').click + find('button[data-qa-selector="resolve_discussion_button"]').click # rubocop:disable QA/SelectorUsage wait_for_requests refresh @@ -320,7 +320,7 @@ RSpec.shared_examples 'thread comments for issue, epic and merge request' do |re it 'shows resolved thread when toggled' do submit_reply('a') - find('button[data-qa-selector="resolve_discussion_button"]').click + find('button[data-qa-selector="resolve_discussion_button"]').click # rubocop:disable QA/SelectorUsage wait_for_requests expect(page).to have_selector(".note-row-#{note_id}", visible: true) diff --git a/spec/support/shared_examples/features/manage_applications_shared_examples.rb b/spec/support/shared_examples/features/manage_applications_shared_examples.rb new file mode 100644 index 00000000000..38bb87eaed2 --- /dev/null +++ b/spec/support/shared_examples/features/manage_applications_shared_examples.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'manage applications' do + let_it_be(:application_name) { 'application foo bar' } + let_it_be(:application_name_changed) { "#{application_name} changed" } + let_it_be(:application_redirect_uri) { 'https://foo.bar' } + + it 'allows user to manage applications' do + visit new_application_path + + expect(page).to have_content 'Add new application' + + fill_in :doorkeeper_application_name, with: application_name + fill_in :doorkeeper_application_redirect_uri, with: application_redirect_uri + check :doorkeeper_application_scopes_read_user + click_on 'Save application' + + validate_application(application_name, 'Yes') + + application = Doorkeeper::Application.find_by(name: application_name) + expect(page).to have_css("button[title=\"Copy secret\"][data-clipboard-text=\"#{application.secret}\"]", text: 'Copy') + + click_on 'Edit' + + application_name_changed = "#{application_name} changed" + + fill_in :doorkeeper_application_name, with: application_name_changed + uncheck :doorkeeper_application_confidential + click_on 'Save application' + + validate_application(application_name_changed, 'No') + + visit_applications_path + + page.within '.oauth-applications' do + click_on 'Destroy' + end + expect(page.find('.oauth-applications')).not_to have_content 'test_changed' + end + + context 'when scopes are blank' do + it 'returns an error' do + visit new_application_path + + expect(page).to have_content 'Add new application' + + fill_in :doorkeeper_application_name, with: application_name + fill_in :doorkeeper_application_redirect_uri, with: application_redirect_uri + click_on 'Save application' + + expect(page).to have_content("Scopes can't be blank") + end + end + + def visit_applications_path + visit defined?(applications_path) ? applications_path : new_application_path + end + + def validate_application(name, confidential) + aggregate_failures do + expect(page).to have_content name + expect(page).to have_content 'Application ID' + expect(page).to have_content 'Secret' + expect(page).to have_content "Confidential #{confidential}" + end + end +end diff --git a/spec/support/shared_examples/features/packages_shared_examples.rb b/spec/support/shared_examples/features/packages_shared_examples.rb index 9e88db2e1c0..96be30b9f1f 100644 --- a/spec/support/shared_examples/features/packages_shared_examples.rb +++ b/spec/support/shared_examples/features/packages_shared_examples.rb @@ -14,7 +14,7 @@ RSpec.shared_examples 'packages list' do |check_project_name: false| end def package_table_row(index) - page.all("#{packages_table_selector} > [data-qa-selector=\"package_row\"]")[index].text + page.all("#{packages_table_selector} > [data-qa-selector=\"package_row\"]")[index].text # rubocop:disable QA/SelectorUsage end end @@ -34,10 +34,8 @@ RSpec.shared_examples 'package details link' do |property| expect(page).to have_css('.packages-app h1[data-testid="title"]', text: package.name) - page.within(%Q([name="#{package.name}"])) do - expect(page).to have_content('Installation') - expect(page).to have_content('Registry setup') - end + expect(page).to have_content('Installation') + expect(page).to have_content('Registry setup') end end @@ -92,7 +90,7 @@ RSpec.shared_examples 'shared package sorting' do end def packages_table_selector - '[data-qa-selector="packages-table"]' + '[data-qa-selector="packages-table"]' # rubocop:disable QA/SelectorUsage end def click_sort_option(option, ascending) @@ -100,7 +98,7 @@ def click_sort_option(option, ascending) # Reset the sort direction click_button 'Sort direction' if page.has_selector?('svg[aria-label="Sorting Direction: Ascending"]', wait: 0) - find('button.dropdown-menu-toggle').click + find('button.gl-dropdown-toggle').click page.within('.dropdown-menu') do click_button option diff --git a/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb b/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb index 56154c7cd03..8212f14d6be 100644 --- a/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb +++ b/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb @@ -23,6 +23,7 @@ RSpec.shared_examples "protected branches > access control > CE" do end click_on_protect + wait_for_requests expect(ProtectedBranch.count).to eq(1) expect(ProtectedBranch.last.push_access_levels.map(&:access_level)).to eq([access_type_id]) diff --git a/spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb b/spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb index 28fe198c9c3..14142793a0d 100644 --- a/spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb +++ b/spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb @@ -23,7 +23,7 @@ RSpec.shared_examples 'Deploy keys with protected branches' do find(".js-allowed-to-push").click wait_for_requests - within('.qa-allowed-to-push-dropdown') do + within('.qa-allowed-to-push-dropdown') do # rubocop:disable QA/SelectorUsage dropdown_headers = page.all('.dropdown-header').map(&:text) expect(dropdown_headers).to contain_exactly(*all_dropdown_sections) @@ -38,7 +38,7 @@ RSpec.shared_examples 'Deploy keys with protected branches' do find(".js-allowed-to-merge").click wait_for_requests - within('.qa-allowed-to-merge-dropdown') do + within('.qa-allowed-to-merge-dropdown') do # rubocop:disable QA/SelectorUsage dropdown_headers = page.all('.dropdown-header').map(&:text) expect(dropdown_headers).to contain_exactly(*dropdown_sections_minus_deploy_keys) @@ -68,7 +68,7 @@ RSpec.shared_examples 'Deploy keys with protected branches' do find(".js-allowed-to-push").click wait_for_requests - within('.qa-allowed-to-push-dropdown') do + within('.qa-allowed-to-push-dropdown') do # rubocop:disable QA/SelectorUsage dropdown_headers = page.all('.dropdown-header').map(&:text) expect(dropdown_headers).to contain_exactly(*dropdown_sections_minus_deploy_keys) diff --git a/spec/support/shared_examples/features/rss_shared_examples.rb b/spec/support/shared_examples/features/rss_shared_examples.rb index 1b0d3f9605a..c7c2aeea358 100644 --- a/spec/support/shared_examples/features/rss_shared_examples.rb +++ b/spec/support/shared_examples/features/rss_shared_examples.rb @@ -9,7 +9,7 @@ end RSpec.shared_examples "it has an RSS button with current_user's feed token" do it "shows the RSS button with current_user's feed token" do expect(page) - .to have_css("a:has(.qa-rss-icon)[href*='feed_token=#{user.feed_token}']") + .to have_css("a:has(.qa-rss-icon)[href*='feed_token=#{user.feed_token}']") # rubocop:disable QA/SelectorUsage end end @@ -22,6 +22,6 @@ end RSpec.shared_examples "it has an RSS button without a feed token" do it "shows the RSS button without a feed token" do expect(page) - .to have_css("a:has(.qa-rss-icon):not([href*='feed_token'])") + .to have_css("a:has(.qa-rss-icon):not([href*='feed_token'])") # rubocop:disable QA/SelectorUsage end end diff --git a/spec/support/shared_examples/features/variable_list_shared_examples.rb b/spec/support/shared_examples/features/variable_list_shared_examples.rb index 997500415a9..52451839281 100644 --- a/spec/support/shared_examples/features/variable_list_shared_examples.rb +++ b/spec/support/shared_examples/features/variable_list_shared_examples.rb @@ -91,7 +91,7 @@ RSpec.shared_examples 'variable list' do end page.within('#add-ci-variable') do - find('[data-qa-selector="ci_variable_key_field"] input').set('new_key') + find('[data-qa-selector="ci_variable_key_field"] input').set('new_key') # rubocop:disable QA/SelectorUsage click_button('Update variable') end @@ -173,7 +173,7 @@ RSpec.shared_examples 'variable list' do click_button('Add variable') page.within('#add-ci-variable') do - find('[data-qa-selector="ci_variable_key_field"] input').set('empty_mask_key') + find('[data-qa-selector="ci_variable_key_field"] input').set('empty_mask_key') # rubocop:disable QA/SelectorUsage find('[data-testid="ci-variable-protected-checkbox"]').click find('[data-testid="ci-variable-masked-checkbox"]').click @@ -286,8 +286,8 @@ RSpec.shared_examples 'variable list' do wait_for_requests page.within('#add-ci-variable') do - find('[data-qa-selector="ci_variable_key_field"] input').set(key) - find('[data-qa-selector="ci_variable_value_field"]').set(value) if value.present? + find('[data-qa-selector="ci_variable_key_field"] input').set(key) # rubocop:disable QA/SelectorUsage + find('[data-qa-selector="ci_variable_value_field"]').set(value) if value.present? # rubocop:disable QA/SelectorUsage find('[data-testid="ci-variable-protected-checkbox"]').click if protected find('[data-testid="ci-variable-masked-checkbox"]').click if masked diff --git a/spec/support/shared_examples/features/wiki/user_views_asciidoc_page_with_includes_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_views_asciidoc_page_with_includes_shared_examples.rb index 3b2fda4e05b..6fdc5ecae73 100644 --- a/spec/support/shared_examples/features/wiki/user_views_asciidoc_page_with_includes_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_views_asciidoc_page_with_includes_shared_examples.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.shared_examples 'User views AsciiDoc page with includes' do - let_it_be(:wiki_content_selector) { '[data-qa-selector=wiki_page_content]' } + let_it_be(:wiki_content_selector) { '[data-qa-selector=wiki_page_content]' } # rubocop:disable QA/SelectorUsage let!(:included_wiki_page) { create_wiki_page('included_page', content: 'Content from the included page')} let!(:wiki_page) { create_wiki_page('home', content: "Content from the main page.\ninclude::included_page.asciidoc[]") } |