blacklight 9.0.0.beta1 → 9.0.0
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/.docker/app/Dockerfile +2 -1
- data/.github/matrix.json +55 -0
- data/.github/workflows/build.yml +16 -0
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/main.yml +22 -0
- 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 +53 -0
- data/.rubocop.yml +81 -3
- data/.rubocop_todo.yml +46 -71
- data/.solr_wrapper.yml +3 -1
- data/README.md +2 -2
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +51 -38
- data/app/assets/javascripts/blacklight/blacklight.esm.js +62 -77
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +62 -77
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +0 -1
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +4 -0
- data/app/assets/stylesheets/blacklight/_facets.scss +37 -29
- data/app/assets/stylesheets/blacklight/_header.scss +4 -0
- data/app/assets/stylesheets/blacklight/_modal.scss +9 -8
- data/app/assets/stylesheets/blacklight/_pagination.scss +1 -3
- data/app/assets/stylesheets/blacklight/_search_history.scss +0 -4
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +3 -0
- data/app/components/blacklight/advanced_search_form_component.html.erb +4 -4
- data/app/components/blacklight/advanced_search_form_component.rb +6 -5
- data/app/components/blacklight/constraint_component.html.erb +1 -5
- data/app/components/blacklight/constraint_component.rb +11 -0
- data/app/components/blacklight/constraint_layout_component.html.erb +1 -6
- data/app/components/blacklight/constraint_layout_component.rb +9 -0
- data/app/components/blacklight/constraints_component.html.erb +3 -8
- data/app/components/blacklight/constraints_component.rb +59 -14
- data/app/components/blacklight/document/action_component.rb +1 -3
- data/app/components/blacklight/document/bookmark_component.html.erb +3 -3
- data/app/components/blacklight/document/bookmark_component.rb +10 -4
- 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 +3 -3
- 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.html.erb +3 -3
- data/app/components/blacklight/document_component.rb +22 -26
- data/app/components/blacklight/document_title_component.rb +6 -10
- data/app/components/blacklight/facet_field_checkboxes_component.rb +4 -18
- data/app/components/blacklight/facet_field_component.rb +4 -15
- data/app/components/blacklight/facet_field_filter_component.rb +4 -19
- data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +4 -23
- data/app/components/blacklight/facet_field_list_component.rb +4 -30
- data/app/components/blacklight/facet_field_no_layout_component.rb +4 -8
- data/app/components/blacklight/facet_field_pagination_component.html.erb +2 -2
- data/app/components/blacklight/facet_item_component.rb +4 -72
- data/app/components/blacklight/facet_item_pivot_component.rb +8 -4
- data/app/components/blacklight/{facet_field_checkboxes_component.html.erb → facets/checkboxes_component.html.erb} +4 -4
- 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} +1 -3
- 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 +39 -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 +76 -0
- data/app/components/blacklight/facets/list_component.html.erb +11 -0
- data/app/components/blacklight/facets/list_component.rb +46 -0
- data/app/components/blacklight/facets/no_layout_component.rb +16 -0
- data/app/components/blacklight/facets/pivot_list_component.rb +14 -0
- data/app/components/blacklight/facets/selected_value_component.rb +29 -0
- data/app/components/blacklight/facets/suggest_component.html.erb +17 -0
- data/app/components/blacklight/facets/suggest_component.rb +21 -0
- data/app/components/blacklight/header_component.rb +2 -2
- data/app/components/blacklight/icons/remove_component.rb +2 -2
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +2 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +9 -4
- data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +2 -2
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -3
- data/app/components/blacklight/response/facet_group_component.rb +9 -1
- data/app/components/blacklight/search_bar_component.html.erb +2 -2
- data/app/components/blacklight/system/dropdown_component.html.erb +1 -1
- data/app/components/blacklight/system/dropdown_component.rb +1 -1
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.rb +0 -9
- data/app/components/blacklight/system/modal_component.html.erb +1 -2
- data/app/components/blacklight/top_navbar_component.html.erb +2 -2
- data/app/controllers/concerns/blacklight/bookmarks.rb +13 -3
- data/app/controllers/concerns/blacklight/catalog.rb +27 -30
- data/app/controllers/concerns/blacklight/controller.rb +1 -1
- data/app/controllers/concerns/blacklight/search_context.rb +1 -1
- data/app/controllers/concerns/blacklight/searchable.rb +1 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +5 -3
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/document_helper_behavior.rb +3 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +7 -12
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -2
- data/app/javascript/blacklight-frontend/bookmark_toggle.js +7 -2
- data/app/javascript/blacklight-frontend/button_focus.js +1 -1
- data/app/javascript/blacklight-frontend/checkbox_submit.js +9 -2
- data/app/javascript/blacklight-frontend/debounce.js +1 -1
- data/app/javascript/blacklight-frontend/facet_suggest.js +27 -3
- data/app/javascript/blacklight-frontend/index.js +0 -2
- data/app/javascript/blacklight-frontend/modal.js +15 -8
- data/app/javascript/blacklight-frontend/search_context.js +3 -2
- data/app/presenters/blacklight/constraint_presenter.rb +22 -0
- data/app/presenters/blacklight/document_presenter.rb +6 -5
- data/app/presenters/blacklight/facet_field_presenter.rb +18 -2
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +6 -0
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +1 -5
- data/app/presenters/blacklight/facet_item_presenter.rb +5 -18
- data/app/presenters/blacklight/field_presenter.rb +4 -2
- data/app/presenters/blacklight/json_presenter.rb +8 -4
- data/app/presenters/blacklight/rendering/abstract_step.rb +7 -1
- data/app/presenters/blacklight/rendering/helper_method.rb +4 -4
- data/app/presenters/blacklight/rendering/join.rb +11 -7
- data/app/presenters/blacklight/rendering/terminator.rb +1 -1
- data/app/services/blacklight/field_retriever.rb +1 -1
- data/app/services/blacklight/search_service.rb +10 -8
- data/app/values/blacklight/types.rb +2 -2
- data/app/views/blacklight/nav/_bookmark.html.erb +1 -1
- data/app/views/catalog/_document.atom.builder +1 -1
- data/app/views/catalog/_document.html.erb +1 -1
- data/app/views/catalog/_email_form.html.erb +4 -4
- data/app/views/catalog/_home_text.html.erb +2 -2
- data/app/views/catalog/_show_main_content.html.erb +9 -5
- data/app/views/catalog/_sms_form.html.erb +4 -4
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/advanced_search.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +8 -10
- data/app/views/catalog/index.html.erb +0 -1
- data/app/views/catalog/index.json.jbuilder +5 -3
- data/app/views/catalog/show.html.erb +2 -2
- data/app/views/layouts/blacklight/base.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.ar.yml +14 -14
- data/config/locales/blacklight.ca.yml +2 -2
- data/config/locales/blacklight.de.yml +13 -13
- data/config/locales/blacklight.en.yml +3 -3
- data/config/locales/blacklight.es.yml +13 -13
- data/config/locales/blacklight.fr.yml +14 -14
- data/config/locales/blacklight.hu.yml +15 -15
- data/config/locales/blacklight.it.yml +16 -16
- data/config/locales/blacklight.nl.yml +13 -13
- data/config/locales/blacklight.pt-BR.yml +15 -15
- data/config/locales/blacklight.sq.yml +14 -14
- data/config/locales/blacklight.zh.yml +12 -12
- data/lib/blacklight/abstract_repository.rb +2 -2
- data/lib/blacklight/component.rb +7 -1
- data/lib/blacklight/configuration/context.rb +3 -3
- data/lib/blacklight/configuration/facet_field.rb +11 -6
- data/lib/blacklight/configuration/field.rb +4 -4
- data/lib/blacklight/configuration/fields.rb +0 -1
- data/lib/blacklight/configuration/search_field.rb +1 -1
- data/lib/blacklight/configuration/view_config.rb +32 -18
- data/lib/blacklight/configuration.rb +64 -10
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -1
- data/lib/blacklight/open_struct_with_hash_access.rb +2 -2
- data/lib/blacklight/routes/searchable.rb +1 -1
- data/lib/blacklight/search_builder.rb +2 -1
- data/lib/blacklight/search_state/filter_field.rb +4 -4
- data/lib/blacklight/search_state/pivot_filter_field.rb +5 -5
- data/lib/blacklight/search_state.rb +2 -0
- 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/field_reflection_search_builder.rb +11 -0
- data/lib/blacklight/solr/repository.rb +17 -15
- data/lib/blacklight/solr/response/facets.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 +48 -97
- data/lib/blacklight/solr/single_doc_search_builder.rb +25 -0
- data/lib/blacklight.rb +6 -4
- data/lib/generators/blacklight/assets/importmap_generator.rb +3 -5
- data/lib/generators/blacklight/assets_generator.rb +1 -1
- data/lib/generators/blacklight/search_builder_generator.rb +1 -1
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +3 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -71
- data/package.json +3 -3
- 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 +23 -15
- 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 +5 -11
- data/spec/components/blacklight/document_component_spec.rb +105 -79
- 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} +13 -13
- data/spec/components/blacklight/facets/filters_component_spec.rb +36 -0
- data/spec/components/blacklight/facets/index_navigation_component_spec.rb +41 -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} +34 -23
- data/spec/components/blacklight/facets/pivot_list_component_spec.rb +53 -0
- data/spec/components/blacklight/facets/suggest_component_spec.rb +82 -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 +28 -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/dropdown_component_spec.rb +26 -0
- data/spec/components/blacklight/system/flash_message_component_spec.rb +7 -11
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +12 -20
- data/spec/features/advanced_search_spec.rb +42 -21
- data/spec/features/facets_spec.rb +84 -12
- data/spec/features/modal_spec.rb +1 -1
- data/spec/features/search_filters_spec.rb +6 -4
- data/spec/features/search_spec.rb +3 -3
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +10 -0
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +2 -2
- data/spec/lib/blacklight/parameters_spec.rb +12 -1
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +18 -0
- data/spec/models/blacklight/configuration_spec.rb +178 -28
- 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/repository_spec.rb +37 -29
- 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 +38 -57
- data/spec/models/solr_document_spec.rb +5 -1
- data/spec/presenters/blacklight/constraint_presenter_spec.rb +32 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -3
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +0 -7
- data/spec/presenters/blacklight/field_presenter_spec.rb +103 -22
- data/spec/presenters/blacklight/json_presenter_spec.rb +17 -0
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +130 -14
- data/spec/services/blacklight/search_service_spec.rb +6 -27
- data/spec/spec_helper.rb +0 -1
- data/spec/support/presenter_test_helpers.rb +1 -1
- data/spec/support/view_component_test_helpers.rb +0 -18
- data/spec/views/catalog/facet.html.erb_spec.rb +10 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +8 -3
- data/spec/views/catalog/index.html.erb_spec.rb +3 -1
- metadata +69 -38
- data/.github/workflows/ruby.yml +0 -98
- data/app/assets/stylesheets/blacklight/_icons.scss +0 -4
- data/app/components/blacklight/facet_field_list_component.html.erb +0 -19
- data/app/components/blacklight/search/facet_suggest_input.html.erb +0 -9
- data/app/components/blacklight/search/facet_suggest_input.rb +0 -16
- data/app/javascript/blacklight-frontend/modalForm.js +0 -60
- 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/_facet_pivot.html.erb +0 -3
- data/app/views/shared/_sitelinks_search_box.html.erb +0 -12
- data/spec/components/blacklight/document_metadata_component_spec.rb +0 -0
- data/spec/components/blacklight/search/facet_suggest_input_spec.rb +0 -33
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
- 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
|
@@ -6,14 +6,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
6
6
|
subject(:component) { described_class.new(document: document, **attr) }
|
|
7
7
|
|
|
8
8
|
let(:attr) { {} }
|
|
9
|
-
let(:view_context) {
|
|
10
|
-
let(:render) do
|
|
11
|
-
component.render_in(view_context)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let(:rendered) do
|
|
15
|
-
Capybara::Node::Simple.new(render)
|
|
16
|
-
end
|
|
9
|
+
let(:view_context) { vc_test_controller.view_context }
|
|
17
10
|
|
|
18
11
|
let(:document) { view_context.document_presenter(presented_document) }
|
|
19
12
|
|
|
@@ -36,88 +29,102 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
36
29
|
|
|
37
30
|
before do
|
|
38
31
|
# Every call to view_context returns a different object. This ensures it stays stable.
|
|
39
|
-
allow(
|
|
32
|
+
allow(vc_test_controller).to receive_messages(view_context: view_context, current_or_guest_user: User.new, blacklight_config: blacklight_config)
|
|
40
33
|
allow(view_context).to receive_messages(search_session: {}, current_search_session: nil, current_bookmarks: [])
|
|
41
34
|
end
|
|
42
35
|
|
|
43
36
|
it 'has some defined content areas' do
|
|
44
|
-
component.
|
|
45
|
-
component.
|
|
46
|
-
component.
|
|
47
|
-
component.
|
|
48
|
-
component.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
expect(
|
|
52
|
-
expect(
|
|
53
|
-
expect(
|
|
54
|
-
expect(
|
|
37
|
+
component.with_title { 'Title' }
|
|
38
|
+
component.with_embed('Embed')
|
|
39
|
+
component.with_metadata('Metadata')
|
|
40
|
+
component.with_thumbnail('Thumbnail')
|
|
41
|
+
component.with_actions { 'Actions' }
|
|
42
|
+
render_inline component
|
|
43
|
+
|
|
44
|
+
expect(page).to have_content 'Title'
|
|
45
|
+
expect(page).to have_content 'Embed'
|
|
46
|
+
expect(page).to have_content 'Metadata'
|
|
47
|
+
expect(page).to have_content 'Thumbnail'
|
|
48
|
+
expect(page).to have_content 'Actions'
|
|
55
49
|
end
|
|
56
50
|
|
|
57
51
|
it 'has schema.org properties' do
|
|
58
|
-
component.
|
|
52
|
+
component.with_body { '-' }
|
|
53
|
+
render_inline component
|
|
59
54
|
|
|
60
|
-
expect(
|
|
61
|
-
expect(
|
|
55
|
+
expect(page).to have_css 'article[@itemtype="http://schema.org/Thing"]'
|
|
56
|
+
expect(page).to have_css 'article[@itemscope]'
|
|
62
57
|
end
|
|
63
58
|
|
|
64
59
|
context 'with a provided body' do
|
|
65
60
|
it 'opts-out of normal component content' do
|
|
66
|
-
component.
|
|
61
|
+
component.with_body { 'Body content' }
|
|
62
|
+
render_inline component
|
|
67
63
|
|
|
68
|
-
expect(
|
|
69
|
-
expect(
|
|
70
|
-
expect(
|
|
64
|
+
expect(page).to have_content 'Body content'
|
|
65
|
+
expect(page).to have_no_css 'header'
|
|
66
|
+
expect(page).to have_no_css 'dl'
|
|
71
67
|
end
|
|
72
68
|
end
|
|
73
69
|
|
|
74
70
|
context 'index view' do
|
|
75
71
|
before do
|
|
76
|
-
|
|
72
|
+
vc_test_controller.action_name = "index"
|
|
77
73
|
end
|
|
78
74
|
|
|
79
75
|
let(:attr) { { counter: 5 } }
|
|
80
76
|
|
|
81
77
|
it 'has data properties' do
|
|
82
|
-
component.
|
|
78
|
+
component.with_body { '-' }
|
|
79
|
+
render_inline component
|
|
83
80
|
|
|
84
|
-
expect(
|
|
85
|
-
expect(
|
|
81
|
+
expect(page).to have_css 'article[@data-document-id="x"]'
|
|
82
|
+
expect(page).to have_css 'article[@data-document-counter="5"]'
|
|
86
83
|
end
|
|
87
84
|
|
|
88
85
|
it 'renders a linked title' do
|
|
89
|
-
|
|
86
|
+
render_inline component
|
|
87
|
+
|
|
88
|
+
expect(page).to have_link 'Title', href: '/catalog/x'
|
|
90
89
|
end
|
|
91
90
|
|
|
92
91
|
it 'renders a counter with the title' do
|
|
93
|
-
|
|
92
|
+
render_inline component
|
|
93
|
+
|
|
94
|
+
expect(page).to have_css 'header', text: '5. Title'
|
|
94
95
|
end
|
|
95
96
|
|
|
96
97
|
context 'with a document rendered as part of a collection' do
|
|
97
|
-
|
|
98
|
-
let(:document_counter) { ViewComponent::VERSION::MAJOR < 3 ? 11 : 10 }
|
|
98
|
+
let(:document_counter) { 10 }
|
|
99
99
|
let(:attr) { { document_counter: document_counter, counter_offset: 100 } }
|
|
100
100
|
|
|
101
101
|
it 'renders a counter with the title' do
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
render_inline component
|
|
103
|
+
|
|
104
|
+
expect(page).to have_css 'header', text: '111. Title'
|
|
104
105
|
end
|
|
105
106
|
end
|
|
106
107
|
|
|
107
108
|
it 'renders actions' do
|
|
108
|
-
|
|
109
|
+
render_inline component
|
|
110
|
+
|
|
111
|
+
expect(page).to have_css '.index-document-functions'
|
|
109
112
|
end
|
|
110
113
|
|
|
111
114
|
it 'renders a thumbnail' do
|
|
112
|
-
|
|
115
|
+
render_inline component
|
|
116
|
+
|
|
117
|
+
expect(page).to have_css 'a[href="/catalog/x"] img[src="http://example.com/image.jpg"]'
|
|
113
118
|
end
|
|
114
119
|
|
|
115
120
|
context 'with default metadata component' do
|
|
116
121
|
it 'renders metadata' do
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
expect(
|
|
120
|
-
expect(
|
|
122
|
+
render_inline component
|
|
123
|
+
|
|
124
|
+
expect(page).to have_css 'dl.document-metadata'
|
|
125
|
+
expect(page).to have_css 'dt', text: 'Title:'
|
|
126
|
+
expect(page).to have_css 'dd', text: 'Title'
|
|
127
|
+
expect(page).to have_no_css 'dt', text: 'ISBN:'
|
|
121
128
|
end
|
|
122
129
|
end
|
|
123
130
|
end
|
|
@@ -126,44 +133,51 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
126
133
|
let(:attr) { { title_component: :h1, show: true } }
|
|
127
134
|
|
|
128
135
|
before do
|
|
129
|
-
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
it 'renders with an id' do
|
|
133
|
-
component.set_slot(:body) { '-' }
|
|
134
|
-
|
|
135
|
-
expect(rendered).to have_css 'article#document'
|
|
136
|
+
vc_test_controller.action_name = "show"
|
|
136
137
|
end
|
|
137
138
|
|
|
138
139
|
it 'renders a title' do
|
|
139
|
-
|
|
140
|
+
render_inline component
|
|
141
|
+
|
|
142
|
+
expect(page).to have_css 'h1', text: 'Title'
|
|
140
143
|
end
|
|
141
144
|
|
|
142
145
|
it 'renders with show-specific metadata' do
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
expect(
|
|
146
|
+
render_inline component
|
|
147
|
+
|
|
148
|
+
expect(page).to have_css 'dl.document-metadata'
|
|
149
|
+
expect(page).to have_css 'dt', text: 'ISBN:'
|
|
150
|
+
expect(page).to have_css 'dd', text: 'Value'
|
|
146
151
|
end
|
|
147
152
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
context 'with an embed component' do
|
|
154
|
+
before do
|
|
155
|
+
vc_test_controller.action_name = "show"
|
|
156
|
+
|
|
157
|
+
stub_const('StubComponent', Class.new(ViewComponent::Base) do
|
|
158
|
+
def initialize(**); end
|
|
151
159
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
def call
|
|
161
|
+
'embed'.html_safe
|
|
162
|
+
end
|
|
163
|
+
end)
|
|
156
164
|
|
|
157
|
-
|
|
158
|
-
|
|
165
|
+
blacklight_config.show.embed_component = StubComponent
|
|
166
|
+
render_inline component
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it 'renders an embed' do
|
|
170
|
+
expect(page).to have_content 'embed'
|
|
171
|
+
end
|
|
159
172
|
end
|
|
160
173
|
|
|
161
174
|
context 'show view with custom translation' do
|
|
162
175
|
let!(:original_translations) { I18n.backend.send(:translations).deep_dup }
|
|
163
176
|
|
|
164
177
|
before do
|
|
165
|
-
|
|
178
|
+
vc_test_controller.action_name = "show"
|
|
166
179
|
I18n.backend.store_translations(:en, blacklight: { search: { show: { label: "testing:%{label}" } } })
|
|
180
|
+
render_inline component
|
|
167
181
|
end
|
|
168
182
|
|
|
169
183
|
after do
|
|
@@ -172,9 +186,9 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
172
186
|
end
|
|
173
187
|
|
|
174
188
|
it 'renders with show-specific metadata with correct translation' do
|
|
175
|
-
expect(
|
|
176
|
-
expect(
|
|
177
|
-
expect(
|
|
189
|
+
expect(page).to have_css 'dl.document-metadata'
|
|
190
|
+
expect(page).to have_css 'dt', text: 'testing:ISBN'
|
|
191
|
+
expect(page).to have_css 'dd', text: 'Value'
|
|
178
192
|
end
|
|
179
193
|
end
|
|
180
194
|
|
|
@@ -191,10 +205,11 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
191
205
|
before do
|
|
192
206
|
stub_const('MyMetadataComponent', custom_component_class)
|
|
193
207
|
blacklight_config.show.metadata_component = MyMetadataComponent
|
|
208
|
+
render_inline component
|
|
194
209
|
end
|
|
195
210
|
|
|
196
211
|
it 'renders custom component' do
|
|
197
|
-
expect(
|
|
212
|
+
expect(page).to have_text 'blah'
|
|
198
213
|
end
|
|
199
214
|
end
|
|
200
215
|
|
|
@@ -211,36 +226,47 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
211
226
|
before do
|
|
212
227
|
stub_const('MyTitleComponent', custom_component_class)
|
|
213
228
|
blacklight_config.show.title_component = MyTitleComponent
|
|
229
|
+
render_inline component
|
|
214
230
|
end
|
|
215
231
|
|
|
216
232
|
it 'renders custom component' do
|
|
217
|
-
expect(
|
|
233
|
+
expect(page).to have_text 'Titleriffic'
|
|
218
234
|
end
|
|
219
235
|
end
|
|
220
236
|
end
|
|
221
237
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
238
|
+
context 'with partials' do
|
|
239
|
+
before do
|
|
240
|
+
component.with_partial { 'Partials' }
|
|
241
|
+
render_inline component
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
it 'renders partials' do
|
|
245
|
+
expect(page).to have_content 'Partials'
|
|
246
|
+
end
|
|
225
247
|
end
|
|
226
248
|
|
|
227
|
-
|
|
228
|
-
|
|
249
|
+
context 'with no partials (default behavior)' do
|
|
250
|
+
before do
|
|
251
|
+
render_inline component
|
|
252
|
+
end
|
|
229
253
|
|
|
230
|
-
|
|
254
|
+
it 'has no partials by default' do
|
|
255
|
+
expect(component.partials?).to be false
|
|
256
|
+
end
|
|
231
257
|
end
|
|
232
258
|
|
|
233
259
|
context 'with before_titles' do
|
|
234
|
-
|
|
235
|
-
component
|
|
236
|
-
|
|
260
|
+
before do
|
|
261
|
+
render_inline(component) do |inner_c|
|
|
262
|
+
inner_c.with_title do |c|
|
|
237
263
|
c.with_before_title { 'Prefix!' }
|
|
238
264
|
end
|
|
239
265
|
end
|
|
240
266
|
end
|
|
241
267
|
|
|
242
268
|
it 'shows the prefix' do
|
|
243
|
-
expect(
|
|
269
|
+
expect(page).to have_content "Prefix!"
|
|
244
270
|
end
|
|
245
271
|
end
|
|
246
272
|
end
|
|
@@ -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.treeitem ul li.treeitem'
|
|
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',
|
|
@@ -33,18 +33,18 @@ RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
|
|
|
33
33
|
let(:params) { { f: { field: ['a'] } } }
|
|
34
34
|
|
|
35
35
|
it 'renders an accordion item' do
|
|
36
|
-
expect(
|
|
37
|
-
expect(
|
|
38
|
-
expect(
|
|
39
|
-
expect(
|
|
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.mt-1.mb-3")
|
|
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,41 @@
|
|
|
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
|
+
facet_path = ViewComponent::VERSION::MAJOR == 3 ? '/catalog/facet/language.html' : '/catalog/facet/language'
|
|
20
|
+
expect(page).to have_link '0', href: "#{facet_path}?facet.prefix=0&facet.sort=index"
|
|
21
|
+
expect(page).to have_link '1'
|
|
22
|
+
expect(page).to have_link '8'
|
|
23
|
+
expect(page).to have_link '9'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'renders an "all" button' do
|
|
27
|
+
expect(page).to have_css '.page-link', text: 'All'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context 'with a selected index' do
|
|
31
|
+
let(:display_facet) { instance_double(Blacklight::Solr::Response::Facets::FacetField, items: [], offset: 0, prefix: '5', sort: 'index', index?: true) }
|
|
32
|
+
|
|
33
|
+
it 'highlights the selected index' do
|
|
34
|
+
expect(page).to have_css '.active', text: '5'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'enables the clear facets button' do
|
|
38
|
+
expect(page).to have_link 'All'
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
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
|