blacklight 7.12.0 → 7.14.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/.github/workflows/ruby.yml +109 -0
- data/.rubocop.yml +3 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +4 -2
- data/app/components/blacklight/constraints_component.rb +14 -6
- data/app/components/blacklight/document/thumbnail_component.html.erb +1 -1
- data/app/components/blacklight/document/thumbnail_component.rb +1 -1
- data/app/components/blacklight/document_component.html.erb +1 -0
- data/app/components/blacklight/document_component.rb +14 -1
- data/app/components/blacklight/facet_field_component.html.erb +1 -0
- data/app/components/blacklight/facet_field_pagination_component.html.erb +4 -4
- data/app/components/blacklight/facet_field_pagination_component.rb +0 -4
- data/app/components/blacklight/hidden_search_state_component.rb +54 -0
- data/app/components/blacklight/search_bar_component.html.erb +10 -8
- data/app/components/blacklight/search_bar_component.rb +14 -1
- data/app/controllers/concerns/blacklight/catalog.rb +3 -3
- data/app/controllers/concerns/blacklight/search_context.rb +2 -2
- data/app/controllers/concerns/blacklight/searchable.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/component_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +3 -9
- data/app/helpers/blacklight/facets_helper_behavior.rb +8 -2
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +2 -38
- data/app/helpers/blacklight/icon_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +7 -5
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +2 -2
- data/app/javascript/blacklight/button_focus.js +1 -0
- data/app/javascript/blacklight/modal.js +10 -4
- data/app/presenters/blacklight/document_presenter.rb +4 -0
- data/app/presenters/blacklight/facet_item_presenter.rb +7 -3
- data/app/presenters/blacklight/index_presenter.rb +2 -2
- data/app/presenters/blacklight/rendering/link_to_facet.rb +3 -1
- data/app/presenters/blacklight/show_presenter.rb +0 -4
- data/app/services/blacklight/search_service.rb +13 -11
- data/app/values/blacklight/types.rb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/catalog/index.json.jbuilder +3 -1
- data/blacklight.gemspec +5 -4
- data/lib/blacklight/configuration/facet_field.rb +7 -0
- data/lib/blacklight/configuration/fields.rb +1 -1
- data/lib/blacklight/configuration/search_field.rb +5 -0
- data/lib/blacklight/configuration/tool_config.rb +4 -0
- data/lib/blacklight/configuration/view_config.rb +12 -0
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -1
- data/lib/blacklight/search_builder.rb +13 -23
- data/lib/blacklight/search_state.rb +82 -70
- data/lib/blacklight/search_state/filter_field.rb +122 -0
- data/lib/blacklight/solr/repository.rb +3 -3
- data/lib/blacklight/solr/response.rb +1 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +71 -51
- data/package.json +5 -1
- data/spec/components/blacklight/constraint_layout_component_spec.rb +1 -1
- data/spec/components/blacklight/document_component_spec.rb +17 -0
- data/spec/components/blacklight/hidden_search_state_component_spec.rb +24 -0
- data/spec/features/facets_spec.rb +2 -17
- data/spec/features/search_filters_spec.rb +0 -20
- data/spec/features/search_spec.rb +0 -5
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +1 -2
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +1 -0
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +1 -0
- data/spec/lib/blacklight/configuration/view_config_spec.rb +15 -0
- data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +9 -0
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +125 -0
- data/spec/lib/blacklight/search_state_spec.rb +132 -3
- data/spec/models/blacklight/configuration_spec.rb +8 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
- data/spec/models/blacklight/solr/search_builder_spec.rb +32 -2
- data/spec/spec_helper.rb +8 -3
- data/spec/test_app_templates/Gemfile.extra +1 -1
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_thumbnail.html.erb_spec.rb +2 -0
- data/tasks/blacklight.rake +3 -3
- metadata +50 -29
- data/.npmignore +0 -23
- data/.travis.yml +0 -40
|
@@ -41,7 +41,7 @@ module Blacklight::Solr
|
|
|
41
41
|
# @return [boolean] true if the repository is reachable
|
|
42
42
|
def ping
|
|
43
43
|
response = connection.send_and_receive 'admin/ping', {}
|
|
44
|
-
Blacklight.logger
|
|
44
|
+
Blacklight.logger&.info("Ping [#{connection.uri}] returned: '#{response['status']}'")
|
|
45
45
|
response['status'] == "OK"
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -63,8 +63,8 @@ module Blacklight::Solr
|
|
|
63
63
|
|
|
64
64
|
solr_response = blacklight_config.response_model.new(res, solr_params, document_model: blacklight_config.document_model, blacklight_config: blacklight_config)
|
|
65
65
|
|
|
66
|
-
Blacklight.logger
|
|
67
|
-
Blacklight.logger
|
|
66
|
+
Blacklight.logger&.debug("Solr query: #{blacklight_config.http_method} #{path} #{solr_params.to_hash.inspect}")
|
|
67
|
+
Blacklight.logger&.debug("Solr response: #{solr_response.inspect}") if defined?(::BLACKLIGHT_VERBOSE_LOGGING) && ::BLACKLIGHT_VERBOSE_LOGGING
|
|
68
68
|
solr_response
|
|
69
69
|
end
|
|
70
70
|
rescue Errno::ECONNREFUSED => e
|
|
@@ -93,7 +93,7 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
|
93
93
|
value.each { |v| force_to_utf8(v) }
|
|
94
94
|
when String
|
|
95
95
|
if value.encoding != Encoding::UTF_8
|
|
96
|
-
Blacklight.logger
|
|
96
|
+
Blacklight.logger&.warn "Found a non utf-8 value in Blacklight::Solr::Response. \"#{value}\" Encoding is #{value.encoding}"
|
|
97
97
|
value.dup.force_encoding('UTF-8')
|
|
98
98
|
else
|
|
99
99
|
value
|
|
@@ -32,18 +32,22 @@ module Blacklight::Solr
|
|
|
32
32
|
# including config's "search field" params for current search field.
|
|
33
33
|
# also include setting spellcheck.q.
|
|
34
34
|
def add_query_to_solr(solr_parameters)
|
|
35
|
-
###
|
|
36
|
-
# Merge in search field configured values, if present, over-writing general
|
|
37
|
-
# defaults
|
|
38
35
|
###
|
|
39
36
|
# legacy behavior of user param :qt is passed through, but over-ridden
|
|
40
37
|
# by actual search field config if present. We might want to remove
|
|
41
38
|
# this legacy behavior at some point. It does not seem to be currently
|
|
42
39
|
# rspec'd.
|
|
43
|
-
|
|
40
|
+
if search_state.params[:qt]
|
|
41
|
+
Deprecation.warn(Blacklight::Solr::SearchBuilderBehavior, 'Passing the Solr qt as a parameter is deprecated.')
|
|
42
|
+
solr_parameters[:qt] = blacklight_params[:qt]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
###
|
|
46
|
+
# Merge in search field configured values, if present, over-writing general
|
|
47
|
+
# defaults
|
|
44
48
|
|
|
45
49
|
if search_field
|
|
46
|
-
solr_parameters[:qt] = search_field.qt
|
|
50
|
+
solr_parameters[:qt] = search_field.qt if search_field.qt
|
|
47
51
|
solr_parameters.merge!(search_field.solr_parameters) if search_field.solr_parameters
|
|
48
52
|
end
|
|
49
53
|
|
|
@@ -52,32 +56,14 @@ module Blacklight::Solr
|
|
|
52
56
|
# solr LocalParams in config, using solr LocalParams syntax.
|
|
53
57
|
# http://wiki.apache.org/solr/LocalParams
|
|
54
58
|
##
|
|
55
|
-
if search_field
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
##
|
|
62
|
-
# Set Solr spellcheck.q to be original user-entered query, without
|
|
63
|
-
# our local params, otherwise it'll try and spellcheck the local
|
|
64
|
-
# params!
|
|
65
|
-
solr_parameters["spellcheck.q"] ||= blacklight_params[:q]
|
|
66
|
-
elsif blacklight_params[:q].is_a? Hash
|
|
67
|
-
q = blacklight_params[:q]
|
|
68
|
-
solr_parameters[:q] = if q.values.any?(&:blank?)
|
|
69
|
-
# if any field parameters are empty, exclude _all_ results
|
|
70
|
-
"{!lucene}NOT *:*"
|
|
71
|
-
else
|
|
72
|
-
"{!lucene}" + q.map do |field, values|
|
|
73
|
-
"#{field}:(#{Array(values).map { |x| solr_param_quote(x) }.join(' OR ')})"
|
|
74
|
-
end.join(" AND ")
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
solr_parameters[:defType] = 'lucene'
|
|
78
|
-
solr_parameters[:spellcheck] = 'false'
|
|
59
|
+
if search_field&.query_builder.present?
|
|
60
|
+
add_search_field_query_builder_params(solr_parameters)
|
|
61
|
+
elsif search_field&.solr_local_parameters.present?
|
|
62
|
+
add_search_field_with_local_parameters(solr_parameters)
|
|
63
|
+
elsif search_state.query_param.is_a? Hash
|
|
64
|
+
add_multifield_search_query(solr_parameters)
|
|
79
65
|
elsif blacklight_params[:q]
|
|
80
|
-
solr_parameters[:q] =
|
|
66
|
+
solr_parameters[:q] = search_state.query_param
|
|
81
67
|
end
|
|
82
68
|
end
|
|
83
69
|
|
|
@@ -90,13 +76,17 @@ module Blacklight::Solr
|
|
|
90
76
|
solr_parameters[:fq] = [solr_parameters[:fq]]
|
|
91
77
|
end
|
|
92
78
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
79
|
+
search_state.filters.each do |filter|
|
|
80
|
+
if filter.config.filter_query_builder
|
|
81
|
+
filter_query, subqueries = filter.config.filter_query_builder.call(self, filter, solr_parameters)
|
|
96
82
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
solr_parameters.append_filter_query(filter_query)
|
|
84
|
+
solr_parameters.merge!(subqueries) if subqueries
|
|
85
|
+
else
|
|
86
|
+
filter.values.reject(&:blank?).each do |value|
|
|
87
|
+
filter_query, subqueries = facet_value_to_fq_string(filter.config.key, value)
|
|
88
|
+
solr_parameters.append_filter_query(filter_query)
|
|
89
|
+
solr_parameters.merge!(subqueries) if subqueries
|
|
100
90
|
end
|
|
101
91
|
end
|
|
102
92
|
end
|
|
@@ -171,9 +161,7 @@ module Blacklight::Solr
|
|
|
171
161
|
|
|
172
162
|
# Remove the group parameter if we've faceted on the group field (e.g. for the full results for a group)
|
|
173
163
|
def add_group_config_to_solr solr_parameters
|
|
174
|
-
|
|
175
|
-
solr_parameters[:group] = false
|
|
176
|
-
end
|
|
164
|
+
solr_parameters[:group] = false if search_state.filter(grouped_key_for_results).any?
|
|
177
165
|
end
|
|
178
166
|
|
|
179
167
|
def add_facet_paging_to_solr(solr_params)
|
|
@@ -191,22 +179,17 @@ module Blacklight::Solr
|
|
|
191
179
|
facet_config.fetch(:more_limit, blacklight_config.default_more_limit)
|
|
192
180
|
end
|
|
193
181
|
|
|
194
|
-
page =
|
|
182
|
+
page = search_state.facet_page
|
|
183
|
+
sort = search_state.facet_sort
|
|
184
|
+
prefix = search_state.facet_prefix
|
|
195
185
|
offset = (page - 1) * limit
|
|
196
186
|
|
|
197
|
-
sort = blacklight_params[request_keys[:sort]]
|
|
198
|
-
prefix = blacklight_params[request_keys[:prefix]]
|
|
199
|
-
|
|
200
187
|
# Need to set as f.facet_field.facet.* to make sure we
|
|
201
188
|
# override any field-specific default in the solr request handler.
|
|
202
189
|
solr_params[:"f.#{facet_config.field}.facet.limit"] = limit + 1
|
|
203
190
|
solr_params[:"f.#{facet_config.field}.facet.offset"] = offset
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
end
|
|
207
|
-
if blacklight_params[request_keys[:prefix]]
|
|
208
|
-
solr_params[:"f.#{facet_config.field}.facet.prefix"] = prefix
|
|
209
|
-
end
|
|
191
|
+
solr_params[:"f.#{facet_config.field}.facet.sort"] = sort if sort
|
|
192
|
+
solr_params[:"f.#{facet_config.field}.facet.prefix"] = prefix if prefix
|
|
210
193
|
solr_params[:rows] = 0
|
|
211
194
|
end
|
|
212
195
|
|
|
@@ -314,8 +297,45 @@ module Blacklight::Solr
|
|
|
314
297
|
end
|
|
315
298
|
end
|
|
316
299
|
|
|
317
|
-
def
|
|
318
|
-
|
|
300
|
+
def search_state
|
|
301
|
+
return super if defined?(super)
|
|
302
|
+
|
|
303
|
+
@search_state ||= Blacklight::SearchState.new(blacklight_params, blacklight_config)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def add_search_field_query_builder_params(solr_parameters)
|
|
307
|
+
q, additional_parameters = search_field.query_builder.call(self, search_field, solr_parameters)
|
|
308
|
+
|
|
309
|
+
solr_parameters[:q] = q
|
|
310
|
+
solr_parameters.merge!(additional_parameters) if additional_parameters
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
def add_search_field_with_local_parameters(solr_parameters)
|
|
314
|
+
local_params = search_field.solr_local_parameters.map do |key, val|
|
|
315
|
+
key.to_s + "=" + solr_param_quote(val, quote: "'")
|
|
316
|
+
end.join(" ")
|
|
317
|
+
solr_parameters[:q] = "{!#{local_params}}#{search_state.query_param}"
|
|
318
|
+
|
|
319
|
+
##
|
|
320
|
+
# Set Solr spellcheck.q to be original user-entered query, without
|
|
321
|
+
# our local params, otherwise it'll try and spellcheck the local
|
|
322
|
+
# params!
|
|
323
|
+
solr_parameters["spellcheck.q"] ||= search_state.query_param
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def add_multifield_search_query(solr_parameters)
|
|
327
|
+
q = search_state.query_param
|
|
328
|
+
solr_parameters[:q] = if q.values.any?(&:blank?)
|
|
329
|
+
# if any field parameters are empty, exclude _all_ results
|
|
330
|
+
"{!lucene}NOT *:*"
|
|
331
|
+
else
|
|
332
|
+
"{!lucene}" + q.map do |field, values|
|
|
333
|
+
"#{field}:(#{Array(values).map { |x| solr_param_quote(x) }.join(' OR ')})"
|
|
334
|
+
end.join(" AND ")
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
solr_parameters[:defType] = 'lucene'
|
|
338
|
+
solr_parameters[:spellcheck] = 'false'
|
|
319
339
|
end
|
|
320
340
|
end
|
|
321
341
|
end
|
data/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blacklight-frontend",
|
|
3
3
|
"version": "7.10.0",
|
|
4
|
-
"description": "[](https://travis-ci.com/projectblacklight/blacklight) [](http://badge.fury.io/rb/blacklight) [](https://coveralls.io/github/projectblacklight/blacklight?branch=master)",
|
|
5
5
|
"main": "app/assets/javascripts/blacklight",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"js-compile-bundle": "shx cat app/javascript/blacklight/core.js app/javascript/blacklight/autocomplete.js app/javascript/blacklight/bookmark_toggle.js app/javascript/blacklight/button_focus.js app/javascript/blacklight/checkbox_submit.js app/javascript/blacklight/facet_load.js app/javascript/blacklight/modal.js app/javascript/blacklight/search_context.js | shx sed \"s/^(import|export).*//\" | babel --filename app/javascript/blacklight/blacklight.js > app/assets/javascripts/blacklight/blacklight.js"
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/projectblacklight/blacklight.git"
|
|
12
12
|
},
|
|
13
|
+
"files": [
|
|
14
|
+
"app/assets",
|
|
15
|
+
"app/javascript"
|
|
16
|
+
],
|
|
13
17
|
"author": "",
|
|
14
18
|
"license": "Apache-2.0",
|
|
15
19
|
"bugs": {
|
|
@@ -33,6 +33,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
before do
|
|
36
|
+
# Every call to view_context returns a different object. This ensures it stays stable.
|
|
37
|
+
allow(controller).to receive(:view_context).and_return(view_context)
|
|
36
38
|
allow(controller).to receive(:current_or_guest_user).and_return(User.new)
|
|
37
39
|
allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
|
|
38
40
|
allow(view_context).to receive(:search_session).and_return({})
|
|
@@ -42,11 +44,13 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
42
44
|
|
|
43
45
|
it 'has some defined content areas' do
|
|
44
46
|
component.with(:title, 'Title')
|
|
47
|
+
component.with(:embed, 'Embed')
|
|
45
48
|
component.with(:metadata, 'Metadata')
|
|
46
49
|
component.with(:thumbnail, 'Thumbnail')
|
|
47
50
|
component.with(:actions, 'Actions')
|
|
48
51
|
|
|
49
52
|
expect(rendered).to have_content 'Title'
|
|
53
|
+
expect(rendered).to have_content 'Embed'
|
|
50
54
|
expect(rendered).to have_content 'Metadata'
|
|
51
55
|
expect(rendered).to have_content 'Thumbnail'
|
|
52
56
|
expect(rendered).to have_content 'Actions'
|
|
@@ -126,6 +130,19 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
126
130
|
expect(rendered).to have_selector 'dt', text: 'ISBN:'
|
|
127
131
|
expect(rendered).to have_selector 'dd', text: 'Value'
|
|
128
132
|
end
|
|
133
|
+
|
|
134
|
+
it 'renders an embed' do
|
|
135
|
+
stub_const('StubComponent', Class.new(ViewComponent::Base) do
|
|
136
|
+
def initialize(**); end
|
|
137
|
+
|
|
138
|
+
def call
|
|
139
|
+
'embed'
|
|
140
|
+
end
|
|
141
|
+
end)
|
|
142
|
+
|
|
143
|
+
blacklight_config.show.embed_component = StubComponent
|
|
144
|
+
expect(rendered).to have_content 'embed'
|
|
145
|
+
end
|
|
129
146
|
end
|
|
130
147
|
|
|
131
148
|
it 'renders metadata' do
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Blacklight::HiddenSearchStateComponent, type: :component do
|
|
4
|
+
subject(:render) { render_inline(instance) }
|
|
5
|
+
|
|
6
|
+
let(:params) do
|
|
7
|
+
{ q: "query",
|
|
8
|
+
search_field: "search_field",
|
|
9
|
+
per_page: 10,
|
|
10
|
+
extra_arbitrary_key: "arbitrary_value",
|
|
11
|
+
f: { field1: %w[a b], field2: ["z"] } }
|
|
12
|
+
end
|
|
13
|
+
let(:instance) { described_class.new(params: params) }
|
|
14
|
+
let(:generated) { Capybara::Node::Simple.new("<div>#{render.to_html}</div>") }
|
|
15
|
+
|
|
16
|
+
it "converts a hash with nested complex data to Rails-style hidden form fields" do
|
|
17
|
+
expect(generated).to have_selector("input[type='hidden'][name='q'][value='query']", visible: :hidden)
|
|
18
|
+
expect(generated).to have_selector("input[type='hidden'][name='per_page'][value='10']", visible: :hidden)
|
|
19
|
+
expect(generated).to have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']", visible: :hidden)
|
|
20
|
+
expect(generated).to have_selector("input[type='hidden'][name='f[field2][]'][value='z']", visible: :hidden)
|
|
21
|
+
expect(generated).to have_selector("input[type='hidden'][name='f[field1][]'][value='a']", visible: :hidden)
|
|
22
|
+
expect(generated).to have_selector("input[type='hidden'][name='f[field1][]'][value='b']", visible: :hidden)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -56,10 +56,6 @@ RSpec.describe "Facets" do
|
|
|
56
56
|
|
|
57
57
|
expect(page).to have_css('#facet-format', visible: false)
|
|
58
58
|
|
|
59
|
-
within('#facets .facets-header') do
|
|
60
|
-
page.find('button.navbar-toggler').click
|
|
61
|
-
end
|
|
62
|
-
|
|
63
59
|
page.find('h3.facet-field-heading button', text: 'Format').click
|
|
64
60
|
|
|
65
61
|
sleep(1) # let facet animation finish and wait for it to potentially re-collapse
|
|
@@ -70,14 +66,10 @@ RSpec.describe "Facets" do
|
|
|
70
66
|
it 'is able to expand pivot facets when javascript is enabled', js: true do
|
|
71
67
|
visit root_path
|
|
72
68
|
|
|
73
|
-
within('#facets .facets-header') do
|
|
74
|
-
page.find('button.navbar-toggler').click
|
|
75
|
-
end
|
|
76
|
-
|
|
77
69
|
page.find('h3.facet-field-heading button', text: 'Pivot Field').click
|
|
78
70
|
|
|
79
71
|
within '#facet-example_pivot_field' do
|
|
80
|
-
expect(page).to have_css('.facet-leaf-node', text:
|
|
72
|
+
expect(page).to have_css('.facet-leaf-node', text: "Book\t30")
|
|
81
73
|
expect(page).not_to have_css('.facet-select', text: 'Tibetan')
|
|
82
74
|
page.find('.facet-toggle-handle').click
|
|
83
75
|
click_link 'Tibetan'
|
|
@@ -88,15 +80,8 @@ RSpec.describe "Facets" do
|
|
|
88
80
|
end
|
|
89
81
|
|
|
90
82
|
describe 'heading button focus with Firefox' do
|
|
91
|
-
before do
|
|
92
|
-
Capybara.current_driver = :selenium_headless
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
after do
|
|
96
|
-
Capybara.current_driver = :rack_test
|
|
97
|
-
end
|
|
98
|
-
|
|
99
83
|
it 'changes to the button on button click in Firefox' do
|
|
84
|
+
pending 'Capybara::NotSupportedByDriverError: Capybara::Driver::Base#evaluate_script'
|
|
100
85
|
visit root_path
|
|
101
86
|
page.find('h3.facet-field-heading button', text: 'Format').click
|
|
102
87
|
focused_element_data_target = page.evaluate_script("document.activeElement")['data-target']
|
|
@@ -168,26 +168,16 @@ RSpec.describe "Facets" do
|
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
it "is collapsed when not selected", js: true do
|
|
171
|
-
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
|
172
171
|
visit root_path
|
|
173
172
|
|
|
174
|
-
within('#facets .facets-header') do
|
|
175
|
-
page.find('button.navbar-toggler').click
|
|
176
|
-
end
|
|
177
|
-
|
|
178
173
|
within(".blacklight-subject_ssim") do
|
|
179
174
|
expect(page).not_to have_selector(".card-body", visible: true)
|
|
180
175
|
end
|
|
181
176
|
end
|
|
182
177
|
|
|
183
178
|
it "expands when the heading button is clicked", js: true do
|
|
184
|
-
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
|
185
179
|
visit root_path
|
|
186
180
|
|
|
187
|
-
within('#facets .facets-header') do
|
|
188
|
-
page.find('button.navbar-toggler').click
|
|
189
|
-
end
|
|
190
|
-
|
|
191
181
|
within(".blacklight-subject_ssim") do
|
|
192
182
|
expect(page).not_to have_selector(".card-body", visible: true)
|
|
193
183
|
find(".card-header button").click
|
|
@@ -196,13 +186,8 @@ RSpec.describe "Facets" do
|
|
|
196
186
|
end
|
|
197
187
|
|
|
198
188
|
it "expands when the button is clicked", js: true do
|
|
199
|
-
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
|
200
189
|
visit root_path
|
|
201
190
|
|
|
202
|
-
within('#facets .facets-header') do
|
|
203
|
-
page.find('button.navbar-toggler').click
|
|
204
|
-
end
|
|
205
|
-
|
|
206
191
|
within(".blacklight-subject_ssim") do
|
|
207
192
|
expect(page).not_to have_selector(".card-body", visible: true)
|
|
208
193
|
find(".card-header").click
|
|
@@ -211,13 +196,8 @@ RSpec.describe "Facets" do
|
|
|
211
196
|
end
|
|
212
197
|
|
|
213
198
|
it "keeps selected facets expanded on page load", js: true do
|
|
214
|
-
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
|
215
199
|
visit root_path
|
|
216
200
|
|
|
217
|
-
within('#facets .facets-header') do
|
|
218
|
-
page.find('button.navbar-toggler').click
|
|
219
|
-
end
|
|
220
|
-
|
|
221
201
|
within(".blacklight-subject_ssim") do
|
|
222
202
|
page.find('h3.facet-field-heading', text: 'Topic').click
|
|
223
203
|
expect(page).to have_selector(".panel-collapse", visible: true)
|
|
@@ -115,9 +115,4 @@ RSpec.describe "Search Page" do
|
|
|
115
115
|
expect(page).to have_content "Welcome!"
|
|
116
116
|
expect(page).not_to have_selector "#q[value='history']"
|
|
117
117
|
end
|
|
118
|
-
|
|
119
|
-
it "handles searches with invalid facet parameters" do
|
|
120
|
-
visit root_path f: { missing_s: [1] }
|
|
121
|
-
expect(page).to have_content "No results found for your search"
|
|
122
|
-
end
|
|
123
118
|
end
|
|
@@ -122,8 +122,7 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
|
122
122
|
|
|
123
123
|
describe "#view_label" do
|
|
124
124
|
it "looks up the label to display for the view" do
|
|
125
|
-
allow(blacklight_config).to receive(:view).and_return("my_view" => double(
|
|
126
|
-
allow(helper).to receive(:field_label).with(:"blacklight.search.view_title.my_view", :"blacklight.search.view.my_view", "some label", nil, "My view")
|
|
125
|
+
allow(blacklight_config).to receive(:view).and_return("my_view" => double(display_label: "some label"))
|
|
127
126
|
|
|
128
127
|
helper.view_label "my_view"
|
|
129
128
|
end
|
|
@@ -14,6 +14,7 @@ RSpec.describe Blacklight::HashAsHiddenFieldsHelperBehavior do
|
|
|
14
14
|
let(:generated) { helper.render_hash_as_hidden_fields(params) }
|
|
15
15
|
|
|
16
16
|
it "converts a hash with nested complex data to Rails-style hidden form fields" do
|
|
17
|
+
allow(Deprecation).to receive(:warn)
|
|
17
18
|
expect(generated).to have_selector("input[type='hidden'][name='q'][value='query']", visible: false)
|
|
18
19
|
expect(generated).to have_selector("input[type='hidden'][name='per_page'][value='10']", visible: false)
|
|
19
20
|
expect(generated).to have_selector("input[type='hidden'][name='page'][value='5']", visible: false)
|
|
@@ -13,6 +13,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
|
13
13
|
let(:parameter_class) { ActionController::Parameters }
|
|
14
14
|
|
|
15
15
|
before do
|
|
16
|
+
allow(controller).to receive(:controller_name).and_return('test')
|
|
16
17
|
allow(helper).to receive(:search_action_path) do |*args|
|
|
17
18
|
search_catalog_url *args
|
|
18
19
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Blacklight::Configuration::ViewConfig do
|
|
4
|
+
subject { described_class.new(key: key, label: label) }
|
|
5
|
+
|
|
6
|
+
let(:key) { 'my_view' }
|
|
7
|
+
let(:label) { 'some label' }
|
|
8
|
+
|
|
9
|
+
describe '#display_label' do
|
|
10
|
+
it "looks up the label to display for the given document and field" do
|
|
11
|
+
allow(I18n).to receive(:t).with(:"blacklight.search.view_title.my_view", default: [:"blacklight.search.view.my_view", label, nil, "My view"]).and_return('x')
|
|
12
|
+
expect(subject.display_label(key)).to eq 'x'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|