blacklight 7.19.0 → 7.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +1 -1
- data/.github/workflows/ruby.yml +19 -1
- data/.rubocop.yml +4 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +14 -5
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +2 -2
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +1 -1
- data/app/assets/stylesheets/blacklight/_constraints.scss +8 -5
- data/app/assets/stylesheets/blacklight/_controls.scss +9 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +5 -3
- data/app/assets/stylesheets/blacklight/_header.scss +6 -1
- data/app/assets/stylesheets/blacklight/_pagination.scss +1 -1
- data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +1 -0
- data/app/components/blacklight/constraint_layout_component.html.erb +1 -1
- data/app/components/blacklight/constraints_component.html.erb +2 -2
- data/app/components/blacklight/constraints_component.rb +6 -2
- data/app/components/blacklight/document_component.rb +4 -4
- data/app/components/blacklight/facet_field_component.html.erb +3 -1
- data/app/components/blacklight/facet_field_no_layout_component.rb +1 -1
- data/app/components/blacklight/facet_item_component.rb +4 -4
- data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
- data/app/components/blacklight/metadata_field_layout_component.rb +1 -1
- data/app/components/blacklight/response/facet_group_component.html.erb +2 -0
- data/app/components/blacklight/response/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/view_type_component.html.erb +1 -1
- data/app/components/blacklight/search_bar_component.html.erb +3 -3
- data/app/components/blacklight/system/dropdown_component.rb +1 -1
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/modal_component.html.erb +1 -1
- data/app/controllers/concerns/blacklight/bookmarks.rb +0 -3
- data/app/controllers/concerns/blacklight/catalog.rb +3 -0
- data/app/controllers/concerns/blacklight/controller.rb +9 -5
- data/app/controllers/concerns/blacklight/search_context.rb +1 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -3
- data/app/helpers/blacklight/component_helper_behavior.rb +1 -1
- data/app/javascript/blacklight/core.js +8 -1
- data/app/javascript/blacklight/modal.js +1 -1
- data/app/javascript/blacklight/search_context.js +5 -2
- data/app/views/blacklight/nav/_bookmark.html.erb +1 -1
- data/app/views/bookmarks/index.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +2 -2
- data/app/views/catalog/_home_text.html.erb +3 -3
- data/app/views/catalog/_paginate_compact.html.erb +1 -0
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_search_results.html.erb +2 -2
- data/app/views/search_history/index.html.erb +1 -1
- data/app/views/shared/_header_navbar.html.erb +3 -3
- data/blacklight.gemspec +4 -2
- data/config/locales/blacklight.ar.yml +2 -2
- data/config/locales/blacklight.ca.yml +2 -2
- data/config/locales/blacklight.de.yml +6 -4
- data/config/locales/blacklight.en.yml +8 -4
- data/config/locales/blacklight.es.yml +5 -3
- data/config/locales/blacklight.fr.yml +5 -3
- data/config/locales/blacklight.hu.yml +2 -2
- data/config/locales/blacklight.it.yml +5 -3
- data/config/locales/blacklight.nl.yml +2 -2
- data/config/locales/blacklight.pt-BR.yml +1 -1
- data/config/locales/blacklight.sq.yml +2 -2
- data/config/locales/blacklight.zh.yml +2 -2
- data/lib/blacklight/search_state/filter_field.rb +9 -0
- data/lib/blacklight/solr/request.rb +10 -7
- data/lib/blacklight/solr/response/group_response.rb +3 -2
- data/lib/blacklight/solr/response/pagination_methods.rb +1 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +37 -17
- data/lib/blacklight.rb +5 -1
- data/lib/generators/blacklight/assets_generator.rb +4 -2
- data/lib/generators/blacklight/install_generator.rb +4 -1
- data/lib/generators/blacklight/user_generator.rb +1 -1
- data/package.json +2 -2
- data/spec/components/blacklight/constraint_layout_component_spec.rb +3 -7
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +3 -7
- data/spec/components/blacklight/facet_field_list_component_spec.rb +3 -7
- data/spec/components/blacklight/facet_item_component_spec.rb +8 -8
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +3 -7
- data/spec/components/blacklight/hidden_search_state_component_spec.rb +7 -8
- data/spec/components/blacklight/metadata_field_component_spec.rb +4 -8
- data/spec/features/axe_spec.rb +34 -0
- data/spec/features/facet_missing_spec.rb +59 -0
- data/spec/features/facets_spec.rb +3 -3
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +3 -3
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +2 -2
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +27 -0
- data/spec/models/blacklight/solr/request_spec.rb +0 -1
- data/spec/models/blacklight/solr/response/group_response_spec.rb +3 -2
- data/spec/models/blacklight/solr/search_builder_spec.rb +27 -1
- data/spec/spec_helper.rb +16 -9
- data/spec/support/view_component_capybara_test_helpers.rb +8 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -3
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +2 -2
- metadata +45 -11
@@ -3,9 +3,11 @@ module Blacklight
|
|
3
3
|
class Assets < Rails::Generators::Base
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
|
6
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 4.0'), desc: "Set the generated app's bootstrap version"
|
7
|
+
|
6
8
|
# This could be skipped if you want to use webpacker
|
7
9
|
def add_javascript_dependencies
|
8
|
-
gem 'bootstrap', '
|
10
|
+
gem 'bootstrap', options[:'bootstrap-version']
|
9
11
|
gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript'
|
10
12
|
end
|
11
13
|
|
@@ -15,7 +17,7 @@ module Blacklight
|
|
15
17
|
|
16
18
|
create_file 'app/assets/javascripts/application.js' do
|
17
19
|
<<~CONTENT
|
18
|
-
//= require
|
20
|
+
//= require jquery3
|
19
21
|
//= require rails-ujs
|
20
22
|
//= require turbolinks
|
21
23
|
CONTENT
|
@@ -10,6 +10,7 @@ module Blacklight
|
|
10
10
|
|
11
11
|
class_option :devise, type: :boolean, default: false, aliases: "-d", desc: "Use Devise as authentication logic."
|
12
12
|
class_option :marc, type: :boolean, default: false, aliases: "-m", desc: "Generate MARC-based demo."
|
13
|
+
class_option :'bootstrap-version', type: :string, default: nil, desc: "Set the generated app's bootstrap version"
|
13
14
|
class_option :'skip-assets', type: :boolean, default: !defined?(Sprockets), desc: "Skip generating javascript and css assets into the application"
|
14
15
|
class_option :'skip-solr', type: :boolean, default: false, desc: "Skip generating solr configurations."
|
15
16
|
|
@@ -33,7 +34,9 @@ module Blacklight
|
|
33
34
|
# Call external generator in AssetsGenerator, so we can
|
34
35
|
# leave that callable seperately too.
|
35
36
|
def copy_public_assets
|
36
|
-
|
37
|
+
generated_options = "--bootstrap-version #{options[:'bootstrap-version']}" if options[:'bootstrap-version']
|
38
|
+
|
39
|
+
generate "blacklight:assets", generated_options unless options[:'skip-assets']
|
37
40
|
end
|
38
41
|
|
39
42
|
def bundle_install
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "blacklight-frontend",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.20.1",
|
4
4
|
"description": "[![Build Status](https://travis-ci.com/projectblacklight/blacklight.png?branch=master)](https://travis-ci.com/projectblacklight/blacklight) [![Gem Version](https://badge.fury.io/rb/blacklight.png)](http://badge.fury.io/rb/blacklight) [![Coverage Status](https://coveralls.io/repos/github/projectblacklight/blacklight/badge.svg?branch=master)](https://coveralls.io/github/projectblacklight/blacklight?branch=master)",
|
5
5
|
"main": "app/assets/javascripts/blacklight",
|
6
6
|
"scripts": {
|
@@ -27,7 +27,7 @@
|
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
29
|
"bloodhound-js": "^1.2.3",
|
30
|
-
"bootstrap": "
|
30
|
+
"bootstrap": ">=4.3.1 <6.0.0",
|
31
31
|
"jquery": "^3.5.1",
|
32
32
|
"typeahead.js": "^0.11.1"
|
33
33
|
}
|
@@ -3,12 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::ConstraintLayoutComponent, type: :component do
|
6
|
-
subject(:
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:rendered) do
|
11
|
-
Capybara::Node::Simple.new(render)
|
6
|
+
subject(:rendered) do
|
7
|
+
render_inline_to_capybara_node(described_class.new(**params))
|
12
8
|
end
|
13
9
|
|
14
10
|
describe "for simple display" do
|
@@ -39,7 +35,7 @@ RSpec.describe Blacklight::ConstraintLayoutComponent, type: :component do
|
|
39
35
|
|
40
36
|
it "has an accessible remove label" do
|
41
37
|
expect(rendered).to have_selector(".remove") do |s|
|
42
|
-
expect(s).to have_selector('.
|
38
|
+
expect(s).to have_selector('.visually-hidden', text: 'Remove constraint my label: my value')
|
43
39
|
end
|
44
40
|
end
|
45
41
|
end
|
@@ -3,12 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
|
6
|
-
subject(:
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:rendered) do
|
11
|
-
Capybara::Node::Simple.new(render)
|
6
|
+
subject(:rendered) do
|
7
|
+
render_inline_to_capybara_node(described_class.new(facet_field: facet_field))
|
12
8
|
end
|
13
9
|
|
14
10
|
let(:facet_field) do
|
@@ -40,7 +36,7 @@ RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
|
|
40
36
|
it 'renders a collapsible card' do
|
41
37
|
expect(rendered).to have_selector '.card'
|
42
38
|
expect(rendered).to have_button 'Field'
|
43
|
-
expect(rendered).to have_selector 'button[data-target="#facet-field"]'
|
39
|
+
expect(rendered).to have_selector 'button[data-bs-target="#facet-field"]'
|
44
40
|
expect(rendered).to have_selector '#facet-field.collapse.show'
|
45
41
|
end
|
46
42
|
|
@@ -3,12 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
6
|
-
subject(:
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:rendered) do
|
11
|
-
Capybara::Node::Simple.new(render)
|
6
|
+
subject(:rendered) do
|
7
|
+
render_inline_to_capybara_node(described_class.new(facet_field: facet_field))
|
12
8
|
end
|
13
9
|
|
14
10
|
let(:facet_field) do
|
@@ -35,7 +31,7 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
35
31
|
it 'renders a collapsible card' do
|
36
32
|
expect(rendered).to have_selector '.card'
|
37
33
|
expect(rendered).to have_button 'Field'
|
38
|
-
expect(rendered).to have_selector 'button[data-target="#facet-field"]'
|
34
|
+
expect(rendered).to have_selector 'button[data-bs-target="#facet-field"]'
|
39
35
|
expect(rendered).to have_selector '#facet-field.collapse.show'
|
40
36
|
end
|
41
37
|
|
@@ -3,12 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::FacetItemComponent, type: :component do
|
6
|
-
subject(:
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:rendered) do
|
11
|
-
Capybara::Node::Simple.new(render)
|
6
|
+
subject(:rendered) do
|
7
|
+
render_inline_to_capybara_node(described_class.new(facet_item: facet_item))
|
12
8
|
end
|
13
9
|
|
14
10
|
let(:facet_item) do
|
@@ -24,7 +20,9 @@ RSpec.describe Blacklight::FacetItemComponent, type: :component do
|
|
24
20
|
|
25
21
|
it 'links to the facet and shows the number of hits' do
|
26
22
|
expect(rendered).to have_selector 'li'
|
27
|
-
expect(rendered).to have_link 'x', href: '/catalog?f=x'
|
23
|
+
expect(rendered).to have_link 'x', href: '/catalog?f=x' do |link|
|
24
|
+
link['rel'] == 'nofollow'
|
25
|
+
end
|
28
26
|
expect(rendered).to have_selector '.facet-count', text: '10'
|
29
27
|
end
|
30
28
|
|
@@ -43,7 +41,9 @@ RSpec.describe Blacklight::FacetItemComponent, type: :component do
|
|
43
41
|
it 'links to the facet and shows the number of hits' do
|
44
42
|
expect(rendered).to have_selector 'li'
|
45
43
|
expect(rendered).to have_selector '.selected', text: 'x'
|
46
|
-
expect(rendered).to have_link '[remove]', href: '/catalog'
|
44
|
+
expect(rendered).to have_link '[remove]', href: '/catalog' do |link|
|
45
|
+
link['rel'] == 'nofollow'
|
46
|
+
end
|
47
47
|
expect(rendered).to have_selector '.selected.facet-count', text: '10'
|
48
48
|
end
|
49
49
|
end
|
@@ -3,12 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
|
6
|
-
subject(:
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:rendered) do
|
11
|
-
Capybara::Node::Simple.new(render)
|
6
|
+
subject(:rendered) do
|
7
|
+
render_inline_to_capybara_node(described_class.new(facet_item: facet_item))
|
12
8
|
end
|
13
9
|
|
14
10
|
let(:search_state) do
|
@@ -31,7 +27,7 @@ RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
|
|
31
27
|
|
32
28
|
it 'links to the facet and shows the number of hits' do
|
33
29
|
expect(rendered).to have_selector 'li'
|
34
|
-
expect(rendered).to have_link 'x', href: '/catalog?f
|
30
|
+
expect(rendered).to have_link 'x', href: '/catalog?f%5Bz%5D=x'
|
35
31
|
expect(rendered).to have_selector '.facet-count', text: '10'
|
36
32
|
end
|
37
33
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::HiddenSearchStateComponent, type: :component do
|
4
|
-
subject(:
|
4
|
+
subject(:rendered) { render_inline_to_capybara_node(instance) }
|
5
5
|
|
6
6
|
let(:params) do
|
7
7
|
{ q: "query",
|
@@ -11,14 +11,13 @@ RSpec.describe Blacklight::HiddenSearchStateComponent, type: :component do
|
|
11
11
|
f: { field1: %w[a b], field2: ["z"] } }
|
12
12
|
end
|
13
13
|
let(:instance) { described_class.new(params: params) }
|
14
|
-
let(:generated) { Capybara::Node::Simple.new("<div>#{render.to_html}</div>") }
|
15
14
|
|
16
15
|
it "converts a hash with nested complex data to Rails-style hidden form fields" do
|
17
|
-
expect(
|
18
|
-
expect(
|
19
|
-
expect(
|
20
|
-
expect(
|
21
|
-
expect(
|
22
|
-
expect(
|
16
|
+
expect(rendered).to have_selector("input[type='hidden'][name='q'][value='query']", visible: :hidden)
|
17
|
+
expect(rendered).to have_selector("input[type='hidden'][name='per_page'][value='10']", visible: :hidden)
|
18
|
+
expect(rendered).to have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']", visible: :hidden)
|
19
|
+
expect(rendered).to have_selector("input[type='hidden'][name='f[field2][]'][value='z']", visible: :hidden)
|
20
|
+
expect(rendered).to have_selector("input[type='hidden'][name='f[field1][]'][value='a']", visible: :hidden)
|
21
|
+
expect(rendered).to have_selector("input[type='hidden'][name='f[field1][]'][value='b']", visible: :hidden)
|
23
22
|
end
|
24
23
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
|
6
|
-
subject(:
|
7
|
-
|
6
|
+
subject(:rendered) do
|
7
|
+
render_inline_to_capybara_node(described_class.new(field: field))
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:view_context) { controller.view_context }
|
@@ -15,10 +15,6 @@ RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
|
|
15
15
|
Blacklight::FieldPresenter.new(view_context, document, field_config)
|
16
16
|
end
|
17
17
|
|
18
|
-
let(:rendered) do
|
19
|
-
Capybara::Node::Simple.new(render)
|
20
|
-
end
|
21
|
-
|
22
18
|
it 'renders the field label' do
|
23
19
|
expect(rendered).to have_selector 'dt.blacklight-field', text: 'Field label'
|
24
20
|
end
|
@@ -28,8 +24,8 @@ RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
|
|
28
24
|
end
|
29
25
|
|
30
26
|
context 'from a show view' do
|
31
|
-
subject(:
|
32
|
-
|
27
|
+
subject(:rendered) do
|
28
|
+
render_inline_to_capybara_node(described_class.new(field: field, show: true))
|
33
29
|
end
|
34
30
|
|
35
31
|
it 'renders the right field label' do
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe 'Accessibility testing', api: false, js: true do
|
4
|
+
xit 'validates the home page' do
|
5
|
+
visit root_path
|
6
|
+
expect(page).to be_accessible
|
7
|
+
end
|
8
|
+
|
9
|
+
xit 'validates the catalog page' do
|
10
|
+
visit root_path
|
11
|
+
fill_in "q", with: 'history'
|
12
|
+
click_button 'search'
|
13
|
+
|
14
|
+
# aria-allowed-role doesn't like nav[role="region"]
|
15
|
+
expect(page).to be_accessible(skipping: ['aria-allowed-role'])
|
16
|
+
|
17
|
+
within '.card.blacklight-language_ssim' do
|
18
|
+
click_button 'Language'
|
19
|
+
click_link "Tibetan"
|
20
|
+
end
|
21
|
+
|
22
|
+
expect(page).to be_accessible(skipping: ['aria-allowed-role'])
|
23
|
+
end
|
24
|
+
|
25
|
+
xit 'validates the single results page' do
|
26
|
+
visit solr_document_path('2007020969')
|
27
|
+
expect(page).to be_accessible
|
28
|
+
end
|
29
|
+
|
30
|
+
def be_accessible(skipping: [])
|
31
|
+
# typeahead does funny things with the search bar
|
32
|
+
be_axe_clean.excluding('.tt-hint').skipping(skipping + [('color-contrast' if Bootstrap::VERSION < '5')])
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe "Facet missing" do
|
4
|
+
before do
|
5
|
+
CatalogController.blacklight_config[:default_solr_params]["facet.missing"] = true
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
CatalogController.blacklight_config[:default_solr_params].delete("facet.missing")
|
10
|
+
end
|
11
|
+
|
12
|
+
context "selecting missing field in facets" do
|
13
|
+
it "adds facet missing query and constraints" do
|
14
|
+
visit root_path
|
15
|
+
|
16
|
+
within "#facet-subject_geo_ssim" do
|
17
|
+
click_link "[Missing]"
|
18
|
+
end
|
19
|
+
|
20
|
+
within "#facet-subject_geo_ssim" do
|
21
|
+
expect(page).to have_selector("span.selected", text: "[Missing")
|
22
|
+
expect(page).to have_selector("span.facet-count.selected", text: "13")
|
23
|
+
end
|
24
|
+
|
25
|
+
within "#sortAndPerPage" do
|
26
|
+
expect(page).to have_content "1 - 10 of 13"
|
27
|
+
end
|
28
|
+
|
29
|
+
expect(page).to have_css(".constraint-value", text: "Region")
|
30
|
+
expect(page).to have_css(".constraint-value", text: "[Missing]")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "unselecting the facet missing facet" do
|
35
|
+
it "unselects the missig field facet" do
|
36
|
+
visit root_path + "?f[-subject_geo_ssim:[* TO *]][]=&f[subject_geo_ssim][]="
|
37
|
+
|
38
|
+
within "#facet-subject_geo_ssim" do
|
39
|
+
click_link "remove"
|
40
|
+
end
|
41
|
+
|
42
|
+
expect(page).not_to have_link "remove"
|
43
|
+
expect(page).to have_content("Welcome!")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "unselecting the facet missing constraint" do
|
48
|
+
it "unselects the missig field facet" do
|
49
|
+
visit root_path + "?f[-subject_geo_ssim:[* TO *]][]=&f[subject_geo_ssim][]="
|
50
|
+
|
51
|
+
within ".filter-subject_geo_ssim" do
|
52
|
+
click_link "Remove constraint Region: [Missing]"
|
53
|
+
end
|
54
|
+
|
55
|
+
expect(page).not_to have_link "remove"
|
56
|
+
expect(page).to have_content("Welcome!")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -69,7 +69,7 @@ RSpec.describe "Facets" do
|
|
69
69
|
page.find('h3.facet-field-heading button', text: 'Pivot Field').click
|
70
70
|
|
71
71
|
within '#facet-example_pivot_field' do
|
72
|
-
expect(page).to have_css('.facet-leaf-node', text: "Book
|
72
|
+
expect(page).to have_css('.facet-leaf-node', text: "Book 30")
|
73
73
|
expect(page).not_to have_css('.facet-select', text: 'Tibetan')
|
74
74
|
page.find('.facet-toggle-handle').click
|
75
75
|
click_link 'Tibetan'
|
@@ -84,13 +84,13 @@ RSpec.describe "Facets" do
|
|
84
84
|
pending 'Capybara::NotSupportedByDriverError: Capybara::Driver::Base#evaluate_script'
|
85
85
|
visit root_path
|
86
86
|
page.find('h3.facet-field-heading button', text: 'Format').click
|
87
|
-
focused_element_data_target = page.evaluate_script("document.activeElement")['data-target']
|
87
|
+
focused_element_data_target = page.evaluate_script("document.activeElement")['data-bs-target']
|
88
88
|
expect(focused_element_data_target).to eq '#facet-format'
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
describe '"More" links' do
|
93
|
-
it 'has default more link with
|
93
|
+
it 'has default more link with visually-hidden text' do
|
94
94
|
visit root_path
|
95
95
|
within '#facet-language_ssim' do
|
96
96
|
expect(page).to have_css 'div.more_facets', text: 'more Language'
|
@@ -194,9 +194,9 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
194
194
|
describe "#per_page_options_for_select" do
|
195
195
|
it "is the per-page values formatted as options_for_select" do
|
196
196
|
allow(helper).to receive_messages(blacklight_config: double(per_page: [11, 22, 33]))
|
197
|
-
expect(helper.per_page_options_for_select).to include ["11<span class=\"sr-only\"> per page</span>", 11]
|
198
|
-
expect(helper.per_page_options_for_select).to include ["22<span class=\"sr-only\"> per page</span>", 22]
|
199
|
-
expect(helper.per_page_options_for_select).to include ["33<span class=\"sr-only\"> per page</span>", 33]
|
197
|
+
expect(helper.per_page_options_for_select).to include ["11<span class=\"sr-only visually-hidden\"> per page</span>", 11]
|
198
|
+
expect(helper.per_page_options_for_select).to include ["22<span class=\"sr-only visually-hidden\"> per page</span>", 22]
|
199
|
+
expect(helper.per_page_options_for_select).to include ["33<span class=\"sr-only visually-hidden\"> per page</span>", 33]
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
@@ -314,7 +314,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
314
314
|
end
|
315
315
|
|
316
316
|
describe "simple case" do
|
317
|
-
let(:expected_html) { '<span class="facet-label"><a class="facet-select" href="/catalog">Z</a></span><span class="facet-count">10</span>' }
|
317
|
+
let(:expected_html) { '<span class="facet-label"><a class="facet-select" rel="nofollow" href="/catalog">Z</a></span><span class="facet-count">10</span>' }
|
318
318
|
|
319
319
|
it "uses facet_display_value" do
|
320
320
|
result = helper.render_facet_value('simple_field', item)
|
@@ -323,7 +323,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
|
|
323
323
|
end
|
324
324
|
|
325
325
|
describe "when :url_method is set" do
|
326
|
-
let(:expected_html) { '<span class="facet-label"><a class="facet-select" href="/blabla">Z</a></span><span class="facet-count">10</span>' }
|
326
|
+
let(:expected_html) { '<span class="facet-label"><a class="facet-select" rel="nofollow" href="/blabla">Z</a></span><span class="facet-count">10</span>' }
|
327
327
|
|
328
328
|
it "uses that method" do
|
329
329
|
allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: :test_method))
|
@@ -159,6 +159,33 @@ RSpec.describe Blacklight::SearchState::FilterField do
|
|
159
159
|
expect(new_state.filter('another_field').values).to eq ['3']
|
160
160
|
end
|
161
161
|
end
|
162
|
+
|
163
|
+
context "With facet.missing field" do
|
164
|
+
let(:params) do
|
165
|
+
{ f: { some_field: [""], "-some_field:": [""] } }
|
166
|
+
end
|
167
|
+
|
168
|
+
it "removes facet.missing facet params" do
|
169
|
+
filter = search_state.filter("some_field")
|
170
|
+
new_state = filter.remove(OpenStruct.new(fq: "-some_field:[* TO *]"))
|
171
|
+
|
172
|
+
expect(new_state.params).to eq("f" => {})
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context "With facet.missing field value" do
|
177
|
+
let(:params) do
|
178
|
+
{ f: { some_field: [""], "-some_field:": [""] } }
|
179
|
+
end
|
180
|
+
|
181
|
+
it "removes facet.missing facet params" do
|
182
|
+
missing = I18n.t("blacklight.search.facets.missing")
|
183
|
+
filter = search_state.filter("some_field")
|
184
|
+
new_state = filter.remove(missing)
|
185
|
+
|
186
|
+
expect(new_state.params).to eq("f" => {})
|
187
|
+
end
|
188
|
+
end
|
162
189
|
end
|
163
190
|
|
164
191
|
describe '#values' do
|
@@ -69,8 +69,9 @@ RSpec.describe Blacklight::Solr::Response::GroupResponse, api: true do
|
|
69
69
|
it "accesses a custom field grouped i18n key" do
|
70
70
|
allow(I18n).to receive(:t).with(
|
71
71
|
'blacklight.entry_name.grouped.result_group_ssi',
|
72
|
-
default: :'blacklight.entry_name.grouped.default'
|
73
|
-
|
72
|
+
default: :'blacklight.entry_name.grouped.default',
|
73
|
+
count: 2
|
74
|
+
).and_return('cool groups')
|
74
75
|
expect(group.entry_name(count: 2)).to eq 'cool groups'
|
75
76
|
end
|
76
77
|
|
@@ -27,6 +27,24 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
27
27
|
it "uses the class-level default_processor_chain" do
|
28
28
|
expect(subject.processor_chain).to eq search_builder_class.default_processor_chain
|
29
29
|
end
|
30
|
+
|
31
|
+
it "appends the :add_missing_field_query processor" do
|
32
|
+
expect(subject.processor_chain).to include(:add_missing_field_query)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with merged parameters from the defaults + the search field' do
|
37
|
+
before do
|
38
|
+
blacklight_config.default_solr_params = { json: { whatever: [1, 2, 3] } }
|
39
|
+
blacklight_config.search_fields['all_fields'].solr_parameters = { json: { and_also: [4, 5, 6] } }
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:user_params) { { search_field: 'all_fields' } }
|
43
|
+
|
44
|
+
it 'deep merges hash values' do
|
45
|
+
expect(subject.to_hash.dig(:json, :whatever)).to eq [1, 2, 3]
|
46
|
+
expect(subject.to_hash.dig(:json, :and_also)).to eq [4, 5, 6]
|
47
|
+
end
|
30
48
|
end
|
31
49
|
|
32
50
|
context "with a complex parameter environment" do
|
@@ -304,7 +322,6 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
304
322
|
|
305
323
|
it "does not include weird keys not in field definition" do
|
306
324
|
expect(subject[:phrase_filters]).to be_nil
|
307
|
-
expect(subject[:fq]).to eq []
|
308
325
|
expect(subject[:commit]).to be_nil
|
309
326
|
expect(subject[:action]).to be_nil
|
310
327
|
expect(subject[:controller]).to be_nil
|
@@ -809,4 +826,13 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
809
826
|
expect(subject.to_hash).to include q: '{!lucene}id:(1 OR 2 OR 3)'
|
810
827
|
end
|
811
828
|
end
|
829
|
+
|
830
|
+
describe "#add_missing_field_query" do
|
831
|
+
it "precesses facet.missing query" do
|
832
|
+
subject.with("f" => { "-hello:" => [""] })
|
833
|
+
solr_params = { "facet.missing" => true, fq: [] }
|
834
|
+
|
835
|
+
expect(subject.add_missing_field_query(solr_params)).to eq(["-hello:[* TO *]"])
|
836
|
+
end
|
837
|
+
end
|
812
838
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -19,18 +19,24 @@ EngineCart.load_application!
|
|
19
19
|
require 'rspec/rails'
|
20
20
|
require 'rspec/its'
|
21
21
|
require 'rspec/collection_matchers'
|
22
|
-
require 'capybara/
|
23
|
-
require '
|
22
|
+
require 'capybara/rails'
|
23
|
+
require 'webdrivers'
|
24
|
+
require 'selenium-webdriver'
|
24
25
|
require 'equivalent-xml'
|
26
|
+
require 'axe-rspec'
|
25
27
|
|
26
|
-
Capybara.javascript_driver = :
|
27
|
-
Capybara.disable_animation = true
|
28
|
-
# Capybara.enable_aria_label = true
|
28
|
+
Capybara.javascript_driver = :headless_chrome
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
Capybara.register_driver :headless_chrome do |app|
|
31
|
+
Capybara::Selenium::Driver.load_selenium
|
32
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
33
|
+
opts.args << '--headless'
|
34
|
+
opts.args << '--disable-gpu'
|
35
|
+
opts.args << '--no-sandbox'
|
36
|
+
opts.args << '--window-size=1280,1696'
|
37
|
+
end
|
38
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
39
|
+
end
|
34
40
|
|
35
41
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
36
42
|
# in spec/support/ and its subdirectories.
|
@@ -62,6 +68,7 @@ RSpec.configure do |config|
|
|
62
68
|
config.infer_spec_type_from_file_location!
|
63
69
|
config.include PresenterTestHelpers, type: :presenter
|
64
70
|
config.include ViewComponent::TestHelpers, type: :component
|
71
|
+
config.include ViewComponentCapybaraTestHelpers, type: :component
|
65
72
|
|
66
73
|
config.include(ControllerLevelHelpers, type: :helper)
|
67
74
|
config.before(:each, type: :helper) { initialize_controller_helpers(helper) }
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ViewComponentCapybaraTestHelpers
|
4
|
+
# Work around for https://github.com/teamcapybara/capybara/issues/2466
|
5
|
+
def render_inline_to_capybara_node(component)
|
6
|
+
Capybara::Node::Simple.new(render_inline(component).to_s)
|
7
|
+
end
|
8
|
+
end
|
@@ -17,9 +17,6 @@ class TestAppGenerator < Rails::Generators::Base
|
|
17
17
|
options = '--devise'
|
18
18
|
if ENV['BLACKLIGHT_API_TEST']
|
19
19
|
options += ' --skip-assets'
|
20
|
-
inject_into_class 'app/controllers/application_controller.rb', 'ApplicationController' do
|
21
|
-
" include ActionController::MimeResponds\n" # see https://github.com/projectblacklight/blacklight/issues/1894
|
22
|
-
end
|
23
20
|
end
|
24
21
|
|
25
22
|
generate 'blacklight:install', options
|
@@ -27,14 +27,14 @@ RSpec.describe "catalog/facet_layout" do
|
|
27
27
|
|
28
28
|
it "is collapsable" do
|
29
29
|
render partial: 'catalog/facet_layout', locals: { facet_field: facet_field }
|
30
|
-
expect(rendered).to have_selector 'button.collapsed[data-toggle="collapse"][aria-expanded="false"]'
|
30
|
+
expect(rendered).to have_selector 'button.collapsed[data-toggle="collapse"][data-bs-toggle="collapse"][aria-expanded="false"]'
|
31
31
|
expect(rendered).to have_selector '.collapse .card-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
|
-
expect(rendered).to have_selector 'button[data-toggle="collapse"][aria-expanded="true"]'
|
37
|
+
expect(rendered).to have_selector 'button[data-toggle="collapse"][data-bs-toggle="collapse"][aria-expanded="true"]'
|
38
38
|
expect(rendered).not_to have_selector '.card-header.collapsed'
|
39
39
|
expect(rendered).to have_selector '.collapse.show .card-body'
|
40
40
|
end
|