blacklight 8.12.2 → 9.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env +3 -3
- data/.github/pull_request_template.md +7 -0
- data/.github/workflows/ruby.yml +98 -0
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +0 -9
- data/.solr_wrapper.yml +0 -2
- data/README.md +30 -8
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +448 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js +8 -51
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +8 -51
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -4
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -3
- data/app/assets/stylesheets/blacklight/_bookmark.scss +44 -41
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -29
- data/app/assets/stylesheets/blacklight/_constraints.scss +15 -24
- data/app/assets/stylesheets/blacklight/_controls.scss +2 -18
- data/app/assets/stylesheets/blacklight/_facets.scss +15 -82
- data/app/assets/stylesheets/blacklight/_group.scss +2 -5
- data/app/assets/stylesheets/blacklight/_header.scss +4 -11
- data/app/assets/stylesheets/blacklight/_icons.scss +0 -8
- data/app/assets/stylesheets/blacklight/_modal.scss +9 -10
- data/app/assets/stylesheets/blacklight/_pagination.scss +3 -5
- data/app/assets/stylesheets/blacklight/_search_form.scss +0 -1
- data/app/assets/stylesheets/blacklight/_search_history.scss +0 -4
- data/app/assets/stylesheets/blacklight/_search_results.scss +1 -15
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +9 -17
- data/app/assets/stylesheets/blacklight/build.scss +4 -0
- data/app/components/blacklight/advanced_search_form_component.rb +1 -1
- data/app/components/blacklight/constraint_component.rb +1 -1
- data/app/components/blacklight/constraint_layout_component.html.erb +2 -2
- data/app/components/blacklight/constraints_component.html.erb +2 -2
- data/app/components/blacklight/constraints_component.rb +1 -1
- data/app/components/blacklight/document/action_component.rb +3 -1
- data/app/components/blacklight/document/bookmark_component.html.erb +3 -3
- data/app/components/blacklight/document/bookmark_component.rb +0 -1
- data/app/components/blacklight/document/group_component.html.erb +1 -1
- data/app/components/blacklight/document/page_header_component.rb +3 -3
- data/app/components/blacklight/document/sidebar_component.rb +5 -5
- data/app/components/blacklight/document_component.rb +14 -20
- data/app/components/blacklight/document_title_component.rb +3 -2
- data/app/components/blacklight/facet_field_component.html.erb +5 -5
- data/app/components/blacklight/facet_field_list_component.rb +4 -22
- data/app/components/blacklight/facet_field_pagination_component.html.erb +2 -2
- data/app/components/blacklight/facet_item_component.rb +2 -2
- data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
- data/app/components/blacklight/header_component.rb +2 -2
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -18
- data/app/components/blacklight/response/facet_group_component.rb +7 -23
- data/app/components/blacklight/response/facet_toggle_button_component.html.erb +16 -0
- data/app/components/blacklight/response/facet_toggle_button_component.rb +14 -0
- data/app/components/blacklight/response/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/pagination_component.rb +2 -1
- data/app/components/blacklight/response/sort_component.rb +1 -0
- data/app/components/blacklight/response/view_type_button_component.html.erb +1 -1
- data/app/components/blacklight/response/view_type_component.html.erb +1 -1
- data/app/components/blacklight/search/facet_suggest_input.html.erb +7 -10
- data/app/components/blacklight/search/facet_suggest_input.rb +0 -4
- data/app/components/blacklight/search/per_page_component.html.erb +1 -1
- data/app/components/blacklight/search/per_page_component.rb +1 -0
- data/app/components/blacklight/search/sidebar_component.html.erb +1 -1
- data/app/components/blacklight/search/sidebar_component.rb +1 -1
- data/app/components/blacklight/search_bar_component.html.erb +3 -3
- data/app/components/blacklight/search_bar_component.rb +2 -2
- data/app/components/blacklight/search_button_component.rb +2 -2
- data/app/components/blacklight/search_context/server_applied_params_component.html.erb +2 -2
- data/app/components/blacklight/search_context/server_applied_params_component.rb +9 -0
- data/app/components/blacklight/skip_link_component.html.erb +1 -1
- data/app/components/blacklight/skip_link_component.rb +2 -1
- data/app/components/blacklight/system/dropdown_component.html.erb +1 -1
- data/app/components/blacklight/system/dropdown_component.rb +1 -1
- data/app/components/blacklight/top_navbar_component.html.erb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +3 -2
- data/app/controllers/concerns/blacklight/search_context.rb +1 -13
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +0 -6
- data/app/helpers/blacklight/catalog_helper_behavior.rb +0 -10
- data/app/helpers/blacklight/configuration_helper_behavior.rb +0 -12
- data/app/helpers/blacklight/document_helper_behavior.rb +0 -26
- data/app/helpers/blacklight/icon_helper_behavior.rb +1 -9
- data/app/helpers/blacklight/layout_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +0 -14
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/javascript/{blacklight → blacklight-frontend}/bookmark_toggle.js +1 -1
- data/app/javascript/{blacklight → blacklight-frontend}/core.js +2 -10
- data/app/javascript/{blacklight → blacklight-frontend}/debounce.js +1 -1
- data/app/javascript/blacklight-frontend/facet_suggest.js +26 -0
- data/app/javascript/blacklight-frontend/index.js +18 -0
- data/app/javascript/{blacklight → blacklight-frontend}/modal.js +2 -14
- data/app/javascript/{blacklight → blacklight-frontend}/search_context.js +2 -3
- data/app/models/concerns/blacklight/document.rb +0 -11
- data/app/models/concerns/blacklight/user.rb +1 -1
- data/app/presenters/blacklight/facet_field_presenter.rb +2 -2
- data/app/presenters/blacklight/json_presenter.rb +3 -1
- data/app/services/blacklight/search_params_yaml_coder.rb +0 -2
- data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +0 -2
- data/app/views/bookmarks/index.html.erb +1 -1
- data/app/views/catalog/_document.atom.builder +1 -1
- data/app/views/catalog/_document.html.erb +1 -1
- data/app/views/catalog/_results_pagination.html.erb +2 -5
- data/app/views/catalog/_search_results.html.erb +3 -3
- data/app/views/catalog/_search_results_header.html.erb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +1 -1
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/_sort_widget.html.erb +1 -0
- data/app/views/catalog/facet.html.erb +9 -9
- data/app/views/catalog/show.html.erb +2 -3
- data/app/views/kaminari/blacklight/_paginator.html.erb +1 -2
- data/app/views/layouts/blacklight/base.html.erb +3 -7
- data/app/views/search_history/index.html.erb +0 -2
- data/blacklight.gemspec +4 -4
- data/config/importmap.rb +1 -1
- data/config/locales/blacklight.ar.yml +4 -4
- data/config/locales/blacklight.ca.yml +124 -124
- data/config/locales/blacklight.de.yml +2 -2
- data/config/locales/blacklight.en.yml +14 -14
- data/config/locales/blacklight.es.yml +4 -4
- data/config/locales/blacklight.fr.yml +4 -4
- data/config/locales/blacklight.hu.yml +4 -4
- data/config/locales/blacklight.it.yml +3 -3
- data/config/locales/blacklight.nl.yml +3 -3
- data/config/locales/blacklight.pt-BR.yml +3 -3
- data/config/locales/blacklight.sq.yml +4 -4
- data/config/locales/blacklight.zh.yml +4 -4
- data/lib/blacklight/component.rb +1 -2
- data/lib/blacklight/configuration/display_field.rb +1 -1
- data/lib/blacklight/configuration/fields.rb +3 -3
- data/lib/blacklight/configuration/view_config.rb +0 -2
- data/lib/blacklight/configuration.rb +5 -11
- data/lib/blacklight/engine.rb +0 -6
- data/lib/blacklight/open_struct_with_hash_access.rb +4 -4
- data/lib/blacklight/search_builder.rb +4 -4
- data/lib/blacklight/search_state/filter_field.rb +2 -2
- data/lib/blacklight/solr/request.rb +1 -7
- data/lib/blacklight/solr/response/group_response.rb +2 -2
- data/lib/blacklight.rb +1 -1
- data/lib/generators/blacklight/assets/importmap_generator.rb +8 -24
- data/lib/generators/blacklight/assets/propshaft_generator.rb +1 -1
- data/lib/generators/blacklight/assets_generator.rb +3 -3
- data/lib/generators/blacklight/controller_generator.rb +3 -3
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +0 -2
- data/lib/generators/blacklight/user_generator.rb +9 -10
- data/package.json +14 -4
- data/rollup.config.js +1 -1
- data/spec/components/blacklight/document/action_component_spec.rb +1 -5
- data/spec/components/blacklight/document/sidebar_component_spec.rb +5 -20
- data/spec/components/blacklight/document_component_spec.rb +9 -14
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +2 -2
- data/spec/components/blacklight/facet_field_list_component_spec.rb +2 -2
- data/spec/components/blacklight/search/facet_suggest_input_spec.rb +3 -27
- data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +1 -1
- data/spec/features/axe_spec.rb +6 -11
- data/spec/features/bookmarks_spec.rb +48 -11
- data/spec/features/facets_spec.rb +22 -90
- data/spec/features/search_context_spec.rb +1 -2
- data/spec/features/search_filters_spec.rb +6 -6
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +0 -9
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -1
- data/spec/lib/blacklight/parameters_spec.rb +1 -12
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +0 -18
- data/spec/models/blacklight/solr/request_spec.rb +7 -0
- data/spec/services/blacklight/search_service_spec.rb +1 -1
- data/spec/support/presenter_test_helpers.rb +1 -1
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +3 -3
- data/spec/views/catalog/facet.html.erb_spec.rb +0 -8
- data/spec/views/catalog/index.atom.builder_spec.rb +0 -2
- data/spec/views/catalog/index.html.erb_spec.rb +6 -3
- data/spec/views/catalog/show.html.erb_spec.rb +1 -0
- data/tasks/blacklight.rake +8 -5
- metadata +30 -64
- data/.github/matrix.json +0 -92
- data/.github/workflows/build.yml +0 -16
- data/.github/workflows/lint.yml +0 -25
- data/.github/workflows/main.yml +0 -24
- data/.github/workflows/test.yml +0 -58
- data/app/assets/stylesheets/blacklight/_autocomplete.scss +0 -25
- data/app/assets/stylesheets/blacklight/_mixins.scss +0 -20
- data/app/components/blacklight/icons/legacy_icon_component.rb +0 -30
- data/app/javascript/blacklight/facet_suggest.js +0 -48
- data/app/javascript/blacklight/index.js +0 -18
- data/app/views/catalog/_constraints.html.erb +0 -1
- data/app/views/catalog/_facets.html.erb +0 -5
- data/app/views/catalog/_search_form.html.erb +0 -7
- data/app/views/catalog/_search_header.html.erb +0 -1
- data/app/views/catalog/_show_sidebar.html.erb +0 -3
- data/app/views/catalog/_show_tools.html.erb +0 -2
- data/app/views/catalog/_start_over.html.erb +0 -1
- data/app/views/shared/_header_navbar.html.erb +0 -1
- data/lib/generators/blacklight/assets/sprockets_generator.rb +0 -68
- data/spec/components/blacklight/system/dropdown_component_spec.rb +0 -26
- data/spec/views/catalog/_search_header.erb_spec.rb +0 -14
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +0 -24
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +0 -37
- /data/app/javascript/{blacklight → blacklight-frontend}/button_focus.js +0 -0
- /data/app/javascript/{blacklight → blacklight-frontend}/checkbox_submit.js +0 -0
- /data/app/javascript/{blacklight → blacklight-frontend}/modalForm.js +0 -0
@@ -41,12 +41,11 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'has some defined content areas' do
|
44
|
-
component.
|
45
|
-
component.
|
46
|
-
component.
|
47
|
-
component.
|
48
|
-
component.
|
49
|
-
render_inline component
|
44
|
+
component.set_slot(:title) { 'Title' }
|
45
|
+
component.set_slot(:embed, nil, 'Embed')
|
46
|
+
component.set_slot(:metadata, nil, 'Metadata')
|
47
|
+
component.set_slot(:thumbnail, nil, 'Thumbnail')
|
48
|
+
component.set_slot(:actions) { 'Actions' }
|
50
49
|
|
51
50
|
expect(rendered).to have_content 'Title'
|
52
51
|
expect(rendered).to have_content 'Embed'
|
@@ -56,8 +55,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
56
55
|
end
|
57
56
|
|
58
57
|
it 'has schema.org properties' do
|
59
|
-
component.
|
60
|
-
render_inline component
|
58
|
+
component.set_slot(:body) { '-' }
|
61
59
|
|
62
60
|
expect(rendered).to have_css 'article[@itemtype="http://schema.org/Thing"]'
|
63
61
|
expect(rendered).to have_css 'article[@itemscope]'
|
@@ -65,8 +63,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
65
63
|
|
66
64
|
context 'with a provided body' do
|
67
65
|
it 'opts-out of normal component content' do
|
68
|
-
component.
|
69
|
-
render_inline component
|
66
|
+
component.set_slot(:body) { 'Body content' }
|
70
67
|
|
71
68
|
expect(rendered).to have_content 'Body content'
|
72
69
|
expect(rendered).to have_no_css 'header'
|
@@ -82,8 +79,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
82
79
|
let(:attr) { { counter: 5 } }
|
83
80
|
|
84
81
|
it 'has data properties' do
|
85
|
-
component.
|
86
|
-
render_inline component
|
82
|
+
component.set_slot(:body) { '-' }
|
87
83
|
|
88
84
|
expect(rendered).to have_css 'article[@data-document-id="x"]'
|
89
85
|
expect(rendered).to have_css 'article[@data-document-counter="5"]'
|
@@ -134,8 +130,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
134
130
|
end
|
135
131
|
|
136
132
|
it 'renders with an id' do
|
137
|
-
component.
|
138
|
-
render_inline component
|
133
|
+
component.set_slot(:body) { '-' }
|
139
134
|
|
140
135
|
expect(rendered).to have_css 'article#document'
|
141
136
|
end
|
@@ -32,8 +32,8 @@ RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
|
|
32
32
|
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, Blacklight::Configuration.new) }
|
33
33
|
let(:params) { { f: { field: ['a'] } } }
|
34
34
|
|
35
|
-
it 'renders
|
36
|
-
expect(rendered).to have_css '.
|
35
|
+
it 'renders an accordion item' do
|
36
|
+
expect(rendered).to have_css '.accordion-item'
|
37
37
|
expect(rendered).to have_button 'Field'
|
38
38
|
expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
|
39
39
|
expect(rendered).to have_css '#facet-field.collapse.show'
|
@@ -30,8 +30,8 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
30
30
|
])
|
31
31
|
end
|
32
32
|
|
33
|
-
it 'renders
|
34
|
-
expect(rendered).to have_css '.
|
33
|
+
it 'renders an accordion item' do
|
34
|
+
expect(rendered).to have_css '.accordion-item'
|
35
35
|
expect(rendered).to have_button 'Field'
|
36
36
|
expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
|
37
37
|
expect(rendered).to have_css '#facet-field.collapse.show'
|
@@ -3,13 +3,11 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::Search::FacetSuggestInput, type: :component do
|
6
|
-
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet'
|
6
|
+
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet' }
|
7
7
|
let(:presenter) { instance_double(Blacklight::FacetFieldPresenter) }
|
8
|
-
let(:view_context) { double(ActionView::Base) }
|
9
8
|
|
10
9
|
before do
|
11
|
-
allow(presenter).to
|
12
|
-
allow(view_context).to receive(:search_facet_path).and_return('/catalog/facet/language_facet')
|
10
|
+
allow(presenter).to receive(:label).and_return 'Language'
|
13
11
|
end
|
14
12
|
|
15
13
|
it 'has an input with the facet-suggest class, which the javascript needs to find it' do
|
@@ -22,36 +20,14 @@ RSpec.describe Blacklight::Search::FacetSuggestInput, type: :component do
|
|
22
20
|
expect(rendered.css('input[data-facet-field="language_facet"]').count).to eq 1
|
23
21
|
end
|
24
22
|
|
25
|
-
it 'has an input with the data-facet-search-context attribute, which the javascript needs to determine the current search context' do
|
26
|
-
allow(view_context).to receive(:search_facet_path).and_return('/catalog/facet/language_facet?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields')
|
27
|
-
rendered = render_inline(described_class.new(facet: facet, presenter: presenter))
|
28
|
-
expect(rendered.css('input[data-facet-search-context="/catalog/facet/language_facet?f%5Bformat%5D%5B%5D=Book&facet.prefix=R&facet.sort=index&q=tibet&search_field=all_fields"]').count).to eq 1
|
29
|
-
end
|
30
|
-
|
31
23
|
it 'has a visible label that is associated with the input' do
|
32
24
|
rendered = render_inline(described_class.new(facet: facet, presenter: presenter))
|
33
25
|
label = rendered.css('label').first
|
34
26
|
expect(label.text.strip).to eq 'Filter Language'
|
35
27
|
|
36
28
|
id_in_label_for = label.attribute('for').text
|
37
|
-
expect(id_in_label_for).to eq('
|
29
|
+
expect(id_in_label_for).to eq('facet-suggest-language_facet')
|
38
30
|
|
39
31
|
expect(rendered.css('input').first.attribute('id').text).to eq id_in_label_for
|
40
32
|
end
|
41
|
-
|
42
|
-
context 'when the facet is explicitly configured to suggest: false' do
|
43
|
-
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest: false }
|
44
|
-
|
45
|
-
it 'does not display' do
|
46
|
-
expect(render_inline(described_class.new(facet: facet, presenter: presenter)).to_s).to eq ''
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'when the facet is not explicitly configured with a suggest key' do
|
51
|
-
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet' }
|
52
|
-
|
53
|
-
it 'does not display' do
|
54
|
-
expect(render_inline(described_class.new(facet: facet, presenter: presenter)).to_s).to eq ''
|
55
|
-
end
|
56
|
-
end
|
57
33
|
end
|
@@ -85,7 +85,7 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
85
85
|
subject(:render) { render_inline(instance) }
|
86
86
|
|
87
87
|
it 'sets the rounded border class' do
|
88
|
-
expect(render.css('.rounded-
|
88
|
+
expect(render.css('.rounded-start')).to be_present
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
RSpec.describe Blacklight::Catalog do
|
4
4
|
subject { controller }
|
5
5
|
|
6
|
-
let(:controller) { Class.new(ApplicationController) { include Blacklight::Catalog }.new }
|
6
|
+
let(:controller) { (Class.new(ApplicationController) { include Blacklight::Catalog }).new }
|
7
7
|
|
8
8
|
describe "#search_state" do
|
9
9
|
subject { controller.send(:search_state) }
|
@@ -803,7 +803,7 @@ RSpec.describe CatalogController, :api do
|
|
803
803
|
end
|
804
804
|
|
805
805
|
it "is empty for empty result sets", :integration do
|
806
|
-
get :page_links, params: { f: { "format" =>
|
806
|
+
get :page_links, params: { f: { "format" => 'empty-result-set' }, counter: 1 }
|
807
807
|
expect(assigns(:page_link_data)).to be_empty
|
808
808
|
end
|
809
809
|
end
|
data/spec/features/axe_spec.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
RSpec.describe 'Accessibility testing', :js, api: false do
|
4
4
|
it 'validates the home page' do
|
5
5
|
visit root_path
|
6
|
-
expect(page).to
|
6
|
+
expect(page).to be_axe_clean
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'validates the catalog page' do
|
@@ -11,28 +11,23 @@ RSpec.describe 'Accessibility testing', :js, api: false do
|
|
11
11
|
fill_in "q", with: 'history'
|
12
12
|
click_on 'search'
|
13
13
|
|
14
|
-
expect(page).to
|
14
|
+
expect(page).to be_axe_clean
|
15
15
|
|
16
|
-
within '.
|
16
|
+
within '.accordion-item.blacklight-language_ssim' do
|
17
17
|
click_on 'Language'
|
18
18
|
click_on "Tibetan"
|
19
19
|
end
|
20
20
|
|
21
|
-
expect(page).to
|
21
|
+
expect(page).to be_axe_clean
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'validates the advanced search form' do
|
25
25
|
visit advanced_search_catalog_path
|
26
|
-
expect(page).to
|
26
|
+
expect(page).to be_axe_clean
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'validates the single results page' do
|
30
30
|
visit solr_document_path('2007020969')
|
31
|
-
expect(page).to
|
32
|
-
end
|
33
|
-
|
34
|
-
def be_accessible(skipping: [])
|
35
|
-
# typeahead does funny things with the search bar
|
36
|
-
be_axe_clean.excluding('.tt-hint').skipping(skipping + [('color-contrast' if defined?(Bootstrap) && Bootstrap::VERSION < '5')].compact)
|
31
|
+
expect(page).to be_axe_clean
|
37
32
|
end
|
38
33
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe "Bookmarks" do
|
4
|
+
before do
|
5
|
+
# Prevent any existing bookmarks from interfering
|
6
|
+
Bookmark.delete_all
|
7
|
+
end
|
8
|
+
|
4
9
|
describe "navigating from the homepage" do
|
5
10
|
it "has a link to the history page" do
|
6
11
|
sign_in 'user1'
|
@@ -40,13 +45,25 @@ RSpec.describe "Bookmarks" do
|
|
40
45
|
expect(page).to have_content 'Successfully removed bookmark.'
|
41
46
|
end
|
42
47
|
|
43
|
-
|
44
|
-
|
45
|
-
check 'Bookmark'
|
48
|
+
context 'when bookmark_icon_component is set to nil' do
|
49
|
+
let!(:default_bookmark_icon_component) { CatalogController.blacklight_config.bookmark_icon_component }
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
before do
|
52
|
+
CatalogController.blacklight_config.bookmark_icon_component = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
after do
|
56
|
+
CatalogController.blacklight_config.bookmark_icon_component = default_bookmark_icon_component
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'shows bookmarks as checkboxes', :js do
|
60
|
+
visit solr_document_path('2007020969')
|
61
|
+
check 'Bookmark'
|
62
|
+
|
63
|
+
visit solr_document_path('2007020969')
|
64
|
+
expect(page).to have_css('input[type="checkbox"][checked]')
|
65
|
+
uncheck 'In Bookmarks'
|
66
|
+
end
|
50
67
|
end
|
51
68
|
|
52
69
|
it "adds bookmarks after a user logs in" do
|
@@ -82,17 +99,37 @@ RSpec.describe "Bookmarks" do
|
|
82
99
|
expect(page).to have_content 'Ci an zhou bian'
|
83
100
|
end
|
84
101
|
|
85
|
-
context "
|
102
|
+
context "when the bookmark icon is configured (default)" do
|
103
|
+
it 'shows bookmark icon', :js do
|
104
|
+
visit solr_document_path('2007020969')
|
105
|
+
expect(page).to have_css('.blacklight-icons-bookmark')
|
106
|
+
find('.blacklight-icons-bookmark').click
|
107
|
+
|
108
|
+
expect(find('.toggle-bookmark-input', visible: false)).to be_checked
|
109
|
+
find('.blacklight-icons-bookmark').click
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "without bookmark navbar element" do
|
114
|
+
let!(:default_nav_partials) { CatalogController.blacklight_config.navbar.partials }
|
115
|
+
|
86
116
|
before do
|
87
|
-
CatalogController.blacklight_config.
|
117
|
+
CatalogController.blacklight_config.navbar.partials = CatalogController.blacklight_config.navbar.partials.except(:bookmark)
|
118
|
+
end
|
119
|
+
|
120
|
+
after do
|
121
|
+
CatalogController.blacklight_config.navbar.partials = default_nav_partials
|
88
122
|
end
|
89
123
|
|
90
|
-
it '
|
124
|
+
it 'adds and removes bookmarks', :js do
|
91
125
|
visit solr_document_path('2007020969')
|
92
|
-
expect(page).to
|
126
|
+
expect(page).to have_no_css('#bookmarks_nav')
|
93
127
|
find('.blacklight-icons-bookmark').click
|
94
128
|
|
95
|
-
expect(
|
129
|
+
expect(page).to have_content 'In Bookmarks'
|
130
|
+
|
131
|
+
visit solr_document_path('2007020969')
|
132
|
+
expect(find('.toggle-bookmark-input', visible: false)).to be_checked
|
96
133
|
find('.blacklight-icons-bookmark').click
|
97
134
|
end
|
98
135
|
end
|
@@ -99,103 +99,35 @@ RSpec.describe "Facets" do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
describe 'Facet modal
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
after do
|
110
|
-
CatalogController.blacklight_config.facet_fields[:subject_ssim].delete(:suggest)
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'allows the user to filter a long list of facet values', :js do
|
114
|
-
visit '/catalog/facet/subject_ssim'
|
115
|
-
expect(page).to have_no_link 'Old age' # This is on the second page of facet values
|
116
|
-
expect(page).to have_css 'a.facet-select', count: 20
|
117
|
-
|
118
|
-
fill_in 'facet_suggest_subject_ssim', with: "ag"
|
119
|
-
|
120
|
-
expect(page).to have_css '.facet-suggestions'
|
121
|
-
expect(page).to have_link 'Old age'
|
122
|
-
expect(page).to have_css 'a.facet-select', count: 2
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'shows the user facet suggestions that are relevant to their q param', :js do
|
126
|
-
visit '/catalog/facet/subject_ssim?q=tibet&search_field=all_fields'
|
127
|
-
fill_in 'facet_suggest_subject_ssim', with: 'la'
|
128
|
-
|
129
|
-
expect(page).to have_css '.facet-suggestions'
|
130
|
-
expect(page).to have_link 'Tibetan language'
|
131
|
-
expect(page).to have_no_link 'Law'
|
132
|
-
expect(page).to have_css 'a.facet-select', count: 1
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'allows the user to toggle the sort, then filter', :js do
|
136
|
-
visit '/catalog/facet/subject_ssim'
|
137
|
-
|
138
|
-
fill_in 'facet_suggest_subject_ssim', with: 'po'
|
139
|
-
|
140
|
-
expect(page).to have_css '.facet-suggestions'
|
141
|
-
expect(page).to have_css('.facet-values li:nth-child(1)', text: 'Political plays, Japanese')
|
142
|
-
expect(page).to have_css('.facet-values li:nth-child(2)', text: 'Military weapons')
|
143
|
-
expect(page).to have_css('.facet-values li:nth-child(3)', text: 'Political science')
|
144
|
-
|
145
|
-
first(:link, 'A-Z Sort').click
|
146
|
-
|
147
|
-
expect(page).to have_css('.facet-suggest[data-facet-search-context*="facet.sort=index"]')
|
102
|
+
describe 'Facet modal' do
|
103
|
+
it 'allows the user to filter a long list of facet values', :js do
|
104
|
+
visit '/catalog/facet/subject_ssim'
|
105
|
+
expect(page).to have_no_link 'Old age' # This is on the second page of facet values
|
106
|
+
expect(page).to have_css 'a.facet-select', count: 20
|
148
107
|
|
149
|
-
|
108
|
+
fill_in 'facet_suggest_subject_ssim', with: "ag"
|
150
109
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
expect(page).to have_css('.facet-values li:nth-child(3)', text: 'Political science')
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'allows the user to choose a starting letter, then filter', :js do
|
158
|
-
visit '/catalog/facet/subject_ssim'
|
159
|
-
|
160
|
-
first(:link, 'A-Z Sort').click
|
161
|
-
expect(page).to have_css('.facet-suggest[data-facet-search-context*="facet.sort=index"]')
|
162
|
-
|
163
|
-
click_on 'M'
|
164
|
-
expect(page).to have_css('.facet-suggest[data-facet-search-context*="facet.prefix=M"]')
|
165
|
-
|
166
|
-
fill_in 'facet_suggest_subject_ssim', with: 'te'
|
167
|
-
|
168
|
-
expect(page).to have_css '.facet-suggestions'
|
169
|
-
expect(page).to have_link 'Maternity insurance'
|
170
|
-
expect(page).to have_no_link 'Teaching'
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'hides previous/next links when filtering', :js do
|
174
|
-
visit '/catalog/facet/subject_ssim'
|
175
|
-
expect(page).to have_link 'Next »'
|
110
|
+
expect(page).to have_link 'Old age'
|
111
|
+
expect(page).to have_css 'a.facet-select', count: 2
|
112
|
+
end
|
176
113
|
|
177
|
-
|
178
|
-
|
179
|
-
|
114
|
+
it 'shows the user facet suggestions that are relevant to their q param', :js do
|
115
|
+
visit '/catalog/facet/subject_ssim?q=tibet&search_field=all_fields'
|
116
|
+
fill_in 'facet_suggest_subject_ssim', with: 'la'
|
180
117
|
|
181
|
-
|
182
|
-
|
183
|
-
expect(page).to have_link 'Next »'
|
184
|
-
end
|
118
|
+
expect(page).to have_link 'Tibetan language'
|
119
|
+
expect(page).to have_css 'a.facet-select', count: 1
|
185
120
|
end
|
186
121
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
end
|
122
|
+
it 'allows the user to filter more than once', :js do
|
123
|
+
visit '/catalog/facet/subject_ssim'
|
124
|
+
expect(page).to have_no_link 'Old age' # This is on the second page of facet values
|
125
|
+
expect(page).to have_css 'a.facet-select', count: 20
|
126
|
+
|
127
|
+
fill_in 'facet_suggest_subject_ssim', with: "ag"
|
194
128
|
|
195
|
-
|
196
|
-
|
197
|
-
visit '/?f[subject_ssim][0]=Iran.+Viza%CC%84rat-i+Kishvar'
|
198
|
-
expect(page).to have_text 'Naqdī barā-yi tamām-i fuṣūl'
|
129
|
+
expect(page).to have_link 'Old age'
|
130
|
+
expect(page).to have_link('Old age', href: '/?f%5Bsubject_ssim%5D%5B%5D=Old+age')
|
199
131
|
end
|
200
132
|
end
|
201
133
|
end
|
@@ -47,10 +47,9 @@ RSpec.describe "Search Results context" do
|
|
47
47
|
search_for ''
|
48
48
|
expect(page).to have_content "1 - 10"
|
49
49
|
find_all('.index_title a').last.click
|
50
|
-
expect(page).to have_css "h1", text: "Pluvial nectar"
|
51
50
|
click_on "Next »"
|
52
51
|
|
53
|
-
expect(page).to
|
52
|
+
expect(page).to have_content "Naqdī barā-yi tamām-i"
|
54
53
|
click_on "Back to Search"
|
55
54
|
expect(page).to have_content "11 - 20"
|
56
55
|
end
|
@@ -171,7 +171,7 @@ RSpec.describe "Facets" do
|
|
171
171
|
visit root_path
|
172
172
|
|
173
173
|
within(".blacklight-subject_ssim") do
|
174
|
-
expect(page).to have_no_css(".
|
174
|
+
expect(page).to have_no_css(".accordion-body", visible: true)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
@@ -179,9 +179,9 @@ RSpec.describe "Facets" do
|
|
179
179
|
visit root_path
|
180
180
|
|
181
181
|
within(".blacklight-subject_ssim") do
|
182
|
-
expect(page).to have_no_css(".
|
182
|
+
expect(page).to have_no_css(".accordion-body", visible: true)
|
183
183
|
click_on 'Topic'
|
184
|
-
expect(page).to have_css(".
|
184
|
+
expect(page).to have_css(".accordion-body", visible: true)
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
@@ -189,9 +189,9 @@ RSpec.describe "Facets" do
|
|
189
189
|
visit root_path
|
190
190
|
|
191
191
|
within(".blacklight-subject_ssim") do
|
192
|
-
expect(page).to have_no_css(".
|
193
|
-
find(".
|
194
|
-
expect(page).to have_css(".
|
192
|
+
expect(page).to have_no_css(".accordion-body", visible: true)
|
193
|
+
find(".accordion-header").click
|
194
|
+
expect(page).to have_css(".accordion-body", visible: true)
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
@@ -93,15 +93,6 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
describe "#per_page_options_for_select" do
|
97
|
-
it "is the per-page values formatted as options_for_select" do
|
98
|
-
allow(helper).to receive_messages(blacklight_config: double(per_page: [11, 22, 33]))
|
99
|
-
expect(helper.per_page_options_for_select).to include ["11<span class=\"sr-only visually-hidden\"> per page</span>", 11]
|
100
|
-
expect(helper.per_page_options_for_select).to include ["22<span class=\"sr-only visually-hidden\"> per page</span>", 22]
|
101
|
-
expect(helper.per_page_options_for_select).to include ["33<span class=\"sr-only visually-hidden\"> per page</span>", 33]
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
96
|
describe "#should_render_field?" do
|
106
97
|
let(:field_config) { double('field config', if: true, unless: false) }
|
107
98
|
|
@@ -52,7 +52,7 @@ RSpec.describe Blacklight::Parameters do
|
|
52
52
|
let(:search_state) { Blacklight::SearchState.new(query_params, blacklight_config) }
|
53
53
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
54
54
|
|
55
|
-
context 'with
|
55
|
+
context 'with facebooks badly mangled query parameters' do
|
56
56
|
let(:query_params) do
|
57
57
|
ActionController::Parameters.new(
|
58
58
|
f: { field: { '0': 'first', '1': 'second' } },
|
@@ -67,17 +67,6 @@ RSpec.describe Blacklight::Parameters do
|
|
67
67
|
it 'normalizes the facets to the expected format' do
|
68
68
|
expect(params.permit_search_params.to_h.with_indifferent_access).to include f: { field: %w[first second] }, f_inclusive: { field: %w[first second] }
|
69
69
|
end
|
70
|
-
|
71
|
-
context 'when several fields are configured' do
|
72
|
-
before do
|
73
|
-
blacklight_config.add_facet_field 'other_field'
|
74
|
-
blacklight_config.add_facet_field 'some_other_pivot_field', pivot: %w[abc def]
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'normalizes the facets to the expected format' do
|
78
|
-
expect(params.permit_search_params.to_h.with_indifferent_access).to include f: { field: %w[first second] }, f_inclusive: { field: %w[first second] }
|
79
|
-
end
|
80
|
-
end
|
81
70
|
end
|
82
71
|
|
83
72
|
context 'with filter_search_state_fields set to false' do
|
@@ -198,22 +198,4 @@ RSpec.describe Blacklight::SearchState::FilterField do
|
|
198
198
|
expect(search_state.filter('some_field').include?(OpenStruct.new(value: '1'))).to be true
|
199
199
|
end
|
200
200
|
end
|
201
|
-
|
202
|
-
describe '#permitted_params' do
|
203
|
-
context 'with a pivot facet' do
|
204
|
-
let(:blacklight_config) do
|
205
|
-
Blacklight::Configuration.new.configure do |config|
|
206
|
-
config.add_facet_field 'my_pivot', pivot: %w[format language_ssim]
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'marks all the pivot fields as permitted' do
|
211
|
-
field = described_class.new blacklight_config.facet_fields['my_pivot'], search_state
|
212
|
-
expect(field.permitted_params).to eq({
|
213
|
-
f: { "-format" => [], "-language_ssim" => [], "format" => [], "language_ssim" => [] },
|
214
|
-
f_inclusive: { "format" => [], "language_ssim" => [] }
|
215
|
-
})
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
201
|
end
|
@@ -64,5 +64,12 @@ RSpec.describe Blacklight::Solr::Request, :api do
|
|
64
64
|
|
65
65
|
expect(subject.dig('json', 'query', 'bool', 'must')).to contain_exactly('some query', 'also required')
|
66
66
|
end
|
67
|
+
|
68
|
+
it 'filters out empty query' do
|
69
|
+
subject['q'] = ""
|
70
|
+
subject.append_boolean_query :must, 'present query'
|
71
|
+
|
72
|
+
expect(subject.dig('json', 'query', 'bool', 'must')).to contain_exactly('present query')
|
73
|
+
end
|
67
74
|
end
|
68
75
|
end
|
@@ -59,7 +59,7 @@ RSpec.describe Blacklight::SearchService, :api do
|
|
59
59
|
allow(blacklight_config).to receive(:default_solr_params).and_return(qt: 'custom_request_handler')
|
60
60
|
allow(blacklight_solr).to receive(:send_and_receive) do |path, params|
|
61
61
|
expect(path).to eq 'select'
|
62
|
-
expect(params[:params]['facet.field']).to
|
62
|
+
expect(params[:params]['facet.field']).to eq ["format", "{!ex=pub_date_ssim_single}pub_date_ssim", "subject_ssim", "language_ssim", "lc_1letter_ssim", "subject_geo_ssim", "subject_era_ssim"]
|
63
63
|
expect(params[:params]["facet.query"]).to eq ["pub_date_ssim:[#{5.years.ago.year} TO *]", "pub_date_ssim:[#{10.years.ago.year} TO *]", "pub_date_ssim:[#{25.years.ago.year} TO *]"]
|
64
64
|
expect(params[:params]).to include('rows' => 10, 'qt' => "custom_request_handler", 'q' => "", "f.subject_ssim.facet.limit" => 21, 'sort' => "score desc, pub_date_si desc, title_si asc")
|
65
65
|
end.and_return('response' => { 'docs' => [] })
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module PresenterTestHelpers
|
4
4
|
def controller
|
5
|
-
@controller ||=
|
5
|
+
@controller ||= ViewComponent::Base.test_controller.constantize.new.tap { |c| c.request = request }.extend(Rails.application.routes.url_helpers)
|
6
6
|
end
|
7
7
|
|
8
8
|
def request
|
@@ -28,14 +28,14 @@ RSpec.describe "catalog/facet_layout" do
|
|
28
28
|
it "is collapsable" do
|
29
29
|
render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
|
30
30
|
expect(rendered).to have_css 'button.collapsed[data-toggle="collapse"][data-bs-toggle="collapse"][aria-expanded="false"]'
|
31
|
-
expect(rendered).to have_css '.collapse .
|
31
|
+
expect(rendered).to have_css '.collapse .accordion-body'
|
32
32
|
end
|
33
33
|
|
34
34
|
it "is configured to be open by default" do
|
35
35
|
allow(facet_field).to receive_messages(collapse: false)
|
36
36
|
render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
|
37
37
|
expect(rendered).to have_css 'button[data-toggle="collapse"][data-bs-toggle="collapse"][aria-expanded="true"]'
|
38
|
-
expect(rendered).to have_no_css '.
|
39
|
-
expect(rendered).to have_css '.collapse.show .
|
38
|
+
expect(rendered).to have_no_css '.accordion-header.collapsed'
|
39
|
+
expect(rendered).to have_css '.collapse.show .accordion-body'
|
40
40
|
end
|
41
41
|
end
|
@@ -4,14 +4,11 @@ RSpec.describe 'catalog/facet.html.erb' do
|
|
4
4
|
let(:display_facet) { double }
|
5
5
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
6
6
|
let(:component) { instance_double(Blacklight::FacetComponent) }
|
7
|
-
let(:facet_suggest_input) { instance_double(Blacklight::Search::FacetSuggestInput) }
|
8
7
|
|
9
8
|
before do
|
10
9
|
allow(Blacklight::FacetComponent).to receive(:new).and_return(component)
|
11
|
-
allow(Blacklight::Search::FacetSuggestInput).to receive(:new).and_return(facet_suggest_input)
|
12
10
|
allow(view).to receive(:render).and_call_original
|
13
11
|
allow(view).to receive(:render).with(component)
|
14
|
-
allow(view).to receive(:render).with(facet_suggest_input)
|
15
12
|
|
16
13
|
blacklight_config.add_facet_field 'xyz', label: "Facet title"
|
17
14
|
allow(view).to receive(:blacklight_config).and_return(blacklight_config)
|
@@ -25,11 +22,6 @@ RSpec.describe 'catalog/facet.html.erb' do
|
|
25
22
|
expect(rendered).to have_css 'h1', text: "Facet title"
|
26
23
|
end
|
27
24
|
|
28
|
-
it "renders the facet suggest input" do
|
29
|
-
render
|
30
|
-
expect(view).to have_received(:render).with(facet_suggest_input)
|
31
|
-
end
|
32
|
-
|
33
25
|
it "renders facet pagination" do
|
34
26
|
render
|
35
27
|
expect(rendered).to have_content 'pagination'
|