summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/features
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /spec/support/shared_examples/features
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/support/shared_examples/features')
-rw-r--r--spec/support/shared_examples/features/cascading_settings_shared_examples.rb18
-rw-r--r--spec/support/shared_examples/features/packages_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb21
-rw-r--r--spec/support/shared_examples/features/sidebar_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb11
-rw-r--r--spec/support/shared_examples/features/wiki/user_deletes_wiki_page_shared_examples.rb26
-rw-r--r--spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb13
7 files changed, 59 insertions, 44 deletions
diff --git a/spec/support/shared_examples/features/cascading_settings_shared_examples.rb b/spec/support/shared_examples/features/cascading_settings_shared_examples.rb
index 29ef3da9a85..395f4fc54e0 100644
--- a/spec/support/shared_examples/features/cascading_settings_shared_examples.rb
+++ b/spec/support/shared_examples/features/cascading_settings_shared_examples.rb
@@ -13,10 +13,22 @@ RSpec.shared_examples 'a cascading setting' do
click_save_button
end
- it 'disables setting in subgroups' do
- visit subgroup_path
+ shared_examples 'subgroup settings are disabled' do
+ it 'disables setting in subgroups' do
+ visit subgroup_path
+
+ expect(find("#{setting_field_selector}[disabled]")).to be_checked
+ end
+ end
+
+ include_examples 'subgroup settings are disabled'
+
+ context 'when use_traversal_ids_for_ancestors is disabled' do
+ before do
+ stub_feature_flags(use_traversal_ids_for_ancestors: false)
+ end
- expect(find("#{setting_field_selector}[disabled]")).to be_checked
+ include_examples 'subgroup settings are disabled'
end
it 'does not show enforcement checkbox in subgroups' do
diff --git a/spec/support/shared_examples/features/packages_shared_examples.rb b/spec/support/shared_examples/features/packages_shared_examples.rb
index 4d2e13aa5bc..9e88db2e1c0 100644
--- a/spec/support/shared_examples/features/packages_shared_examples.rb
+++ b/spec/support/shared_examples/features/packages_shared_examples.rb
@@ -32,11 +32,9 @@ RSpec.shared_examples 'package details link' do |property|
expect(page).to have_current_path(project_package_path(package.project, package))
- page.within('[data-qa-selector="package_title"]') do
- expect(page).to have_content(package.name)
- end
+ expect(page).to have_css('.packages-app h1[data-testid="title"]', text: package.name)
- page.within('[data-qa-selector="package_information_content"]') do
+ page.within(%Q([name="#{package.name}"])) do
expect(page).to have_content('Installation')
expect(page).to have_content('Registry setup')
end
diff --git a/spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb b/spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb
new file mode 100644
index 00000000000..bb5460e2a6f
--- /dev/null
+++ b/spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'search timeouts' do |scope|
+ context 'when search times out' do
+ before do
+ allow_next_instance_of(SearchService) do |service|
+ allow(service).to receive(:search_objects).and_raise(ActiveRecord::QueryCanceled)
+ end
+
+ visit(search_path(search: 'test', scope: scope))
+ end
+
+ it 'renders timeout information' do
+ expect(page).to have_content('Your search timed out')
+ end
+
+ it 'sets tab count to 0' do
+ expect(page.find('.search-filter .active')).to have_text('0')
+ end
+ end
+end
diff --git a/spec/support/shared_examples/features/sidebar_shared_examples.rb b/spec/support/shared_examples/features/sidebar_shared_examples.rb
index c9508818f74..5bfe929e957 100644
--- a/spec/support/shared_examples/features/sidebar_shared_examples.rb
+++ b/spec/support/shared_examples/features/sidebar_shared_examples.rb
@@ -175,12 +175,4 @@ RSpec.shared_examples 'issue boards sidebar' do
end
end
end
-
- def refresh_and_click_first_card
- page.refresh
-
- wait_for_requests
-
- first_card.click
- end
end
diff --git a/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb
index f2576931642..dfc9a45bd0d 100644
--- a/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb
+++ b/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb
@@ -20,17 +20,6 @@ RSpec.shared_examples 'User creates wiki page' do
click_link "Create your first page"
end
- it "shows validation error message if the form is force submitted", :js do
- page.within(".wiki-form") do
- fill_in(:wiki_content, with: "")
-
- page.execute_script("document.querySelector('.wiki-form').submit()")
- page.accept_alert # manually force form submit
- end
-
- expect(page).to have_content("The form contains the following error:").and have_content("Content can't be blank")
- end
-
it "disables the submit button", :js do
page.within(".wiki-form") do
fill_in(:wiki_content, with: "")
diff --git a/spec/support/shared_examples/features/wiki/user_deletes_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_deletes_wiki_page_shared_examples.rb
index ee0261771f9..55c89977a99 100644
--- a/spec/support/shared_examples/features/wiki/user_deletes_wiki_page_shared_examples.rb
+++ b/spec/support/shared_examples/features/wiki/user_deletes_wiki_page_shared_examples.rb
@@ -7,18 +7,34 @@
RSpec.shared_examples 'User deletes wiki page' do
include WikiHelpers
+ let_it_be(:developer) { create(:user) }
+
let(:wiki_page) { create(:wiki_page, wiki: wiki) }
before do
+ wiki.container.add_developer(developer)
+
sign_in(user)
visit wiki_page_path(wiki, wiki_page)
end
- it 'deletes a page', :js do
- click_on('Edit')
- click_on('Delete')
- find('[data-testid="confirm_deletion_button"]').click
+ shared_examples 'deletes a wiki page' do
+ specify 'deletes a page', :js do
+ click_on('Edit')
+ click_on('Delete')
+ find('[data-testid="confirm_deletion_button"]').click
+
+ expect(page).to have_content('Wiki page was successfully deleted.')
+ end
+ end
+
+ context 'when user is the owner or maintainer' do
+ it_behaves_like 'deletes a wiki page'
+ end
+
+ context 'when user is a developer' do
+ let(:user) { developer }
- expect(page).to have_content('Wiki page was successfully deleted.')
+ it_behaves_like 'deletes a wiki page'
end
end
diff --git a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb
index db2a96d9649..9587da0233e 100644
--- a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb
+++ b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb
@@ -90,19 +90,6 @@ RSpec.shared_examples 'User updates wiki page' do
expect(page).to have_field('wiki[message]', with: 'Update Wiki title')
end
- it 'shows a validation error message if the form is force submitted', :js do
- fill_in(:wiki_content, with: '')
-
- page.execute_script("document.querySelector('.wiki-form').submit()")
- page.accept_alert # manually force form submit
-
- expect(page).to have_selector('.wiki-form')
- expect(page).to have_content('Edit Page')
- expect(page).to have_content('The form contains the following error:')
- expect(page).to have_content("Content can't be blank")
- expect(find('textarea#wiki_content').value).to eq('')
- end
-
it "disables the submit button", :js do
page.within(".wiki-form") do
fill_in(:wiki_content, with: "")