blacklight 8.11.0 → 9.0.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env +3 -3
- data/.github/matrix.json +11 -42
- data/.github/pull_request_template.md +7 -0
- data/.github/workflows/main.yml +0 -2
- data/.github/workflows/release_7_x_scheduled.yml +39 -0
- data/.github/workflows/release_8_x_scheduled.yml +39 -0
- data/.github/workflows/test.yml +0 -5
- data/.rubocop.yml +71 -3
- data/.rubocop_todo.yml +43 -76
- data/.solr_wrapper.yml +2 -0
- data/README.md +30 -8
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +452 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js +6 -76
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +6 -76
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -4
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -3
- data/app/assets/stylesheets/blacklight/_bookmark.scss +44 -41
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -25
- data/app/assets/stylesheets/blacklight/_constraints.scss +15 -24
- data/app/assets/stylesheets/blacklight/_controls.scss +2 -18
- data/app/assets/stylesheets/blacklight/_facets.scss +17 -84
- data/app/assets/stylesheets/blacklight/_group.scss +2 -5
- data/app/assets/stylesheets/blacklight/_header.scss +8 -11
- data/app/assets/stylesheets/blacklight/_icons.scss +0 -8
- data/app/assets/stylesheets/blacklight/_modal.scss +1 -1
- data/app/assets/stylesheets/blacklight/_pagination.scss +0 -4
- data/app/assets/stylesheets/blacklight/_search_form.scss +0 -1
- data/app/assets/stylesheets/blacklight/_search_history.scss +0 -8
- data/app/assets/stylesheets/blacklight/_search_results.scss +1 -15
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +9 -14
- data/app/assets/stylesheets/blacklight/build.scss +4 -0
- data/app/components/blacklight/advanced_search_form_component.rb +3 -3
- data/app/components/blacklight/constraint_component.rb +1 -1
- data/app/components/blacklight/constraint_layout_component.html.erb +2 -2
- data/app/components/blacklight/constraints_component.html.erb +2 -2
- data/app/components/blacklight/constraints_component.rb +3 -3
- data/app/components/blacklight/document/bookmark_component.html.erb +3 -3
- data/app/components/blacklight/document/bookmark_component.rb +2 -2
- data/app/components/blacklight/document/group_component.html.erb +1 -1
- data/app/components/blacklight/document/more_like_this_component.rb +2 -2
- data/app/components/blacklight/document/page_header_component.rb +1 -1
- data/app/components/blacklight/document/sidebar_component.rb +5 -5
- data/app/components/blacklight/document/thumbnail_component.html.erb +3 -7
- data/app/components/blacklight/document/thumbnail_component.rb +7 -6
- data/app/components/blacklight/document_component.rb +12 -16
- data/app/components/blacklight/document_title_component.rb +5 -11
- data/app/components/blacklight/facet_field_checkboxes_component.rb +2 -20
- data/app/components/blacklight/facet_field_component.rb +2 -17
- data/app/components/blacklight/facet_field_filter_component.rb +2 -21
- data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +4 -25
- data/app/components/blacklight/facet_field_list_component.rb +2 -50
- data/app/components/blacklight/facet_field_no_layout_component.rb +2 -10
- data/app/components/blacklight/facet_item_component.rb +2 -74
- data/app/components/blacklight/facet_item_pivot_component.rb +3 -3
- data/app/components/blacklight/facets/checkboxes_component.rb +26 -0
- data/app/components/blacklight/facets/count_component.rb +23 -0
- data/app/components/blacklight/{facet_field_component.html.erb → facets/field_component.html.erb} +4 -4
- data/app/components/blacklight/facets/field_component.rb +23 -0
- data/app/components/blacklight/facets/filters_component.html.erb +4 -0
- data/app/components/blacklight/facets/filters_component.rb +27 -0
- data/app/components/blacklight/{facet_field_inclusive_constraint_component.html.erb → facets/inclusive_constraint_component.html.erb} +1 -1
- data/app/components/blacklight/facets/inclusive_constraint_component.rb +31 -0
- data/app/components/blacklight/{facet_field_filter_component.html.erb → facets/index_navigation_component.html.erb} +1 -1
- data/app/components/blacklight/facets/index_navigation_component.rb +32 -0
- data/app/components/blacklight/facets/item_component.rb +73 -0
- data/app/components/blacklight/facets/list_component.html.erb +11 -0
- data/app/components/blacklight/facets/list_component.rb +38 -0
- data/app/components/blacklight/facets/no_layout_component.rb +16 -0
- data/app/components/blacklight/facets/selected_value_component.rb +29 -0
- data/app/components/blacklight/facets/suggest_component.html.erb +12 -0
- data/app/components/blacklight/facets/suggest_component.rb +22 -0
- data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +2 -2
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -18
- data/app/components/blacklight/response/facet_group_component.rb +11 -23
- data/app/components/blacklight/response/facet_toggle_button_component.html.erb +16 -0
- data/app/components/blacklight/response/facet_toggle_button_component.rb +14 -0
- data/app/components/blacklight/response/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/pagination_component.rb +2 -1
- data/app/components/blacklight/response/sort_component.rb +1 -0
- data/app/components/blacklight/response/view_type_button_component.html.erb +1 -1
- data/app/components/blacklight/response/view_type_component.html.erb +1 -1
- data/app/components/blacklight/search/per_page_component.html.erb +1 -1
- data/app/components/blacklight/search/per_page_component.rb +1 -0
- data/app/components/blacklight/search/sidebar_component.html.erb +1 -1
- data/app/components/blacklight/search/sidebar_component.rb +1 -1
- data/app/components/blacklight/search_bar_component.html.erb +3 -3
- data/app/components/blacklight/search_bar_component.rb +2 -2
- data/app/components/blacklight/search_button_component.rb +2 -2
- data/app/components/blacklight/search_context/server_applied_params_component.html.erb +2 -2
- data/app/components/blacklight/search_context/server_applied_params_component.rb +9 -0
- data/app/components/blacklight/skip_link_component.html.erb +1 -1
- data/app/components/blacklight/skip_link_component.rb +2 -1
- data/app/components/blacklight/top_navbar_component.html.erb +2 -2
- data/app/controllers/concerns/blacklight/bookmarks.rb +3 -3
- data/app/controllers/concerns/blacklight/catalog.rb +9 -23
- data/app/controllers/concerns/blacklight/controller.rb +1 -1
- data/app/controllers/concerns/blacklight/facetable.rb +34 -0
- data/app/controllers/concerns/blacklight/search_context.rb +0 -12
- data/app/controllers/concerns/blacklight/searchable.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +0 -6
- data/app/helpers/blacklight/catalog_helper_behavior.rb +0 -10
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -14
- data/app/helpers/blacklight/document_helper_behavior.rb +3 -27
- data/app/helpers/blacklight/facets_helper_behavior.rb +9 -0
- data/app/helpers/blacklight/icon_helper_behavior.rb +3 -11
- data/app/helpers/blacklight/layout_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +0 -14
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/javascript/{blacklight → blacklight-frontend}/bookmark_toggle.js +1 -1
- data/app/javascript/{blacklight → blacklight-frontend}/checkbox_submit.js +3 -0
- data/app/javascript/{blacklight → blacklight-frontend}/core.js +2 -10
- data/app/javascript/{blacklight → blacklight-frontend}/facet_suggest.js +1 -3
- data/app/javascript/blacklight-frontend/index.js +16 -0
- data/app/javascript/{blacklight → blacklight-frontend}/modal.js +1 -5
- data/app/models/concerns/blacklight/document.rb +0 -11
- data/app/models/concerns/blacklight/user.rb +1 -1
- data/app/models/facet_search_builder.rb +5 -0
- data/app/presenters/blacklight/facet_field_presenter.rb +3 -3
- data/app/presenters/blacklight/rendering/helper_method.rb +4 -4
- data/app/presenters/blacklight/rendering/join.rb +2 -2
- data/app/services/blacklight/facet_search_service.rb +44 -0
- data/app/services/blacklight/field_retriever.rb +1 -1
- data/app/services/blacklight/search_params_yaml_coder.rb +0 -2
- data/app/services/blacklight/search_service.rb +6 -6
- data/app/values/blacklight/types.rb +2 -2
- data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +0 -2
- data/app/views/bookmarks/index.html.erb +1 -1
- data/app/views/catalog/_facet_pivot.html.erb +1 -1
- data/app/views/catalog/_home_text.html.erb +2 -2
- data/app/views/catalog/_results_pagination.html.erb +2 -5
- data/app/views/catalog/_search_results.html.erb +3 -3
- data/app/views/catalog/_search_results_header.html.erb +1 -1
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/_sort_widget.html.erb +1 -0
- data/app/views/catalog/facet.html.erb +4 -6
- data/app/views/catalog/show.html.erb +2 -3
- data/app/views/kaminari/blacklight/_paginator.html.erb +1 -2
- data/app/views/layouts/blacklight/base.html.erb +3 -7
- data/app/views/search_history/index.html.erb +0 -2
- data/blacklight.gemspec +4 -4
- data/config/importmap.rb +1 -1
- data/config/locales/blacklight.ar.yml +2 -2
- data/config/locales/blacklight.ca.yml +124 -124
- data/config/locales/blacklight.de.yml +2 -2
- data/config/locales/blacklight.en.yml +14 -14
- data/config/locales/blacklight.es.yml +2 -2
- data/config/locales/blacklight.fr.yml +2 -2
- data/config/locales/blacklight.hu.yml +2 -2
- data/config/locales/blacklight.it.yml +1 -1
- data/config/locales/blacklight.nl.yml +2 -2
- data/config/locales/blacklight.pt-BR.yml +1 -1
- data/config/locales/blacklight.sq.yml +2 -2
- data/config/locales/blacklight.zh.yml +2 -2
- data/lib/blacklight/abstract_repository.rb +2 -2
- data/lib/blacklight/abstract_search_builder.rb +154 -0
- data/lib/blacklight/configuration/context.rb +3 -3
- data/lib/blacklight/configuration/display_field.rb +1 -1
- data/lib/blacklight/configuration/facet_field.rb +6 -6
- data/lib/blacklight/configuration/field.rb +4 -4
- data/lib/blacklight/configuration/fields.rb +3 -4
- data/lib/blacklight/configuration/search_field.rb +1 -1
- data/lib/blacklight/configuration/view_config.rb +2 -4
- data/lib/blacklight/configuration.rb +11 -18
- data/lib/blacklight/engine.rb +0 -6
- data/lib/blacklight/facet_search_builder.rb +18 -0
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -1
- data/lib/blacklight/open_struct_with_hash_access.rb +5 -5
- data/lib/blacklight/search_builder.rb +1 -159
- data/lib/blacklight/search_state/filter_field.rb +2 -2
- data/lib/blacklight/search_state/pivot_filter_field.rb +4 -4
- data/lib/blacklight/solr/abstract_filter_query_builder.rb +77 -0
- data/lib/blacklight/solr/default_filter_query_builder.rb +20 -0
- data/lib/blacklight/solr/facet_search_builder_behavior.rb +62 -0
- data/lib/blacklight/solr/repository.rb +8 -9
- data/lib/blacklight/solr/request.rb +1 -7
- data/lib/blacklight/solr/response/facets.rb +2 -2
- data/lib/blacklight/solr/response/group_response.rb +2 -2
- data/lib/blacklight/solr/response/params.rb +0 -4
- data/lib/blacklight/solr/response.rb +5 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +17 -132
- data/lib/blacklight.rb +2 -2
- data/lib/generators/blacklight/assets/importmap_generator.rb +6 -24
- data/lib/generators/blacklight/assets/propshaft_generator.rb +1 -1
- data/lib/generators/blacklight/assets_generator.rb +3 -3
- data/lib/generators/blacklight/controller_generator.rb +3 -3
- data/lib/generators/blacklight/search_builder_generator.rb +1 -1
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +2 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +3 -1
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -4
- data/lib/generators/blacklight/user_generator.rb +9 -10
- data/package.json +15 -5
- data/rollup.config.js +1 -1
- data/spec/components/blacklight/advanced_search_form_component_spec.rb +18 -22
- data/spec/components/blacklight/constraint_layout_component_spec.rb +8 -8
- data/spec/components/blacklight/constraints_component_spec.rb +11 -11
- data/spec/components/blacklight/document/action_component_spec.rb +21 -17
- data/spec/components/blacklight/document/group_component_spec.rb +10 -15
- data/spec/components/blacklight/document/page_header_component_spec.rb +35 -28
- data/spec/components/blacklight/document/sidebar_component_spec.rb +9 -30
- data/spec/components/blacklight/document_component_spec.rb +98 -65
- data/spec/components/blacklight/facet_component_spec.rb +12 -8
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +12 -12
- data/spec/components/blacklight/{facet_field_checkboxes_component_spec.rb → facets/checkboxes_component_spec.rb} +14 -14
- data/spec/components/blacklight/facets/filters_component_spec.rb +36 -0
- data/spec/components/blacklight/facets/index_navigation_component_spec.rb +40 -0
- data/spec/components/blacklight/{facet_item_component_spec.rb → facets/item_component_spec.rb} +10 -10
- data/spec/components/blacklight/{facet_field_list_component_spec.rb → facets/list_component_spec.rb} +24 -24
- data/spec/components/blacklight/facets/suggest_component_spec.rb +68 -0
- data/spec/components/blacklight/header_component_spec.rb +2 -4
- data/spec/components/blacklight/hidden_search_state_component_spec.rb +7 -7
- data/spec/components/blacklight/metadata_field_component_spec.rb +17 -15
- data/spec/components/blacklight/response/facet_group_component_spec.rb +37 -0
- data/spec/components/blacklight/response/pagination_component_spec.rb +1 -1
- data/spec/components/blacklight/response/spellcheck_component_spec.rb +1 -1
- data/spec/components/blacklight/search_bar_component_spec.rb +5 -5
- data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +2 -2
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +3 -5
- data/spec/components/blacklight/skip_link_component_spec.rb +8 -11
- data/spec/components/blacklight/start_over_button_component_spec.rb +4 -4
- data/spec/components/blacklight/system/flash_message_component_spec.rb +7 -11
- data/spec/controllers/catalog_controller_spec.rb +11 -19
- data/spec/features/axe_spec.rb +6 -11
- data/spec/features/bookmarks_spec.rb +48 -11
- data/spec/features/facets_spec.rb +58 -63
- data/spec/features/search_context_spec.rb +1 -2
- data/spec/features/search_filters_spec.rb +6 -6
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +0 -9
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +10 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +2 -2
- data/spec/models/blacklight/configuration_spec.rb +32 -28
- data/spec/models/blacklight/facet_search_builder_spec.rb +19 -0
- data/spec/models/blacklight/search_builder_spec.rb +1 -11
- data/spec/models/blacklight/solr/default_filter_query_builder_spec.rb +72 -0
- data/spec/models/blacklight/solr/document_spec.rb +0 -4
- data/spec/models/blacklight/solr/facet_search_builder_behavior_spec.rb +929 -0
- data/spec/models/blacklight/solr/repository_spec.rb +31 -29
- data/spec/models/blacklight/solr/request_spec.rb +7 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +86 -40
- data/spec/models/blacklight/solr/response/group_response_spec.rb +8 -5
- data/spec/models/blacklight/solr/response/group_spec.rb +9 -5
- data/spec/models/blacklight/solr/response_spec.rb +96 -64
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +2 -227
- data/spec/models/solr_document_spec.rb +5 -1
- data/spec/services/blacklight/search_service_spec.rb +5 -26
- data/spec/spec_helper.rb +0 -1
- data/spec/support/view_component_test_helpers.rb +0 -18
- data/spec/views/catalog/facet.html.erb_spec.rb +10 -11
- data/spec/views/catalog/index.atom.builder_spec.rb +6 -3
- data/spec/views/catalog/index.html.erb_spec.rb +8 -3
- data/spec/views/catalog/show.html.erb_spec.rb +1 -0
- data/tasks/blacklight.rake +8 -5
- metadata +76 -81
- data/app/assets/stylesheets/blacklight/_autocomplete.scss +0 -25
- data/app/assets/stylesheets/blacklight/_mixins.scss +0 -20
- data/app/components/blacklight/facet_field_list_component.html.erb +0 -19
- data/app/components/blacklight/icons/legacy_icon_component.rb +0 -30
- data/app/components/blacklight/search/facet_suggest_input.html.erb +0 -12
- data/app/components/blacklight/search/facet_suggest_input.rb +0 -20
- data/app/javascript/blacklight/index.js +0 -18
- data/app/javascript/blacklight/modalForm.js +0 -60
- data/app/views/catalog/_constraints.html.erb +0 -1
- data/app/views/catalog/_facet_index_navigation.html.erb +0 -1
- data/app/views/catalog/_facet_layout.html.erb +0 -8
- data/app/views/catalog/_facet_pagination.html.erb +0 -1
- data/app/views/catalog/_facets.html.erb +0 -5
- data/app/views/catalog/_search_form.html.erb +0 -7
- data/app/views/catalog/_search_header.html.erb +0 -1
- data/app/views/catalog/_show_sidebar.html.erb +0 -3
- data/app/views/catalog/_show_tools.html.erb +0 -2
- data/app/views/catalog/_start_over.html.erb +0 -1
- data/app/views/shared/_header_navbar.html.erb +0 -1
- data/lib/generators/blacklight/assets/sprockets_generator.rb +0 -68
- data/spec/components/blacklight/document_metadata_component_spec.rb +0 -0
- data/spec/components/blacklight/search/facet_suggest_input_spec.rb +0 -57
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +0 -43
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +0 -41
- data/spec/views/catalog/_search_header.erb_spec.rb +0 -14
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +0 -24
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +0 -37
- /data/app/components/blacklight/{facet_field_checkboxes_component.html.erb → facets/checkboxes_component.html.erb} +0 -0
- /data/app/javascript/{blacklight → blacklight-frontend}/button_focus.js +0 -0
- /data/app/javascript/{blacklight → blacklight-frontend}/debounce.js +0 -0
- /data/app/javascript/{blacklight → blacklight-frontend}/search_context.js +0 -0
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::FacetComponent, type: :component do
|
6
6
|
subject(:rendered) do
|
7
|
-
|
7
|
+
render_inline(component)
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:component) { described_class.new(**component_kwargs) }
|
@@ -18,13 +18,14 @@ RSpec.describe Blacklight::FacetComponent, type: :component do
|
|
18
18
|
let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'field').normalize! }
|
19
19
|
|
20
20
|
it 'delegates to the configured component to render something' do
|
21
|
-
|
21
|
+
rendered
|
22
|
+
expect(page).to have_css 'ul.facet-values'
|
22
23
|
end
|
23
24
|
|
24
25
|
context 'with a provided component' do
|
25
26
|
let(:component_kwargs) { { field_config: facet_config, display_facet: display_facet, component: component_class } }
|
26
27
|
let(:component_class) do
|
27
|
-
Class.new(Blacklight::
|
28
|
+
Class.new(Blacklight::Facets::ListComponent) do
|
28
29
|
def self.name
|
29
30
|
'CustomFacetComponent'
|
30
31
|
end
|
@@ -35,8 +36,10 @@ RSpec.describe Blacklight::FacetComponent, type: :component do
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
before { rendered }
|
40
|
+
|
38
41
|
it 'renders the provided component' do
|
39
|
-
expect(
|
42
|
+
expect(page).to have_content 'Custom facet rendering'
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -53,14 +56,15 @@ RSpec.describe Blacklight::FacetComponent, type: :component do
|
|
53
56
|
replace_hash = { 'catalog/_facet_partial.html.erb' => 'facet partial' }
|
54
57
|
|
55
58
|
if Rails.version.to_f >= 7.1
|
56
|
-
|
59
|
+
vc_test_controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
57
60
|
else
|
58
|
-
|
61
|
+
vc_test_controller.view_context.view_paths.unshift(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
59
62
|
end
|
63
|
+
rendered
|
60
64
|
end
|
61
65
|
|
62
66
|
it 'renders the partial' do
|
63
|
-
expect(
|
67
|
+
expect(page).to have_content 'facet partial'
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
@@ -113,7 +117,7 @@ RSpec.describe Blacklight::FacetComponent, type: :component do
|
|
113
117
|
{ display_facet_or_field_config: presenter }
|
114
118
|
end
|
115
119
|
|
116
|
-
let(:presenter) { Blacklight::FacetFieldPresenter.new(facet_config, display_facet,
|
120
|
+
let(:presenter) { Blacklight::FacetFieldPresenter.new(facet_config, display_facet, vc_test_controller.view_context) }
|
117
121
|
|
118
122
|
it 'renders the component with the provided presenter' do
|
119
123
|
allow(facet_config.component).to receive(:new).and_call_original
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
|
6
|
-
|
7
|
-
|
6
|
+
before do
|
7
|
+
render_inline(described_class.new(facet_item: facet_item))
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:blacklight_config) do
|
@@ -31,17 +31,17 @@ RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
|
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
|
-
let(:facet_config) { Blacklight::Configuration::NullField.new(key: 'z', item_component: Blacklight::
|
34
|
+
let(:facet_config) { Blacklight::Configuration::NullField.new(key: 'z', item_component: Blacklight::Facets::ItemComponent, item_presenter: Blacklight::FacetItemPivotPresenter) }
|
35
35
|
|
36
36
|
it 'links to the facet and shows the number of hits' do
|
37
|
-
expect(
|
38
|
-
expect(
|
39
|
-
expect(
|
37
|
+
expect(page).to have_css 'li'
|
38
|
+
expect(page).to have_link 'x', href: nokogiri_mediated_href(facet_item.href)
|
39
|
+
expect(page).to have_css '.facet-count', text: '10'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'has the facet hierarchy' do
|
43
|
-
expect(
|
44
|
-
expect(
|
43
|
+
expect(page).to have_css 'li ul.pivot-facet'
|
44
|
+
expect(page).to have_link 'x:1', href: nokogiri_mediated_href(facet_item.facet_item_presenters.first.href)
|
45
45
|
end
|
46
46
|
|
47
47
|
context 'with a selected facet' do
|
@@ -60,10 +60,10 @@ RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'links to the facet and shows the number of hits' do
|
63
|
-
expect(
|
64
|
-
expect(
|
65
|
-
expect(
|
66
|
-
expect(
|
63
|
+
expect(page).to have_css 'li'
|
64
|
+
expect(page).to have_css '.selected', text: 'x'
|
65
|
+
expect(page).to have_link '[remove]', href: '/catalog'
|
66
|
+
expect(page).to have_css '.selected.facet-count', text: '10'
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
RSpec.describe Blacklight::
|
6
|
-
|
7
|
-
|
5
|
+
RSpec.describe Blacklight::Facets::CheckboxesComponent, type: :component do
|
6
|
+
before do
|
7
|
+
render_inline(described_class.new(facet_field: facet_field))
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:facet_field) do
|
11
11
|
instance_double(
|
12
12
|
Blacklight::FacetFieldPresenter,
|
13
|
-
facet_field: Blacklight::Configuration::NullField.new(key: 'field', item_component: Blacklight::
|
13
|
+
facet_field: Blacklight::Configuration::NullField.new(key: 'field', item_component: Blacklight::Facets::ItemComponent, item_presenter: Blacklight::FacetItemPresenter),
|
14
14
|
paginator: paginator,
|
15
15
|
key: 'field',
|
16
16
|
label: 'Field',
|
@@ -32,19 +32,19 @@ RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
|
|
32
32
|
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, Blacklight::Configuration.new) }
|
33
33
|
let(:params) { { f: { field: ['a'] } } }
|
34
34
|
|
35
|
-
it 'renders
|
36
|
-
expect(
|
37
|
-
expect(
|
38
|
-
expect(
|
39
|
-
expect(
|
35
|
+
it 'renders an accordion item' do
|
36
|
+
expect(page).to have_css '.accordion-item'
|
37
|
+
expect(page).to have_button 'Field'
|
38
|
+
expect(page).to have_css 'button[data-bs-target="#facet-field"]'
|
39
|
+
expect(page).to have_css '#facet-field.collapse.show'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'renders the facet items' do
|
43
|
-
expect(
|
44
|
-
expect(
|
43
|
+
expect(page).to have_css 'ul.facet-values'
|
44
|
+
expect(page).to have_css 'li', count: 3
|
45
45
|
|
46
|
-
expect(
|
47
|
-
expect(
|
48
|
-
expect(
|
46
|
+
expect(page).to have_field 'f_inclusive[field][]', with: 'a'
|
47
|
+
expect(page).to have_field 'f_inclusive[field][]', with: 'b'
|
48
|
+
expect(page).to have_field 'f_inclusive[field][]', with: 'c'
|
49
49
|
end
|
50
50
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::Facets::FiltersComponent, type: :component do
|
6
|
+
let(:facet_field) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest: true }
|
7
|
+
let(:presenter) do
|
8
|
+
instance_double(Blacklight::FacetFieldPresenter, facet_field: facet_field, label: 'Lang',
|
9
|
+
view_context: view_context, suggest: true, key: 'lang')
|
10
|
+
end
|
11
|
+
let(:view_context) { vc_test_controller.view_context }
|
12
|
+
|
13
|
+
before do
|
14
|
+
allow(view_context).to receive(:search_facet_path).and_return('/catalog/facet/language_facet')
|
15
|
+
|
16
|
+
with_request_url '/catalog?q=foo' do
|
17
|
+
render_inline(component)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with default classes' do
|
22
|
+
let(:component) { described_class.new(presenter: presenter) }
|
23
|
+
|
24
|
+
it 'draws default classes' do
|
25
|
+
expect(page).to have_css(".facet-filters.card.card-body.bg-light.p-3.mb-3.border-0")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with custom classes' do
|
30
|
+
let(:component) { described_class.new(presenter: presenter, classes: 'foo') }
|
31
|
+
|
32
|
+
it 'draws default classes' do
|
33
|
+
expect(page).to have_css(".foo")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Blacklight::Facets::IndexNavigationComponent, type: :component do
|
4
|
+
let(:pagination) { Blacklight::Solr::FacetPaginator.new([]) }
|
5
|
+
let(:facet) { Blacklight::Configuration::FacetField.new(index_range: '0'..'9', presenter: Blacklight::FacetFieldPresenter) }
|
6
|
+
let(:display_facet) { instance_double(Blacklight::Solr::Response::Facets::FacetField, items: [], offset: 0, prefix: '', sort: 'index', index?: true) }
|
7
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
8
|
+
|
9
|
+
let(:presenter) { facet.presenter.new(facet, display_facet, vc_test_controller.view_context) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
with_request_url "/catalog/facet/language" do
|
13
|
+
render_inline(described_class.new(presenter: presenter))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'renders the facet index navigation range' do
|
18
|
+
expect(page).to have_css '.pagination'
|
19
|
+
expect(page).to have_link '0', href: '/catalog/facet/language.html?facet.prefix=0&facet.sort=index'
|
20
|
+
expect(page).to have_link '1'
|
21
|
+
expect(page).to have_link '8'
|
22
|
+
expect(page).to have_link '9'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'renders an "all" button' do
|
26
|
+
expect(page).to have_css '.page-link', text: 'All'
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with a selected index' do
|
30
|
+
let(:display_facet) { instance_double(Blacklight::Solr::Response::Facets::FacetField, items: [], offset: 0, prefix: '5', sort: 'index', index?: true) }
|
31
|
+
|
32
|
+
it 'highlights the selected index' do
|
33
|
+
expect(page).to have_css '.active', text: '5'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'enables the clear facets button' do
|
37
|
+
expect(page).to have_link 'All'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/components/blacklight/{facet_item_component_spec.rb → facets/item_component_spec.rb}
RENAMED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
RSpec.describe Blacklight::
|
6
|
-
|
7
|
-
|
5
|
+
RSpec.describe Blacklight::Facets::ItemComponent, type: :component do
|
6
|
+
before do
|
7
|
+
render_inline(described_class.new(facet_item: facet_item))
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:facet_item) do
|
@@ -19,11 +19,11 @@ RSpec.describe Blacklight::FacetItemComponent, type: :component do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'links to the facet and shows the number of hits' do
|
22
|
-
expect(
|
23
|
-
expect(
|
22
|
+
expect(page).to have_css 'li'
|
23
|
+
expect(page).to have_link 'x', href: '/catalog?f=x' do |link|
|
24
24
|
link['rel'] == 'nofollow'
|
25
25
|
end
|
26
|
-
expect(
|
26
|
+
expect(page).to have_css '.facet-count', text: '10'
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'with a selected facet' do
|
@@ -39,12 +39,12 @@ RSpec.describe Blacklight::FacetItemComponent, type: :component do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'links to the facet and shows the number of hits' do
|
42
|
-
expect(
|
43
|
-
expect(
|
44
|
-
expect(
|
42
|
+
expect(page).to have_css 'li'
|
43
|
+
expect(page).to have_css '.selected', text: 'x'
|
44
|
+
expect(page).to have_link '[remove]', href: '/catalog' do |link|
|
45
45
|
link['rel'] == 'nofollow'
|
46
46
|
end
|
47
|
-
expect(
|
47
|
+
expect(page).to have_css '.selected.facet-count', text: '10'
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/spec/components/blacklight/{facet_field_list_component_spec.rb → facets/list_component_spec.rb}
RENAMED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
RSpec.describe Blacklight::
|
6
|
-
|
7
|
-
|
5
|
+
RSpec.describe Blacklight::Facets::ListComponent, type: :component do
|
6
|
+
before do
|
7
|
+
render_inline(described_class.new(facet_field: facet_field))
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:facet_field) do
|
@@ -21,7 +21,7 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
24
|
-
let(:facet_config) { Blacklight::Configuration::NullField.new(key: 'field', item_component: Blacklight::
|
24
|
+
let(:facet_config) { Blacklight::Configuration::NullField.new(key: 'field', item_component: Blacklight::Facets::ItemComponent, item_presenter: Blacklight::FacetItemPresenter) }
|
25
25
|
|
26
26
|
let(:paginator) do
|
27
27
|
instance_double(Blacklight::FacetPaginator, items: [
|
@@ -30,16 +30,16 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
30
30
|
])
|
31
31
|
end
|
32
32
|
|
33
|
-
it 'renders
|
34
|
-
expect(
|
35
|
-
expect(
|
36
|
-
expect(
|
37
|
-
expect(
|
33
|
+
it 'renders an accordion item' do
|
34
|
+
expect(page).to have_css '.accordion-item'
|
35
|
+
expect(page).to have_button 'Field'
|
36
|
+
expect(page).to have_css 'button[data-bs-target="#facet-field"]'
|
37
|
+
expect(page).to have_css '#facet-field.collapse.show'
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'renders the facet items' do
|
41
|
-
expect(
|
42
|
-
expect(
|
41
|
+
expect(page).to have_css 'ul.facet-values'
|
42
|
+
expect(page).to have_css 'li', count: 2
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'with an active facet' do
|
@@ -58,7 +58,7 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'adds the facet-limit-active class' do
|
61
|
-
expect(
|
61
|
+
expect(page).to have_css 'div.facet-limit-active'
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -78,13 +78,13 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'renders a collapsed facet' do
|
81
|
-
expect(
|
82
|
-
expect(
|
81
|
+
expect(page).to have_css '.facet-content.collapse'
|
82
|
+
expect(page).to have_no_css '.facet-content.collapse.show'
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'renders the toggle button in the collapsed state' do
|
86
|
-
expect(
|
87
|
-
expect(
|
86
|
+
expect(page).to have_css '.btn.collapsed'
|
87
|
+
expect(page).to have_css '.btn[aria-expanded="false"]'
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -104,7 +104,7 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'renders a link to the modal' do
|
107
|
-
expect(
|
107
|
+
expect(page).to have_link 'more Field', href: '/catalog/facet/modal'
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -133,13 +133,13 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
133
133
|
let(:params) { { f_inclusive: { field: %w[a b c] } } }
|
134
134
|
|
135
135
|
it 'displays the constraint above the list' do
|
136
|
-
expect(
|
137
|
-
expect(
|
138
|
-
expect(
|
139
|
-
expect(
|
140
|
-
expect(
|
141
|
-
expect(
|
142
|
-
expect(
|
136
|
+
expect(page).to have_content 'Any of:'
|
137
|
+
expect(page).to have_css '.inclusive_or .facet-label', text: 'a'
|
138
|
+
expect(page).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=b&f_inclusive%5Bfield%5D%5B%5D=c'
|
139
|
+
expect(page).to have_css '.inclusive_or .facet-label', text: 'b'
|
140
|
+
expect(page).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=a&f_inclusive%5Bfield%5D%5B%5D=c'
|
141
|
+
expect(page).to have_css '.inclusive_or .facet-label', text: 'c'
|
142
|
+
expect(page).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=a&f_inclusive%5Bfield%5D%5B%5D=b'
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
6
|
+
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest: true }
|
7
|
+
let(:presenter) { Blacklight::FacetFieldPresenter.new(facet, nil, nil, nil) }
|
8
|
+
let(:component) { described_class.new(presenter: presenter) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(presenter).to receive_messages(label: 'Language')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has an input with the facet-suggest class, which the javascript needs to find it' do
|
15
|
+
with_request_url "/catalog/facet/language_facet" do
|
16
|
+
rendered = render_inline component
|
17
|
+
expect(rendered.css("input.facet-suggest").count).to eq 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has an input with the data-facet-field attribute, which the javascript needs to determine the correct query' do
|
22
|
+
with_request_url "/catalog/facet/language_facet" do
|
23
|
+
rendered = render_inline component
|
24
|
+
expect(rendered.css('input[data-facet-field="language_facet"]').count).to eq 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'has an input with the data-facet-search-context attribute, which the javascript needs to determine the current search context' do
|
29
|
+
with_request_url "/catalog/facet/language_facet?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields" do
|
30
|
+
rendered = render_inline component
|
31
|
+
expect(rendered.css('input[data-facet-search-context="/catalog/facet/language_facet.html?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields"]').count).to eq 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'has a visible label that is associated with the input' do
|
36
|
+
with_request_url "/catalog/facet/language_facet" do
|
37
|
+
rendered = render_inline component
|
38
|
+
label = rendered.css('label').first
|
39
|
+
expect(label.text.strip).to eq 'Filter Language'
|
40
|
+
|
41
|
+
id_in_label_for = label.attribute('for').text
|
42
|
+
expect(id_in_label_for).to eq('facet_suggest_language_facet')
|
43
|
+
|
44
|
+
expect(rendered.css('input').first.attribute('id').text).to eq id_in_label_for
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when the facet is explicitly configured to suggest: false' do
|
49
|
+
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest: false }
|
50
|
+
|
51
|
+
it 'does not display' do
|
52
|
+
with_request_url "/catalog/facet/language_facet" do
|
53
|
+
expect(render_inline(component).to_s).to eq ''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when the facet is not explicitly configured with a suggest key' do
|
59
|
+
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet' }
|
60
|
+
|
61
|
+
it 'displays' do
|
62
|
+
with_request_url "/catalog/facet/language_facet" do
|
63
|
+
rendered = render_inline component
|
64
|
+
expect(rendered.css("input.facet-suggest").count).to eq 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -3,14 +3,12 @@
|
|
3
3
|
RSpec.describe Blacklight::HeaderComponent, type: :component do
|
4
4
|
before do
|
5
5
|
with_controller_class(CatalogController) do
|
6
|
-
allow(
|
7
|
-
|
6
|
+
allow(vc_test_controller).to receive_messages(current_user: nil, search_action_url: '/search')
|
7
|
+
render_inline described_class.new(blacklight_config: CatalogController.blacklight_config)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'with no slots' do
|
12
|
-
let(:render) { render_inline(described_class.new(blacklight_config: CatalogController.blacklight_config)) }
|
13
|
-
|
14
12
|
it 'draws the topbar' do
|
15
13
|
expect(page).to have_css 'nav.topbar'
|
16
14
|
expect(page).to have_link 'Blacklight', href: '/'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::HiddenSearchStateComponent, type: :component do
|
4
|
-
|
4
|
+
before { render_inline(instance) }
|
5
5
|
|
6
6
|
let(:params) do
|
7
7
|
{ q: "query",
|
@@ -13,11 +13,11 @@ RSpec.describe Blacklight::HiddenSearchStateComponent, type: :component do
|
|
13
13
|
let(:instance) { described_class.new(params: params) }
|
14
14
|
|
15
15
|
it "converts a hash with nested complex data to Rails-style hidden form fields" do
|
16
|
-
expect(
|
17
|
-
expect(
|
18
|
-
expect(
|
19
|
-
expect(
|
20
|
-
expect(
|
21
|
-
expect(
|
16
|
+
expect(page).to have_css("input[type='hidden'][name='q'][value='query']", visible: :hidden)
|
17
|
+
expect(page).to have_css("input[type='hidden'][name='per_page'][value='10']", visible: :hidden)
|
18
|
+
expect(page).to have_css("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']", visible: :hidden)
|
19
|
+
expect(page).to have_css("input[type='hidden'][name='f[field2][]'][value='z']", visible: :hidden)
|
20
|
+
expect(page).to have_css("input[type='hidden'][name='f[field1][]'][value='a']", visible: :hidden)
|
21
|
+
expect(page).to have_css("input[type='hidden'][name='f[field1][]'][value='b']", visible: :hidden)
|
22
22
|
end
|
23
23
|
end
|
@@ -3,11 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
|
6
|
-
|
7
|
-
render_inline_to_capybara_node(described_class.new(field: field))
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:view_context) { controller.view_context }
|
6
|
+
let(:view_context) { vc_test_controller.view_context }
|
11
7
|
let(:document) { SolrDocument.new('field' => ['Value']) }
|
12
8
|
let(:field_config) { Blacklight::Configuration::Field.new(key: 'field', field: 'field', label: 'Field label') }
|
13
9
|
|
@@ -15,23 +11,29 @@ RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
|
|
15
11
|
Blacklight::FieldPresenter.new(view_context, document, field_config)
|
16
12
|
end
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
context "from index view" do
|
15
|
+
before do
|
16
|
+
render_inline(described_class.new(field: field))
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'renders the field label' do
|
20
|
+
expect(page).to have_css 'dt.blacklight-field', text: 'Field label'
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
it 'renders the field value' do
|
24
|
+
expect(page).to have_css 'dd.blacklight-field', text: 'Value'
|
25
|
+
end
|
24
26
|
end
|
25
27
|
|
26
28
|
context 'from a show view' do
|
27
|
-
|
28
|
-
|
29
|
+
before do
|
30
|
+
allow(field).to receive(:label).with('show').and_return('custom label')
|
31
|
+
|
32
|
+
render_inline(described_class.new(field: field, show: true))
|
29
33
|
end
|
30
34
|
|
31
35
|
it 'renders the right field label' do
|
32
|
-
|
33
|
-
|
34
|
-
expect(rendered).to have_css 'dt.blacklight-field', text: 'custom label'
|
36
|
+
expect(page).to have_css 'dt.blacklight-field', text: 'custom label'
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::Response::FacetGroupComponent, type: :component do
|
6
|
+
before do
|
7
|
+
render_inline(instance)
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when classes are passed in' do
|
11
|
+
let(:instance) do
|
12
|
+
described_class.new(id: 'foo', title: 'bar', body_classes: 'custom-class').tap do |component|
|
13
|
+
component.with_body { 'body' }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "uses them" do
|
18
|
+
within '.facets' do
|
19
|
+
expect(page).to have_css 'div.custom-class'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when classes are not passed in' do
|
25
|
+
let(:instance) do
|
26
|
+
described_class.new(id: 'foo', title: 'bar').tap do |component|
|
27
|
+
component.with_body { 'body' }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "uses default classes them" do
|
32
|
+
within '.facets' do
|
33
|
+
expect(page).to have_css 'div.facets-collapse.d-lg-block.collapse.accordion'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -38,7 +38,7 @@ RSpec.describe Blacklight::Response::PaginationComponent, type: :component do
|
|
38
38
|
|
39
39
|
context 'when a different configuration that removes deep links is configured in the controller' do
|
40
40
|
before do
|
41
|
-
allow(
|
41
|
+
allow(vc_test_controller.blacklight_config.index)
|
42
42
|
.to receive(:pagination_options)
|
43
43
|
.and_return(theme: 'blacklight', left: 5, right: 0)
|
44
44
|
render
|
@@ -14,7 +14,7 @@ RSpec.describe Blacklight::Response::SpellcheckComponent, type: :component do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
before do
|
17
|
-
allow(
|
17
|
+
allow(vc_test_controller).to receive(:blacklight_config).and_return(config)
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'when there are many results' do
|
@@ -15,7 +15,7 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
before do
|
18
|
-
allow(
|
18
|
+
allow(vc_test_controller).to receive(:blacklight_config).and_return(blacklight_config)
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'with the default button' do
|
@@ -31,7 +31,7 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
31
31
|
subject(:render) do
|
32
32
|
render_inline(instance) do |c|
|
33
33
|
c.with_search_button do
|
34
|
-
|
34
|
+
vc_test_controller.view_context.tag.button "hello", id: 'custom_search'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -70,8 +70,8 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
70
70
|
context 'with extra inputs' do
|
71
71
|
subject(:render) do
|
72
72
|
render_inline(instance) do |c|
|
73
|
-
c.with_before_input_group {
|
74
|
-
c.with_before_input_group {
|
73
|
+
c.with_before_input_group { vc_test_controller.view_context.tag.input name: 'foo' }
|
74
|
+
c.with_before_input_group { vc_test_controller.view_context.tag.input name: 'bar' }
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -85,7 +85,7 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
85
85
|
subject(:render) { render_inline(instance) }
|
86
86
|
|
87
87
|
it 'sets the rounded border class' do
|
88
|
-
expect(render.css('.rounded-
|
88
|
+
expect(render.css('.rounded-start')).to be_present
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|