From e28a66ff74e2b77b96b95b8e50ecda3cdc20ebe9 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Mon, 16 Dec 2024 13:30:30 -0600 Subject: [PATCH] Simplify capybara wait time helper --- spec/features/item_admin_spec.rb | 2 +- .../blocks/oembed_and_text_block_spec.rb | 2 +- .../blocks/solr_documents_block_spec.rb | 2 +- .../features/javascript/edit_in_place_spec.rb | 2 +- .../javascript/multi_image_select_spec.rb | 2 +- .../javascript/reindex_monitor_spec.rb | 2 +- .../javascript/search_config_admin_spec.rb | 2 +- spec/spec_helper.rb | 2 +- ...pybara_default_max_wait_metadata_helper.rb | 20 ------------------- .../features/capybara_wait_metadata_helper.rb | 13 ++++++++++++ 10 files changed, 21 insertions(+), 28 deletions(-) delete mode 100644 spec/support/features/capybara_default_max_wait_metadata_helper.rb create mode 100644 spec/support/features/capybara_wait_metadata_helper.rb diff --git a/spec/features/item_admin_spec.rb b/spec/features/item_admin_spec.rb index 20c9a9144..1bbcb6d08 100644 --- a/spec/features/item_admin_spec.rb +++ b/spec/features/item_admin_spec.rb @@ -38,7 +38,7 @@ item.click_button 'Make public' end - it "toggles the 'blacklight-private' label", default_max_wait_time: 5, js: true do + it "toggles the 'blacklight-private' label", max_wait_time: 5, js: true do visit spotlight.admin_exhibit_catalog_path(exhibit) # The label should be toggled when the checkbox is clicked expect(page).to have_no_css('tr.blacklight-private') diff --git a/spec/features/javascript/blocks/oembed_and_text_block_spec.rb b/spec/features/javascript/blocks/oembed_and_text_block_spec.rb index 532a3a05d..06e0b180e 100644 --- a/spec/features/javascript/blocks/oembed_and_text_block_spec.rb +++ b/spec/features/javascript/blocks/oembed_and_text_block_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe 'Oembed and text block', default_max_wait_time: 15, feature: true, versioning: true do +describe 'Oembed and text block', max_wait_time: 15, feature: true, versioning: true do let(:exhibit) { FactoryBot.create(:exhibit) } let(:exhibit_curator) { FactoryBot.create(:exhibit_curator, exhibit:) } let(:feature_page) do diff --git a/spec/features/javascript/blocks/solr_documents_block_spec.rb b/spec/features/javascript/blocks/solr_documents_block_spec.rb index 8c8bee082..6c45d3743 100644 --- a/spec/features/javascript/blocks/solr_documents_block_spec.rb +++ b/spec/features/javascript/blocks/solr_documents_block_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe 'Solr Document Block', default_max_wait_time: 30, feature: true, versioning: true do +RSpec.describe 'Solr Document Block', max_wait_time: 30, feature: true, versioning: true do let(:exhibit) { FactoryBot.create(:exhibit) } let(:exhibit_curator) { FactoryBot.create(:exhibit_curator, exhibit:) } let(:feature_page) do diff --git a/spec/features/javascript/edit_in_place_spec.rb b/spec/features/javascript/edit_in_place_spec.rb index a42e4d831..63e74da89 100644 --- a/spec/features/javascript/edit_in_place_spec.rb +++ b/spec/features/javascript/edit_in_place_spec.rb @@ -90,7 +90,7 @@ end end - it 'updates the metadata label', default_max_wait_time: 10 do + it 'updates the metadata label', max_wait_time: 10 do visit spotlight.exhibit_dashboard_path(exhibit) within '#sidebar' do diff --git a/spec/features/javascript/multi_image_select_spec.rb b/spec/features/javascript/multi_image_select_spec.rb index 582737f8a..b8fbcd244 100644 --- a/spec/features/javascript/multi_image_select_spec.rb +++ b/spec/features/javascript/multi_image_select_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe 'Multi image selector', default_max_wait_time: 5, js: true, type: :feature, versioning: true do +RSpec.describe 'Multi image selector', max_wait_time: 5, js: true, type: :feature, versioning: true do let(:exhibit) { FactoryBot.create(:exhibit) } let(:exhibit_curator) { FactoryBot.create(:exhibit_curator, exhibit:) } let(:feature_page) { FactoryBot.create(:feature_page, exhibit:) } diff --git a/spec/features/javascript/reindex_monitor_spec.rb b/spec/features/javascript/reindex_monitor_spec.rb index b2990f4bd..de3e76cf1 100644 --- a/spec/features/javascript/reindex_monitor_spec.rb +++ b/spec/features/javascript/reindex_monitor_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe 'Reindex Monitor', default_max_wait_time: 10, js: true do +describe 'Reindex Monitor', max_wait_time: 10, js: true do let(:resources) do FactoryBot.create_list(:resource, 1) end diff --git a/spec/features/javascript/search_config_admin_spec.rb b/spec/features/javascript/search_config_admin_spec.rb index a9fc611db..668f95fc4 100644 --- a/spec/features/javascript/search_config_admin_spec.rb +++ b/spec/features/javascript/search_config_admin_spec.rb @@ -6,7 +6,7 @@ before { login_as user } - describe 'search fields', default_max_wait_time: 5 do + describe 'search fields', max_wait_time: 5 do it 'allows the curator to disable all search fields' do visit spotlight.exhibit_home_page_path(exhibit, exhibit.home_page) expect(page).to have_css 'select#search_field' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a60b6632d..e59ea6e01 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -87,7 +87,7 @@ config.include Rails.application.routes.url_helpers config.include Rails.application.routes.mounted_helpers config.include Spotlight::TestFeaturesHelpers, type: :feature - config.include CapybaraDefaultMaxWaitMetadataHelper, type: :feature + config.include CapybaraWaitMetadataHelper, type: :feature config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true diff --git a/spec/support/features/capybara_default_max_wait_metadata_helper.rb b/spec/support/features/capybara_default_max_wait_metadata_helper.rb deleted file mode 100644 index 239993ecf..000000000 --- a/spec/support/features/capybara_default_max_wait_metadata_helper.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -module CapybaraDefaultMaxWaitMetadataHelper - extend ActiveSupport::Concern - - included do - before do |example| - next unless example.metadata[:default_max_wait_time] - - @previous_wait_time = Capybara.default_max_wait_time - Capybara.default_max_wait_time = example.metadata[:default_max_wait_time] - end - - after do |example| - next unless example.metadata[:default_max_wait_time] - - Capybara.default_max_wait_time = @previous_wait_time - end - end -end diff --git a/spec/support/features/capybara_wait_metadata_helper.rb b/spec/support/features/capybara_wait_metadata_helper.rb new file mode 100644 index 000000000..bdf28ddfe --- /dev/null +++ b/spec/support/features/capybara_wait_metadata_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module CapybaraWaitMetadataHelper + extend ActiveSupport::Concern + + included do + around do |example| + using_wait_time example.metadata[:max_wait_time] || Capybara.default_max_wait_time do + example.run + end + end + end +end