blacklight 8.2.2 → 8.4.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/.env +1 -1
- data/.github/workflows/ruby.yml +60 -62
- data/.rubocop.yml +229 -21
- data/.rubocop_todo.yml +22 -55
- data/Gemfile +2 -10
- data/README.md +2 -2
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +5 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +5 -1
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
- data/app/assets/stylesheets/blacklight/_bookmark.scss +30 -0
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -4
- data/app/assets/stylesheets/blacklight/_constraints.scss +15 -9
- data/app/assets/stylesheets/blacklight/_controls.scss +0 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +33 -37
- data/app/assets/stylesheets/blacklight/_header.scss +2 -35
- data/app/assets/stylesheets/blacklight/_icons.scss +3 -2
- data/app/assets/stylesheets/blacklight/_layout.scss +3 -0
- data/app/assets/stylesheets/blacklight/_mixins.scss +6 -21
- data/app/assets/stylesheets/blacklight/_search_form.scss +3 -8
- data/app/assets/stylesheets/blacklight/_search_history.scss +5 -5
- data/app/assets/stylesheets/blacklight/_search_results.scss +5 -2
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +16 -10
- data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +6 -0
- data/app/components/blacklight/constraint_layout_component.html.erb +2 -9
- data/app/components/blacklight/constraint_layout_component.rb +8 -0
- data/app/components/blacklight/constraints_component.rb +3 -3
- data/app/components/blacklight/document/action_component.rb +2 -1
- data/app/components/blacklight/document/bookmark_component.html.erb +2 -1
- data/app/components/blacklight/document/bookmark_component.rb +6 -0
- data/app/components/blacklight/document/page_header_component.html.erb +7 -0
- data/app/components/blacklight/document/page_header_component.rb +85 -0
- data/app/components/blacklight/document_component.rb +1 -1
- data/app/components/blacklight/facet_component.rb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
- data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +1 -1
- data/app/components/blacklight/facet_field_list_component.html.erb +1 -1
- data/app/components/blacklight/facet_item_component.rb +1 -1
- data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
- data/app/components/blacklight/icons/bookmark_icon_component.rb +17 -0
- data/app/components/blacklight/icons/icon_component.rb +9 -4
- data/app/components/blacklight/icons/remove_component.rb +16 -0
- data/app/components/blacklight/metadata_field_component.html.erb +1 -1
- data/app/components/blacklight/metadata_field_component.rb +5 -0
- data/app/components/blacklight/response/facet_group_component.rb +1 -1
- data/app/components/blacklight/response/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/sort_component.html.erb +1 -6
- data/app/components/blacklight/response/sort_component.rb +15 -0
- data/app/components/blacklight/search/per_page_component.html.erb +2 -0
- data/app/components/blacklight/search/per_page_component.rb +50 -0
- data/app/components/blacklight/search_bar_component.html.erb +1 -1
- data/app/components/blacklight/search_context/server_item_pagination_component.html.erb +4 -7
- data/app/components/blacklight/skip_link_component.html.erb +7 -0
- data/app/components/blacklight/skip_link_component.rb +17 -0
- data/app/components/blacklight/system/dropdown_button_component.rb +18 -0
- data/app/components/blacklight/system/dropdown_component.rb +4 -7
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/top_navbar_component.html.erb +2 -2
- data/app/components/blacklight/top_navbar_component.rb +4 -0
- data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -5
- data/app/helpers/blacklight/component_helper_behavior.rb +4 -4
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
- data/app/javascript/blacklight/checkbox_submit.js +5 -1
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -1
- data/app/presenters/blacklight/facet_checkbox_item_presenter.rb +11 -0
- data/app/presenters/blacklight/facet_field_presenter.rb +9 -1
- data/app/services/blacklight/search_service.rb +9 -1
- data/app/views/catalog/_per_page_widget.html.erb +1 -10
- data/app/views/catalog/_search_results.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +1 -1
- data/app/views/catalog/show.html.erb +0 -2
- data/app/views/catalog/suggest.html.erb +1 -1
- data/app/views/kaminari/blacklight/_page.html.erb +14 -8
- data/app/views/layouts/blacklight/base.html.erb +3 -4
- data/app/views/shared/_flash_messages.html.erb +1 -1
- data/blacklight.gemspec +4 -0
- data/{docker-compose.yml → compose.yaml} +1 -1
- data/config/locales/blacklight.ar.yml +3 -0
- data/config/locales/blacklight.de.yml +3 -0
- data/config/locales/blacklight.en.yml +216 -229
- data/config/locales/blacklight.es.yml +3 -0
- data/config/locales/blacklight.fr.yml +3 -0
- data/config/locales/blacklight.hu.yml +3 -0
- data/config/locales/blacklight.it.yml +3 -0
- data/config/locales/blacklight.nl.yml +3 -0
- data/config/locales/blacklight.pt-BR.yml +3 -0
- data/config/locales/blacklight.sq.yml +3 -0
- data/config/locales/blacklight.zh.yml +3 -0
- data/lib/blacklight/abstract_repository.rb +6 -0
- data/lib/blacklight/configuration.rb +33 -19
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +2 -2
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/solr/repository.rb +11 -4
- data/lib/blacklight/solr/request.rb +1 -1
- data/lib/blacklight/solr/response/facets.rb +1 -1
- data/lib/blacklight/solr/response/params.rb +1 -1
- data/lib/blacklight/solr/response.rb +0 -12
- data/lib/blacklight/solr/search_builder_behavior.rb +2 -2
- data/lib/blacklight/solr.rb +0 -6
- data/lib/blacklight.rb +4 -14
- data/lib/generators/blacklight/assets/propshaft_generator.rb +2 -2
- data/lib/generators/blacklight/models_generator.rb +1 -1
- data/package.json +1 -1
- data/spec/components/blacklight/advanced_search_form_component_spec.rb +2 -2
- data/spec/components/blacklight/constraint_layout_component_spec.rb +11 -11
- data/spec/components/blacklight/constraints_component_spec.rb +9 -9
- data/spec/components/blacklight/document/action_component_spec.rb +1 -1
- data/spec/components/blacklight/document/group_component_spec.rb +3 -3
- data/spec/components/blacklight/document/page_header_component_spec.rb +92 -0
- data/spec/components/blacklight/document/sidebar_component_spec.rb +3 -4
- data/spec/components/blacklight/document_component_spec.rb +41 -25
- data/spec/components/blacklight/facet_component_spec.rb +2 -2
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +5 -5
- data/spec/components/blacklight/facet_field_list_component_spec.rb +13 -13
- data/spec/components/blacklight/facet_item_component_spec.rb +5 -5
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +6 -6
- data/spec/components/blacklight/header_component_spec.rb +1 -2
- data/spec/components/blacklight/hidden_search_state_component_spec.rb +6 -6
- data/spec/components/blacklight/icons/icon_component_spec.rb +42 -0
- data/spec/components/blacklight/metadata_field_component_spec.rb +3 -3
- data/spec/components/blacklight/response/pagination_component_spec.rb +4 -4
- data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +1 -1
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +2 -4
- data/spec/components/blacklight/system/flash_message_component_spec.rb +5 -5
- data/spec/controllers/blacklight/catalog_spec.rb +2 -2
- data/spec/controllers/blacklight/{catalog/component_configuration_spec.rb → configurable_spec.rb} +1 -1
- data/spec/controllers/bookmarks_controller_spec.rb +10 -10
- data/spec/controllers/catalog_controller_spec.rb +29 -31
- data/spec/features/advanced_search_spec.rb +30 -16
- data/spec/features/alternate_controller_spec.rb +9 -9
- data/spec/features/axe_spec.rb +4 -4
- data/spec/features/bookmarks_spec.rb +34 -19
- data/spec/features/citation_spec.rb +1 -1
- data/spec/features/did_you_mean_spec.rb +23 -23
- data/spec/features/facet_missing_spec.rb +9 -9
- data/spec/features/facets_spec.rb +21 -20
- data/spec/features/modal_spec.rb +4 -4
- data/spec/features/record_view_spec.rb +2 -2
- data/spec/features/search_context_spec.rb +6 -6
- data/spec/features/search_crawler_spec.rb +5 -5
- data/spec/features/search_filters_spec.rb +65 -65
- data/spec/features/search_history_spec.rb +12 -12
- data/spec/features/search_pagination_spec.rb +10 -10
- data/spec/features/search_results_spec.rb +1 -1
- data/spec/features/search_sort_spec.rb +4 -4
- data/spec/features/search_spec.rb +25 -25
- data/spec/features/sitelinks_search_box_spec.rb +2 -2
- data/spec/features/sms_spec.rb +1 -1
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +2 -2
- data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +20 -3
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +2 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -8
- data/spec/helpers/blacklight_helper_spec.rb +13 -15
- data/spec/helpers/catalog_helper_spec.rb +3 -6
- data/spec/i18n_spec.rb +2 -1
- data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +1 -1
- data/spec/lib/blacklight/search_state_spec.rb +4 -4
- data/spec/lib/tasks/blacklight_task_spec.rb +2 -1
- data/spec/models/blacklight/configurable_spec.rb +1 -1
- data/spec/models/blacklight/configuration/context_spec.rb +1 -1
- data/spec/models/blacklight/configuration_spec.rb +14 -14
- data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -1
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -1
- data/spec/models/blacklight/document_spec.rb +1 -1
- data/spec/models/blacklight/facet_paginator_spec.rb +14 -14
- data/spec/models/blacklight/icon_spec.rb +1 -1
- data/spec/models/blacklight/search_builder_spec.rb +1 -1
- data/spec/models/blacklight/solr/document_spec.rb +3 -3
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -1
- data/spec/models/blacklight/solr/repository_spec.rb +33 -15
- data/spec/models/blacklight/solr/request_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/facets_spec.rb +3 -3
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_spec.rb +2 -2
- data/spec/models/blacklight/solr/response_spec.rb +3 -3
- data/spec/models/blacklight/solr/{search_builder_spec.rb → search_builder_behavior_spec.rb} +10 -20
- data/spec/models/blacklight/suggest/response_spec.rb +1 -1
- data/spec/models/blacklight/suggest_search_spec.rb +1 -1
- data/spec/models/blacklight/user_spec.rb +1 -1
- data/spec/models/bookmark_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +1 -1
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -4
- data/spec/presenters/blacklight/facet_checkbox_item_presenter_spec.rb +42 -0
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +14 -0
- data/spec/presenters/blacklight/field_presenter_spec.rb +1 -1
- data/spec/presenters/blacklight/index_presenter_spec.rb +2 -3
- data/spec/presenters/blacklight/json_presenter_spec.rb +1 -1
- data/spec/presenters/{pipeline_spec.rb → blacklight/rendering/pipeline_spec.rb} +1 -1
- data/spec/presenters/blacklight/show_presenter_spec.rb +5 -6
- data/spec/presenters/{thumbnail_presenter_spec.rb → blacklight/thumbnail_presenter_spec.rb} +5 -3
- data/spec/requests/load_suggestions_spec.rb +5 -5
- data/spec/routing/catalog_routing_spec.rb +1 -1
- data/spec/services/blacklight/field_retriever_spec.rb +1 -1
- data/spec/services/blacklight/search_service_spec.rb +11 -11
- data/spec/spec_helper.rb +2 -2
- data/spec/support/features/search_helpers.rb +2 -2
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +3 -3
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -4
- data/spec/views/catalog/_document_list.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +5 -6
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -4
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -2
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -7
- data/spec/views/catalog/email_success.html.erb_spec.rb +1 -1
- data/spec/views/catalog/facet.html.erb_spec.rb +1 -1
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -1
- data/spec/views/catalog/index.atom.builder_spec.rb +18 -19
- data/spec/views/catalog/index.html.erb_spec.rb +2 -4
- data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -8
- data/spec/views/catalog/show.html.erb_spec.rb +3 -5
- data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -2
- data/spec/views/catalog/sms_success.html.erb_spec.rb +1 -1
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +2 -3
- data/tasks/blacklight.rake +5 -5
- metadata +84 -12
@@ -36,12 +36,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
36
36
|
|
37
37
|
before do
|
38
38
|
# Every call to view_context returns a different object. This ensures it stays stable.
|
39
|
-
allow(controller).to
|
40
|
-
allow(
|
41
|
-
allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
|
42
|
-
allow(view_context).to receive(:search_session).and_return({})
|
43
|
-
allow(view_context).to receive(:current_search_session).and_return(nil)
|
44
|
-
allow(view_context).to receive(:current_bookmarks).and_return([])
|
39
|
+
allow(controller).to receive_messages(view_context: view_context, current_or_guest_user: User.new, blacklight_config: blacklight_config)
|
40
|
+
allow(view_context).to receive_messages(search_session: {}, current_search_session: nil, current_bookmarks: [])
|
45
41
|
end
|
46
42
|
|
47
43
|
it 'has some defined content areas' do
|
@@ -61,8 +57,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
61
57
|
it 'has schema.org properties' do
|
62
58
|
component.set_slot(:body) { '-' }
|
63
59
|
|
64
|
-
expect(rendered).to
|
65
|
-
expect(rendered).to
|
60
|
+
expect(rendered).to have_css 'article[@itemtype="http://schema.org/Thing"]'
|
61
|
+
expect(rendered).to have_css 'article[@itemscope]'
|
66
62
|
end
|
67
63
|
|
68
64
|
context 'with a provided body' do
|
@@ -70,8 +66,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
70
66
|
component.set_slot(:body) { 'Body content' }
|
71
67
|
|
72
68
|
expect(rendered).to have_content 'Body content'
|
73
|
-
expect(rendered).
|
74
|
-
expect(rendered).
|
69
|
+
expect(rendered).to have_no_css 'header'
|
70
|
+
expect(rendered).to have_no_css 'dl'
|
75
71
|
end
|
76
72
|
end
|
77
73
|
|
@@ -85,8 +81,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
85
81
|
it 'has data properties' do
|
86
82
|
component.set_slot(:body) { '-' }
|
87
83
|
|
88
|
-
expect(rendered).to
|
89
|
-
expect(rendered).to
|
84
|
+
expect(rendered).to have_css 'article[@data-document-id="x"]'
|
85
|
+
expect(rendered).to have_css 'article[@data-document-counter="5"]'
|
90
86
|
end
|
91
87
|
|
92
88
|
it 'renders a linked title' do
|
@@ -94,7 +90,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
94
90
|
end
|
95
91
|
|
96
92
|
it 'renders a counter with the title' do
|
97
|
-
expect(rendered).to
|
93
|
+
expect(rendered).to have_css 'header', text: '5. Title'
|
98
94
|
end
|
99
95
|
|
100
96
|
context 'with a document rendered as part of a collection' do
|
@@ -104,24 +100,24 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
104
100
|
|
105
101
|
it 'renders a counter with the title' do
|
106
102
|
# after ViewComponent 2.5, collection counter params are 1-indexed
|
107
|
-
expect(rendered).to
|
103
|
+
expect(rendered).to have_css 'header', text: '111. Title'
|
108
104
|
end
|
109
105
|
end
|
110
106
|
|
111
107
|
it 'renders actions' do
|
112
|
-
expect(rendered).to
|
108
|
+
expect(rendered).to have_css '.index-document-functions'
|
113
109
|
end
|
114
110
|
|
115
111
|
it 'renders a thumbnail' do
|
116
|
-
expect(rendered).to
|
112
|
+
expect(rendered).to have_css 'a[href="/catalog/x"] img[src="http://example.com/image.jpg"]'
|
117
113
|
end
|
118
114
|
|
119
115
|
context 'with default metadata component' do
|
120
116
|
it 'renders metadata' do
|
121
|
-
expect(rendered).to
|
122
|
-
expect(rendered).to
|
123
|
-
expect(rendered).to
|
124
|
-
expect(rendered).
|
117
|
+
expect(rendered).to have_css 'dl.document-metadata'
|
118
|
+
expect(rendered).to have_css 'dt', text: 'Title:'
|
119
|
+
expect(rendered).to have_css 'dd', text: 'Title'
|
120
|
+
expect(rendered).to have_no_css 'dt', text: 'ISBN:'
|
125
121
|
end
|
126
122
|
end
|
127
123
|
end
|
@@ -136,17 +132,17 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
136
132
|
it 'renders with an id' do
|
137
133
|
component.set_slot(:body) { '-' }
|
138
134
|
|
139
|
-
expect(rendered).to
|
135
|
+
expect(rendered).to have_css 'article#document'
|
140
136
|
end
|
141
137
|
|
142
138
|
it 'renders a title' do
|
143
|
-
expect(rendered).to
|
139
|
+
expect(rendered).to have_css 'h1', text: 'Title'
|
144
140
|
end
|
145
141
|
|
146
142
|
it 'renders with show-specific metadata' do
|
147
|
-
expect(rendered).to
|
148
|
-
expect(rendered).to
|
149
|
-
expect(rendered).to
|
143
|
+
expect(rendered).to have_css 'dl.document-metadata'
|
144
|
+
expect(rendered).to have_css 'dt', text: 'ISBN:'
|
145
|
+
expect(rendered).to have_css 'dd', text: 'Value'
|
150
146
|
end
|
151
147
|
|
152
148
|
it 'renders an embed' do
|
@@ -162,6 +158,26 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
162
158
|
expect(rendered).to have_content 'embed'
|
163
159
|
end
|
164
160
|
|
161
|
+
context 'show view with custom translation' do
|
162
|
+
let!(:original_translations) { I18n.backend.send(:translations).deep_dup }
|
163
|
+
|
164
|
+
before do
|
165
|
+
controller.action_name = "show"
|
166
|
+
I18n.backend.store_translations(:en, blacklight: { search: { show: { label: "testing:%{label}" } } })
|
167
|
+
end
|
168
|
+
|
169
|
+
after do
|
170
|
+
I18n.backend.reload!
|
171
|
+
I18n.backend.store_translations(:en, original_translations[:en])
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'renders with show-specific metadata with correct translation' do
|
175
|
+
expect(rendered).to have_css 'dl.document-metadata'
|
176
|
+
expect(rendered).to have_css 'dt', text: 'testing:ISBN'
|
177
|
+
expect(rendered).to have_css 'dd', text: 'Value'
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
165
181
|
context 'with configured metadata component' do
|
166
182
|
let(:custom_component_class) do
|
167
183
|
Class.new(Blacklight::DocumentMetadataComponent) do
|
@@ -18,7 +18,7 @@ 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
|
-
expect(rendered).to
|
21
|
+
expect(rendered).to have_css 'ul.facet-values'
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'with a provided component' do
|
@@ -52,7 +52,7 @@ RSpec.describe Blacklight::FacetComponent, type: :component do
|
|
52
52
|
before do
|
53
53
|
replace_hash = { 'catalog/_facet_partial.html.erb' => 'facet partial' }
|
54
54
|
|
55
|
-
if
|
55
|
+
if Rails.version.to_f >= 7.1
|
56
56
|
controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
57
57
|
else
|
58
58
|
controller.view_context.view_paths.unshift(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
@@ -33,15 +33,15 @@ RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
|
|
33
33
|
let(:params) { { f: { field: ['a'] } } }
|
34
34
|
|
35
35
|
it 'renders a collapsible card' do
|
36
|
-
expect(rendered).to
|
36
|
+
expect(rendered).to have_css '.card'
|
37
37
|
expect(rendered).to have_button 'Field'
|
38
|
-
expect(rendered).to
|
39
|
-
expect(rendered).to
|
38
|
+
expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
|
39
|
+
expect(rendered).to have_css '#facet-field.collapse.show'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'renders the facet items' do
|
43
|
-
expect(rendered).to
|
44
|
-
expect(rendered).to
|
43
|
+
expect(rendered).to have_css 'ul.facet-values'
|
44
|
+
expect(rendered).to have_css 'li', count: 3
|
45
45
|
|
46
46
|
expect(rendered).to have_field 'f_inclusive[field][]', with: 'a'
|
47
47
|
expect(rendered).to have_field 'f_inclusive[field][]', with: 'b'
|
@@ -31,15 +31,15 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'renders a collapsible card' do
|
34
|
-
expect(rendered).to
|
34
|
+
expect(rendered).to have_css '.card'
|
35
35
|
expect(rendered).to have_button 'Field'
|
36
|
-
expect(rendered).to
|
37
|
-
expect(rendered).to
|
36
|
+
expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
|
37
|
+
expect(rendered).to have_css '#facet-field.collapse.show'
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'renders the facet items' do
|
41
|
-
expect(rendered).to
|
42
|
-
expect(rendered).to
|
41
|
+
expect(rendered).to have_css 'ul.facet-values'
|
42
|
+
expect(rendered).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(rendered).to
|
61
|
+
expect(rendered).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(rendered).to
|
82
|
-
expect(rendered).
|
81
|
+
expect(rendered).to have_css '.facet-content.collapse'
|
82
|
+
expect(rendered).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(rendered).to
|
87
|
-
expect(rendered).to
|
86
|
+
expect(rendered).to have_css '.btn.collapsed'
|
87
|
+
expect(rendered).to have_css '.btn[aria-expanded="false"]'
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -134,11 +134,11 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
134
134
|
|
135
135
|
it 'displays the constraint above the list' do
|
136
136
|
expect(rendered).to have_content 'Any of:'
|
137
|
-
expect(rendered).to
|
137
|
+
expect(rendered).to have_css '.inclusive_or .facet-label', text: 'a'
|
138
138
|
expect(rendered).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(rendered).to
|
139
|
+
expect(rendered).to have_css '.inclusive_or .facet-label', text: 'b'
|
140
140
|
expect(rendered).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(rendered).to
|
141
|
+
expect(rendered).to have_css '.inclusive_or .facet-label', text: 'c'
|
142
142
|
expect(rendered).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
|
@@ -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(rendered).to
|
22
|
+
expect(rendered).to have_css 'li'
|
23
23
|
expect(rendered).to have_link 'x', href: '/catalog?f=x' do |link|
|
24
24
|
link['rel'] == 'nofollow'
|
25
25
|
end
|
26
|
-
expect(rendered).to
|
26
|
+
expect(rendered).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(rendered).to
|
43
|
-
expect(rendered).to
|
42
|
+
expect(rendered).to have_css 'li'
|
43
|
+
expect(rendered).to have_css '.selected', text: 'x'
|
44
44
|
expect(rendered).to have_link '[remove]', href: '/catalog' do |link|
|
45
45
|
link['rel'] == 'nofollow'
|
46
46
|
end
|
47
|
-
expect(rendered).to
|
47
|
+
expect(rendered).to have_css '.selected.facet-count', text: '10'
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -34,13 +34,13 @@ RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
|
|
34
34
|
let(:facet_config) { Blacklight::Configuration::NullField.new(key: 'z', item_component: Blacklight::FacetItemComponent, item_presenter: Blacklight::FacetItemPivotPresenter) }
|
35
35
|
|
36
36
|
it 'links to the facet and shows the number of hits' do
|
37
|
-
expect(rendered).to
|
37
|
+
expect(rendered).to have_css 'li'
|
38
38
|
expect(rendered).to have_link 'x', href: nokogiri_mediated_href(facet_item.href)
|
39
|
-
expect(rendered).to
|
39
|
+
expect(rendered).to have_css '.facet-count', text: '10'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'has the facet hierarchy' do
|
43
|
-
expect(rendered).to
|
43
|
+
expect(rendered).to have_css 'li ul.pivot-facet'
|
44
44
|
expect(rendered).to have_link 'x:1', href: nokogiri_mediated_href(facet_item.facet_item_presenters.first.href)
|
45
45
|
end
|
46
46
|
|
@@ -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(rendered).to
|
64
|
-
expect(rendered).to
|
63
|
+
expect(rendered).to have_css 'li'
|
64
|
+
expect(rendered).to have_css '.selected', text: 'x'
|
65
65
|
expect(rendered).to have_link '[remove]', href: '/catalog'
|
66
|
-
expect(rendered).to
|
66
|
+
expect(rendered).to have_css '.selected.facet-count', text: '10'
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -3,8 +3,7 @@
|
|
3
3
|
RSpec.describe Blacklight::HeaderComponent, type: :component do
|
4
4
|
before do
|
5
5
|
with_controller_class(CatalogController) do
|
6
|
-
allow(controller).to
|
7
|
-
allow(controller).to receive(:search_action_url).and_return('/search')
|
6
|
+
allow(controller).to receive_messages(current_user: nil, search_action_url: '/search')
|
8
7
|
render
|
9
8
|
end
|
10
9
|
end
|
@@ -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(rendered).to
|
17
|
-
expect(rendered).to
|
18
|
-
expect(rendered).to
|
19
|
-
expect(rendered).to
|
20
|
-
expect(rendered).to
|
21
|
-
expect(rendered).to
|
16
|
+
expect(rendered).to have_css("input[type='hidden'][name='q'][value='query']", visible: :hidden)
|
17
|
+
expect(rendered).to have_css("input[type='hidden'][name='per_page'][value='10']", visible: :hidden)
|
18
|
+
expect(rendered).to have_css("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']", visible: :hidden)
|
19
|
+
expect(rendered).to have_css("input[type='hidden'][name='f[field2][]'][value='z']", visible: :hidden)
|
20
|
+
expect(rendered).to have_css("input[type='hidden'][name='f[field1][]'][value='a']", visible: :hidden)
|
21
|
+
expect(rendered).to have_css("input[type='hidden'][name='f[field1][]'][value='b']", visible: :hidden)
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Blacklight::Icons::IconComponent, type: :component do
|
6
|
+
subject(:component) { sub_component.new }
|
7
|
+
|
8
|
+
let(:sub_component) do
|
9
|
+
Class.new(described_class) do
|
10
|
+
def self.name
|
11
|
+
'TestIconComponent'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when no classes are passed in' do
|
17
|
+
subject(:component) { sub_component.new }
|
18
|
+
|
19
|
+
it "renders component" do
|
20
|
+
render_inline(component)
|
21
|
+
expect(page).to have_css "span[class='blacklight-icons blacklight-icons-test_icon']"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when classes are passed in' do
|
26
|
+
subject(:component) { sub_component.new(classes: 'my-icon') }
|
27
|
+
|
28
|
+
it "renders component" do
|
29
|
+
render_inline(component)
|
30
|
+
expect(page).to have_css "span[class='my-icon blacklight-icons blacklight-icons-test_icon']"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when name is passed in' do
|
35
|
+
subject(:component) { sub_component.new(name: 'my-icon') }
|
36
|
+
|
37
|
+
it "renders component" do
|
38
|
+
render_inline(component)
|
39
|
+
expect(page).to have_css "span[class='blacklight-icons blacklight-icons-my-icon']"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -16,11 +16,11 @@ RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'renders the field label' do
|
19
|
-
expect(rendered).to
|
19
|
+
expect(rendered).to have_css 'dt.blacklight-field', text: 'Field label'
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'renders the field value' do
|
23
|
-
expect(rendered).to
|
23
|
+
expect(rendered).to have_css 'dd.blacklight-field', text: 'Value'
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'from a show view' do
|
@@ -31,7 +31,7 @@ RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
|
|
31
31
|
it 'renders the right field label' do
|
32
32
|
allow(field).to receive(:label).with('show').and_return('custom label')
|
33
33
|
|
34
|
-
expect(rendered).to
|
34
|
+
expect(rendered).to have_css 'dt.blacklight-field', text: 'custom label'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -18,10 +18,10 @@ RSpec.describe Blacklight::Response::PaginationComponent, type: :component do
|
|
18
18
|
before { render }
|
19
19
|
|
20
20
|
it "has links to deep pages" do
|
21
|
-
expect(page).
|
21
|
+
expect(page).to have_no_link '98'
|
22
22
|
expect(page).to have_link '99'
|
23
23
|
expect(page).to have_link '100'
|
24
|
-
expect(page).
|
24
|
+
expect(page).to have_no_link '101'
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -32,7 +32,7 @@ RSpec.describe Blacklight::Response::PaginationComponent, type: :component do
|
|
32
32
|
|
33
33
|
it "does not link to deep pages" do
|
34
34
|
expect(page).to have_link '1'
|
35
|
-
expect(page).
|
35
|
+
expect(page).to have_no_link '100'
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -46,7 +46,7 @@ RSpec.describe Blacklight::Response::PaginationComponent, type: :component do
|
|
46
46
|
|
47
47
|
it "does not link to deep pages" do
|
48
48
|
expect(page).to have_link '1'
|
49
|
-
expect(page).
|
49
|
+
expect(page).to have_no_link '100'
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -15,7 +15,7 @@ RSpec.describe Blacklight::SearchContext::ServerAppliedParamsComponent, type: :c
|
|
15
15
|
# https://github.com/rspec/rspec-rails/commit/4d65bea0619955acb15023b9c3f57a3a53183da8
|
16
16
|
# https://github.com/rspec/rspec-rails/issues/2696
|
17
17
|
replace_hash = { 'application/_start_over.html.erb' => 'start over' }
|
18
|
-
if
|
18
|
+
if Rails.version.to_f >= 7.1
|
19
19
|
controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
20
20
|
else
|
21
21
|
view_context.view_paths.unshift(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
@@ -30,14 +30,12 @@ RSpec.describe Blacklight::SearchContext::ServerItemPaginationComponent, type: :
|
|
30
30
|
|
31
31
|
before do
|
32
32
|
# allow(controller).to receive(:controller_tracking_method).and_return('track_catalog_path')
|
33
|
-
allow(controller).to receive(:controller_name).and_return('catalog')
|
34
33
|
|
35
|
-
allow(controller).to
|
36
|
-
allow(controller).to receive(:link_to_next_document).and_return('')
|
34
|
+
allow(controller).to receive_messages(controller_name: 'catalog', link_to_previous_document: '', link_to_next_document: '')
|
37
35
|
end
|
38
36
|
|
39
37
|
it "renders content" do
|
40
|
-
expect(render.css('.
|
38
|
+
expect(render.css('.search-context.page-links').to_html).not_to be_blank
|
41
39
|
end
|
42
40
|
|
43
41
|
context "session and document are out of sync" do
|
@@ -17,14 +17,14 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
|
17
17
|
let(:type) { 'whatever' }
|
18
18
|
|
19
19
|
it 'renders a message inside an alert' do
|
20
|
-
expect(rendered).to
|
20
|
+
expect(rendered).to have_css 'div.alert.alert-whatever', text: message
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'with a success message' do
|
24
24
|
let(:type) { 'success' }
|
25
25
|
|
26
26
|
it 'adds some styling' do
|
27
|
-
expect(rendered).to
|
27
|
+
expect(rendered).to have_css 'div.alert-success'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
|
32
32
|
let(:type) { 'notice' }
|
33
33
|
|
34
34
|
it 'adds some styling' do
|
35
|
-
expect(rendered).to
|
35
|
+
expect(rendered).to have_css 'div.alert-info'
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -40,7 +40,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
|
40
40
|
let(:type) { 'alert' }
|
41
41
|
|
42
42
|
it 'adds some styling' do
|
43
|
-
expect(rendered).to
|
43
|
+
expect(rendered).to have_css 'div.alert-warning'
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -48,7 +48,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
|
|
48
48
|
let(:type) { 'error' }
|
49
49
|
|
50
50
|
it 'adds some styling' do
|
51
|
-
expect(rendered).to
|
51
|
+
expect(rendered).to have_css 'div.alert-danger'
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -8,7 +8,7 @@ RSpec.describe Blacklight::Catalog do
|
|
8
8
|
describe "#search_state" do
|
9
9
|
subject { controller.send(:search_state) }
|
10
10
|
|
11
|
-
let(:raw_params) { HashWithIndifferentAccess.new a: 1 }
|
11
|
+
let(:raw_params) { ActiveSupport::HashWithIndifferentAccess.new a: 1 }
|
12
12
|
let(:params) { ActionController::Parameters.new raw_params }
|
13
13
|
|
14
14
|
before do
|
@@ -17,7 +17,7 @@ RSpec.describe Blacklight::Catalog do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "creates a path object" do
|
20
|
-
expect(subject).to
|
20
|
+
expect(subject).to be_a Blacklight::SearchState
|
21
21
|
expect(subject.params).to eq raw_params
|
22
22
|
end
|
23
23
|
end
|
@@ -15,8 +15,8 @@ RSpec.describe BookmarksController do
|
|
15
15
|
it "has a 200 status code when creating a new one" do
|
16
16
|
put :update, xhr: true, params: { id: '2007020969', format: :js }
|
17
17
|
expect(response).to be_successful
|
18
|
-
expect(response
|
19
|
-
expect(
|
18
|
+
expect(response).to have_http_status :ok
|
19
|
+
expect(response.parsed_body["bookmarks"]["count"]).to eq 1
|
20
20
|
end
|
21
21
|
|
22
22
|
it "has a 500 status code when create is not success" do
|
@@ -26,7 +26,7 @@ RSpec.describe BookmarksController do
|
|
26
26
|
allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :create!).and_raise(ActiveRecord::RecordInvalid)
|
27
27
|
allow(@controller).to receive_message_chain(:current_or_guest_user, :errors, :full_messages).and_return([1])
|
28
28
|
put :update, xhr: true, params: { id: 'iamabooboo', format: :js }
|
29
|
-
expect(response
|
29
|
+
expect(response).to have_http_status :internal_server_error
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -44,8 +44,8 @@ RSpec.describe BookmarksController do
|
|
44
44
|
}
|
45
45
|
|
46
46
|
expect(response).to be_successful
|
47
|
-
expect(response
|
48
|
-
expect(
|
47
|
+
expect(response).to have_http_status :ok
|
48
|
+
expect(response.parsed_body["bookmarks"]["count"]).to eq 3
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -58,8 +58,8 @@ RSpec.describe BookmarksController do
|
|
58
58
|
it "has a 200 status code when delete is success" do
|
59
59
|
delete :destroy, xhr: true, params: { id: '2007020969', format: :js }
|
60
60
|
expect(response).to be_successful
|
61
|
-
expect(response
|
62
|
-
expect(
|
61
|
+
expect(response).to have_http_status :ok
|
62
|
+
expect(response.parsed_body["bookmarks"]["count"]).to eq 0
|
63
63
|
end
|
64
64
|
|
65
65
|
it "can handle bookmark deletion via :bookmarks param" do
|
@@ -74,8 +74,8 @@ RSpec.describe BookmarksController do
|
|
74
74
|
format: :js
|
75
75
|
}
|
76
76
|
expect(response).to be_successful
|
77
|
-
expect(response
|
78
|
-
expect(
|
77
|
+
expect(response).to have_http_status :ok
|
78
|
+
expect(response.parsed_body["bookmarks"]["count"]).to eq 0
|
79
79
|
end
|
80
80
|
|
81
81
|
it "has a 500 status code when delete is not success" do
|
@@ -85,7 +85,7 @@ RSpec.describe BookmarksController do
|
|
85
85
|
|
86
86
|
delete :destroy, xhr: true, params: { id: 'pleasekillme', format: :js }
|
87
87
|
|
88
|
-
expect(response
|
88
|
+
expect(response).to have_http_status :internal_server_error
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|