blacklight 9.0.0.beta1 → 9.0.0.beta2
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/matrix.json +47 -0
- data/.github/workflows/build.yml +16 -0
- data/.github/workflows/lint.yml +25 -0
- data/.github/workflows/main.yml +22 -0
- data/.github/workflows/release_7_x_scheduled.yml +39 -0
- data/.github/workflows/release_8_x_scheduled.yml +39 -0
- data/.github/workflows/test.yml +53 -0
- data/.rubocop.yml +70 -2
- data/.rubocop_todo.yml +43 -67
- data/.solr_wrapper.yml +2 -0
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +19 -15
- data/app/assets/javascripts/blacklight/blacklight.esm.js +31 -69
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +31 -69
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +4 -0
- data/app/assets/stylesheets/blacklight/_facets.scss +2 -2
- data/app/assets/stylesheets/blacklight/_header.scss +4 -0
- data/app/assets/stylesheets/blacklight/_modal.scss +9 -8
- data/app/assets/stylesheets/blacklight/_pagination.scss +1 -3
- data/app/assets/stylesheets/blacklight/_search_history.scss +0 -4
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +3 -0
- data/app/components/blacklight/advanced_search_form_component.rb +2 -2
- data/app/components/blacklight/constraints_component.rb +2 -2
- data/app/components/blacklight/document/action_component.rb +1 -3
- data/app/components/blacklight/document/bookmark_component.rb +2 -2
- data/app/components/blacklight/document/more_like_this_component.rb +2 -2
- data/app/components/blacklight/document/page_header_component.rb +2 -2
- data/app/components/blacklight/document/thumbnail_component.html.erb +3 -7
- data/app/components/blacklight/document/thumbnail_component.rb +7 -6
- data/app/components/blacklight/document_component.rb +3 -3
- data/app/components/blacklight/document_title_component.rb +3 -10
- data/app/components/blacklight/facet_field_checkboxes_component.rb +2 -20
- data/app/components/blacklight/facet_field_component.rb +2 -17
- data/app/components/blacklight/facet_field_filter_component.rb +2 -21
- data/app/components/blacklight/facet_field_inclusive_constraint_component.rb +4 -25
- data/app/components/blacklight/facet_field_list_component.rb +2 -32
- data/app/components/blacklight/facet_field_no_layout_component.rb +2 -10
- data/app/components/blacklight/facet_field_pagination_component.html.erb +2 -2
- data/app/components/blacklight/facet_item_component.rb +2 -74
- data/app/components/blacklight/facet_item_pivot_component.rb +1 -1
- data/app/components/blacklight/facets/checkboxes_component.rb +26 -0
- data/app/components/blacklight/facets/count_component.rb +23 -0
- data/app/components/blacklight/{facet_field_component.html.erb → facets/field_component.html.erb} +1 -1
- data/app/components/blacklight/facets/field_component.rb +23 -0
- data/app/components/blacklight/facets/filters_component.html.erb +4 -0
- data/app/components/blacklight/facets/filters_component.rb +27 -0
- data/app/components/blacklight/{facet_field_inclusive_constraint_component.html.erb → facets/inclusive_constraint_component.html.erb} +1 -1
- data/app/components/blacklight/facets/inclusive_constraint_component.rb +31 -0
- data/app/components/blacklight/{facet_field_filter_component.html.erb → facets/index_navigation_component.html.erb} +1 -1
- data/app/components/blacklight/facets/index_navigation_component.rb +32 -0
- data/app/components/blacklight/facets/item_component.rb +73 -0
- data/app/components/blacklight/facets/list_component.html.erb +11 -0
- data/app/components/blacklight/facets/list_component.rb +38 -0
- data/app/components/blacklight/facets/no_layout_component.rb +16 -0
- data/app/components/blacklight/facets/selected_value_component.rb +29 -0
- data/app/components/blacklight/facets/suggest_component.html.erb +12 -0
- data/app/components/blacklight/facets/suggest_component.rb +22 -0
- data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +2 -2
- data/app/components/blacklight/response/facet_group_component.html.erb +1 -1
- data/app/components/blacklight/response/facet_group_component.rb +5 -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/bookmarks.rb +3 -3
- data/app/controllers/concerns/blacklight/catalog.rb +10 -25
- data/app/controllers/concerns/blacklight/controller.rb +1 -1
- data/app/controllers/concerns/blacklight/facetable.rb +34 -0
- data/app/controllers/concerns/blacklight/search_context.rb +1 -1
- data/app/controllers/concerns/blacklight/searchable.rb +1 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/document_helper_behavior.rb +3 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +9 -0
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -2
- data/app/javascript/blacklight-frontend/checkbox_submit.js +3 -0
- data/app/javascript/blacklight-frontend/debounce.js +1 -1
- data/app/javascript/blacklight-frontend/facet_suggest.js +23 -3
- data/app/javascript/blacklight-frontend/index.js +0 -2
- data/app/javascript/blacklight-frontend/modal.js +1 -4
- data/app/javascript/blacklight-frontend/search_context.js +3 -2
- data/app/models/facet_search_builder.rb +5 -0
- data/app/presenters/blacklight/facet_field_presenter.rb +1 -1
- data/app/presenters/blacklight/json_presenter.rb +1 -3
- data/app/presenters/blacklight/rendering/helper_method.rb +4 -4
- data/app/presenters/blacklight/rendering/join.rb +2 -2
- data/app/services/blacklight/facet_search_service.rb +44 -0
- data/app/services/blacklight/field_retriever.rb +1 -1
- data/app/services/blacklight/search_service.rb +6 -6
- data/app/values/blacklight/types.rb +2 -2
- data/app/views/catalog/_facet_pivot.html.erb +1 -1
- data/app/views/catalog/_home_text.html.erb +2 -2
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +8 -10
- data/config/locales/blacklight.ar.yml +2 -2
- data/config/locales/blacklight.es.yml +2 -2
- data/config/locales/blacklight.fr.yml +2 -2
- data/config/locales/blacklight.hu.yml +2 -2
- data/config/locales/blacklight.it.yml +2 -2
- data/config/locales/blacklight.nl.yml +1 -1
- data/config/locales/blacklight.pt-BR.yml +2 -2
- data/config/locales/blacklight.sq.yml +2 -2
- data/config/locales/blacklight.zh.yml +2 -2
- data/lib/blacklight/abstract_repository.rb +2 -2
- data/lib/blacklight/abstract_search_builder.rb +154 -0
- data/lib/blacklight/configuration/context.rb +3 -3
- data/lib/blacklight/configuration/facet_field.rb +6 -6
- data/lib/blacklight/configuration/field.rb +4 -4
- data/lib/blacklight/configuration/fields.rb +0 -1
- data/lib/blacklight/configuration/search_field.rb +1 -1
- data/lib/blacklight/configuration/view_config.rb +2 -2
- data/lib/blacklight/configuration.rb +6 -7
- data/lib/blacklight/facet_search_builder.rb +18 -0
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -1
- data/lib/blacklight/open_struct_with_hash_access.rb +2 -2
- data/lib/blacklight/search_builder.rb +1 -159
- data/lib/blacklight/search_state/filter_field.rb +4 -4
- data/lib/blacklight/search_state/pivot_filter_field.rb +4 -4
- data/lib/blacklight/solr/abstract_filter_query_builder.rb +77 -0
- data/lib/blacklight/solr/default_filter_query_builder.rb +20 -0
- data/lib/blacklight/solr/facet_search_builder_behavior.rb +62 -0
- data/lib/blacklight/solr/repository.rb +8 -9
- data/lib/blacklight/solr/response/facets.rb +2 -2
- data/lib/blacklight/solr/response/params.rb +0 -4
- data/lib/blacklight/solr/response.rb +5 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +17 -132
- data/lib/blacklight.rb +1 -1
- data/lib/generators/blacklight/assets/importmap_generator.rb +3 -5
- data/lib/generators/blacklight/assets_generator.rb +1 -1
- data/lib/generators/blacklight/search_builder_generator.rb +1 -1
- data/lib/generators/blacklight/templates/.solr_wrapper.yml +2 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +3 -1
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -4
- data/package.json +3 -3
- data/spec/components/blacklight/advanced_search_form_component_spec.rb +18 -22
- data/spec/components/blacklight/constraint_layout_component_spec.rb +8 -8
- data/spec/components/blacklight/constraints_component_spec.rb +11 -11
- data/spec/components/blacklight/document/action_component_spec.rb +23 -15
- data/spec/components/blacklight/document/group_component_spec.rb +10 -15
- data/spec/components/blacklight/document/page_header_component_spec.rb +35 -28
- data/spec/components/blacklight/document/sidebar_component_spec.rb +5 -11
- data/spec/components/blacklight/document_component_spec.rb +98 -65
- data/spec/components/blacklight/facet_component_spec.rb +12 -8
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +12 -12
- data/spec/components/blacklight/{facet_field_checkboxes_component_spec.rb → facets/checkboxes_component_spec.rb} +13 -13
- data/spec/components/blacklight/facets/filters_component_spec.rb +36 -0
- data/spec/components/blacklight/facets/index_navigation_component_spec.rb +40 -0
- data/spec/components/blacklight/{facet_item_component_spec.rb → facets/item_component_spec.rb} +10 -10
- data/spec/components/blacklight/{facet_field_list_component_spec.rb → facets/list_component_spec.rb} +23 -23
- data/spec/components/blacklight/facets/suggest_component_spec.rb +68 -0
- data/spec/components/blacklight/header_component_spec.rb +2 -4
- data/spec/components/blacklight/hidden_search_state_component_spec.rb +7 -7
- data/spec/components/blacklight/metadata_field_component_spec.rb +17 -15
- data/spec/components/blacklight/response/facet_group_component_spec.rb +37 -0
- data/spec/components/blacklight/response/pagination_component_spec.rb +1 -1
- data/spec/components/blacklight/response/spellcheck_component_spec.rb +1 -1
- data/spec/components/blacklight/search_bar_component_spec.rb +4 -4
- data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +2 -2
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +3 -5
- data/spec/components/blacklight/skip_link_component_spec.rb +8 -11
- data/spec/components/blacklight/start_over_button_component_spec.rb +4 -4
- data/spec/components/blacklight/system/dropdown_component_spec.rb +26 -0
- data/spec/components/blacklight/system/flash_message_component_spec.rb +7 -11
- data/spec/controllers/catalog_controller_spec.rb +12 -20
- data/spec/features/facets_spec.rb +70 -7
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +10 -0
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +2 -2
- data/spec/lib/blacklight/parameters_spec.rb +12 -1
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +18 -0
- data/spec/models/blacklight/configuration_spec.rb +32 -28
- data/spec/models/blacklight/facet_search_builder_spec.rb +19 -0
- data/spec/models/blacklight/search_builder_spec.rb +1 -11
- data/spec/models/blacklight/solr/default_filter_query_builder_spec.rb +72 -0
- data/spec/models/blacklight/solr/document_spec.rb +0 -4
- data/spec/models/blacklight/solr/facet_search_builder_behavior_spec.rb +929 -0
- data/spec/models/blacklight/solr/repository_spec.rb +31 -29
- data/spec/models/blacklight/solr/response/facets_spec.rb +86 -40
- data/spec/models/blacklight/solr/response/group_response_spec.rb +8 -5
- data/spec/models/blacklight/solr/response/group_spec.rb +9 -5
- data/spec/models/blacklight/solr/response_spec.rb +96 -64
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +2 -227
- data/spec/models/solr_document_spec.rb +5 -1
- data/spec/services/blacklight/search_service_spec.rb +6 -27
- data/spec/spec_helper.rb +0 -1
- data/spec/support/view_component_test_helpers.rb +0 -18
- data/spec/views/catalog/facet.html.erb_spec.rb +10 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +6 -3
- data/spec/views/catalog/index.html.erb_spec.rb +3 -1
- metadata +58 -29
- data/.github/workflows/ruby.yml +0 -98
- data/app/components/blacklight/facet_field_list_component.html.erb +0 -19
- data/app/components/blacklight/search/facet_suggest_input.html.erb +0 -9
- data/app/components/blacklight/search/facet_suggest_input.rb +0 -16
- data/app/javascript/blacklight-frontend/modalForm.js +0 -60
- data/app/views/catalog/_facet_index_navigation.html.erb +0 -1
- data/app/views/catalog/_facet_layout.html.erb +0 -8
- data/app/views/catalog/_facet_pagination.html.erb +0 -1
- data/spec/components/blacklight/document_metadata_component_spec.rb +0 -0
- data/spec/components/blacklight/search/facet_suggest_input_spec.rb +0 -33
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +0 -43
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +0 -41
- /data/app/components/blacklight/{facet_field_checkboxes_component.html.erb → facets/checkboxes_component.html.erb} +0 -0
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::ConstraintLayoutComponent, type: :component do
|
6
|
-
|
7
|
-
|
6
|
+
before do
|
7
|
+
render_inline described_class.new(**params)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "for simple display" do
|
@@ -13,7 +13,7 @@ RSpec.describe Blacklight::ConstraintLayoutComponent, type: :component do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "renders label and value" do
|
16
|
-
expect(
|
16
|
+
expect(page).to have_css("span.applied-filter.constraint") do |s|
|
17
17
|
expect(s).to have_css("span.constraint-value")
|
18
18
|
expect(s).to have_no_css("a.constraint-value")
|
19
19
|
expect(s).to have_css "span.filter-name", text: "my label"
|
@@ -28,13 +28,13 @@ RSpec.describe Blacklight::ConstraintLayoutComponent, type: :component do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "includes remove link" do
|
31
|
-
expect(
|
31
|
+
expect(page).to have_css("span.applied-filter") do |s|
|
32
32
|
expect(s).to have_css(".remove[href='http://remove']")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
it "has an accessible remove label" do
|
37
|
-
expect(
|
37
|
+
expect(page).to have_css(".remove") do |s|
|
38
38
|
expect(s).to have_css('.visually-hidden', text: 'Remove constraint my label: my value')
|
39
39
|
end
|
40
40
|
end
|
@@ -46,7 +46,7 @@ RSpec.describe Blacklight::ConstraintLayoutComponent, type: :component do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "includes them" do
|
49
|
-
expect(
|
49
|
+
expect(page).to have_css("span.applied-filter.constraint.class1.class2")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -56,8 +56,8 @@ RSpec.describe Blacklight::ConstraintLayoutComponent, type: :component do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "does not escape key and value" do
|
59
|
-
expect(
|
60
|
-
expect(
|
59
|
+
expect(page).to have_css("span.applied-filter.constraint span.filter-name span.custom_label")
|
60
|
+
expect(page).to have_css("span.applied-filter.constraint span.filter-value span.custom_value")
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
RSpec.describe Blacklight::ConstraintsComponent, type: :component do
|
6
6
|
subject(:component) { described_class.new(**params) }
|
7
7
|
|
8
|
-
|
8
|
+
before { render_inline(component) }
|
9
9
|
|
10
10
|
let(:params) do
|
11
11
|
{ search_state: search_state }
|
@@ -32,19 +32,19 @@ RSpec.describe Blacklight::ConstraintsComponent, type: :component do
|
|
32
32
|
let(:query_params) { { q: 'some query' } }
|
33
33
|
|
34
34
|
it 'renders a start-over link' do
|
35
|
-
expect(
|
35
|
+
expect(page).to have_link 'Start Over', href: '/catalog'
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'has a header' do
|
39
|
-
expect(
|
39
|
+
expect(page).to have_css('h2', text: 'Search Constraints')
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'wraps the output in a div' do
|
43
|
-
expect(
|
43
|
+
expect(page).to have_css('div#appliedParams')
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'renders the query' do
|
47
|
-
expect(
|
47
|
+
expect(page).to have_css('.applied-filter.constraint', text: 'some query')
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -52,15 +52,15 @@ RSpec.describe Blacklight::ConstraintsComponent, type: :component do
|
|
52
52
|
let(:query_params) { { f: { some_facet: ['some value'] } } }
|
53
53
|
|
54
54
|
it 'renders the query' do
|
55
|
-
expect(
|
55
|
+
expect(page).to have_css('.constraint-value > .filter-name', text: 'Some Facet').and(have_css('.constraint-value > .filter-value', text: 'some value'))
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'that is not configured' do
|
59
59
|
let(:query_params) { { f: { some_facet: ['some value'], missing: ['another value'] } } }
|
60
60
|
|
61
61
|
it 'renders only the configured constraints' do
|
62
|
-
expect(
|
63
|
-
expect(
|
62
|
+
expect(page).to have_css('.constraint-value > .filter-name', text: 'Some Facet').and(have_css('.constraint-value > .filter-value', text: 'some value'))
|
63
|
+
expect(page).to have_no_css('.constraint-value > .filter-name', text: 'Missing')
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -71,15 +71,15 @@ RSpec.describe Blacklight::ConstraintsComponent, type: :component do
|
|
71
71
|
let(:query_params) { { q: 'some query', f: { some_facet: ['some value'] } } }
|
72
72
|
|
73
73
|
it 'wraps the output in a span' do
|
74
|
-
expect(
|
74
|
+
expect(page).to have_css('span .constraint')
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'renders the search state as lightly-decorated text' do
|
78
|
-
expect(
|
78
|
+
expect(page).to have_css('.constraint > .filter-values', text: 'some query').and(have_css('.constraint', text: 'Some Facet:some value'))
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'omits the headers' do
|
82
|
-
expect(
|
82
|
+
expect(page).to have_no_css('h2', text: 'Search Constraints')
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -6,35 +6,43 @@ RSpec.describe Blacklight::Document::ActionComponent, type: :component do
|
|
6
6
|
subject(:component) { described_class.new(document: document, action: action, **attr) }
|
7
7
|
|
8
8
|
let(:action) { Blacklight::Configuration::ToolConfig.new(key: 'some_tool', name: 'some_tool', component: true) }
|
9
|
-
let(:attr) { {} }
|
10
|
-
let(:view_context) { controller.view_context }
|
11
|
-
let(:render) do
|
12
|
-
component.render_in(view_context)
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:rendered) do
|
16
|
-
Capybara::Node::Simple.new(render)
|
17
|
-
end
|
18
|
-
|
19
9
|
let(:document) do
|
20
10
|
SolrDocument.new(
|
21
11
|
id: 'x'
|
22
12
|
)
|
23
13
|
end
|
14
|
+
let(:attr) { {} }
|
15
|
+
let(:view_context) { vc_test_controller.view_context }
|
16
|
+
|
17
|
+
before do
|
18
|
+
# Every call to view_context returns a different object. This ensures it stays stable.
|
19
|
+
allow(vc_test_controller).to receive_messages(view_context: view_context)
|
20
|
+
end
|
24
21
|
|
25
|
-
|
26
|
-
|
22
|
+
context 'with a configured path' do
|
23
|
+
before do
|
24
|
+
allow(view_context).to receive(:some_tool_solr_document_path).with(document, { only_path: true }).and_return('/asdf')
|
27
25
|
|
28
|
-
|
26
|
+
render_inline component
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'renders an action link' do
|
30
|
+
expect(page).to have_link 'Some tool', href: '/asdf'
|
31
|
+
end
|
29
32
|
end
|
30
33
|
|
31
34
|
context 'with a partial configured' do
|
32
35
|
let(:action) { Blacklight::Configuration::ToolConfig.new(name: '', partial: '/some/tool') }
|
33
36
|
|
34
|
-
|
37
|
+
before do
|
38
|
+
allow(view_context).to receive(:render).and_call_original
|
35
39
|
allow(view_context).to receive(:render).with(hash_including(partial: '/some/tool'), {}).and_return('tool')
|
36
40
|
|
37
|
-
|
41
|
+
render_inline component
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'render the partial' do
|
45
|
+
expect(page).to have_content 'tool'
|
38
46
|
end
|
39
47
|
end
|
40
48
|
end
|
@@ -6,40 +6,35 @@ RSpec.describe Blacklight::Document::GroupComponent, type: :component do
|
|
6
6
|
subject(:component) { described_class.new(group: group, **attr) }
|
7
7
|
|
8
8
|
let(:attr) { {} }
|
9
|
-
let(:view_context) {
|
10
|
-
let(:
|
11
|
-
component.render_in(view_context)
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:rendered) do
|
15
|
-
Capybara::Node::Simple.new(render)
|
16
|
-
end
|
17
|
-
|
18
|
-
let(:docs) { 10.times.map { double } }
|
9
|
+
let(:view_context) { vc_test_controller.view_context }
|
10
|
+
let(:docs) { 10.times.map { SolrDocument.new } }
|
19
11
|
|
20
12
|
let(:group) do
|
21
13
|
instance_double(Blacklight::Solr::Response::Group, key: 'group1', field: 'group_field', total: 15, docs: docs)
|
22
14
|
end
|
23
15
|
|
24
16
|
before do
|
17
|
+
# Every call to view_context returns a different object. This ensures it stays stable.
|
18
|
+
allow(vc_test_controller).to receive_messages(view_context: view_context)
|
25
19
|
allow(view_context).to receive(:render_document_index).with(docs).and_return('results')
|
20
|
+
render_inline component
|
26
21
|
end
|
27
22
|
|
28
23
|
it 'renders the group with a header' do
|
29
|
-
expect(
|
30
|
-
expect(
|
31
|
-
expect(
|
24
|
+
expect(page).to have_css 'div.group'
|
25
|
+
expect(page).to have_css 'h2', text: 'group1'
|
26
|
+
expect(page).to have_no_link 'more'
|
32
27
|
end
|
33
28
|
|
34
29
|
it 'renders the group documents' do
|
35
|
-
expect(
|
30
|
+
expect(page).to have_content 'results'
|
36
31
|
end
|
37
32
|
|
38
33
|
context 'with a limit applied' do
|
39
34
|
let(:attr) { { group_limit: 5 } }
|
40
35
|
|
41
36
|
it 'renders a control to see more results' do
|
42
|
-
expect(
|
37
|
+
expect(page).to have_link 'more'
|
43
38
|
end
|
44
39
|
end
|
45
40
|
end
|
@@ -7,14 +7,7 @@ RSpec.describe Blacklight::Document::PageHeaderComponent, type: :component do
|
|
7
7
|
|
8
8
|
let(:show_header_tools_component) { Class.new(Blacklight::Document::ShowToolsComponent) }
|
9
9
|
|
10
|
-
let(:view_context) {
|
11
|
-
let(:render) do
|
12
|
-
component.render_in(view_context)
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:rendered) do
|
16
|
-
Capybara::Node::Simple.new(render)
|
17
|
-
end
|
10
|
+
let(:view_context) { vc_test_controller.view_context }
|
18
11
|
|
19
12
|
let(:document) { SolrDocument.new(id: 'x', title_tsim: 'Title') }
|
20
13
|
|
@@ -25,16 +18,16 @@ RSpec.describe Blacklight::Document::PageHeaderComponent, type: :component do
|
|
25
18
|
# rubocop:disable RSpec/SubjectStub
|
26
19
|
before do
|
27
20
|
# Every call to view_context returns a different object. This ensures it stays stable.
|
28
|
-
allow(
|
29
|
-
allow(
|
30
|
-
|
31
|
-
allow(
|
21
|
+
allow(vc_test_controller).to receive_messages(view_context: view_context, blacklight_config: blacklight_config)
|
22
|
+
allow(vc_test_controller).to receive(:current_search_session).and_return(double(id: document.id))
|
23
|
+
vc_test_controller.class.helper_method :current_search_session
|
24
|
+
allow(vc_test_controller).to receive_messages(controller_name: 'catalog', link_to_previous_document: '', link_to_next_document: '')
|
32
25
|
allow(view_context).to receive_messages(search_context: search_context, search_session: current_search_session, current_search_session: current_search_session)
|
33
26
|
allow(component).to receive(:render).and_call_original
|
34
27
|
allow(component).to receive(:render).with(an_instance_of(show_header_tools_component)).and_return('tool component content')
|
35
28
|
replace_hash = { 'application/_start_over.html.erb' => 'Start Over' }
|
36
29
|
if Rails.version.to_f >= 7.1
|
37
|
-
|
30
|
+
vc_test_controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
38
31
|
else
|
39
32
|
view_context.view_paths.unshift(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
40
33
|
end
|
@@ -45,18 +38,25 @@ RSpec.describe Blacklight::Document::PageHeaderComponent, type: :component do
|
|
45
38
|
let(:search_context) { nil }
|
46
39
|
let(:current_search_session) { {} }
|
47
40
|
|
48
|
-
|
49
|
-
|
41
|
+
context 'with no header tools' do
|
42
|
+
before do
|
43
|
+
render_inline component
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'does not render' do
|
47
|
+
expect(page.native.inner_html).to be_blank
|
48
|
+
end
|
50
49
|
end
|
51
50
|
|
52
51
|
context 'has header tools' do
|
53
52
|
before do
|
54
53
|
blacklight_config.show.show_header_tools_component = show_header_tools_component
|
54
|
+
render_inline component
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'renders the tools' do
|
58
|
-
expect(
|
59
|
-
expect(
|
58
|
+
expect(page).to have_text 'tool component content'
|
59
|
+
expect(page).to have_css '.row'
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -67,25 +67,32 @@ RSpec.describe Blacklight::Document::PageHeaderComponent, type: :component do
|
|
67
67
|
let(:next_doc) { SolrDocument.new(id: '888') }
|
68
68
|
let(:current_search_session) { { query_params: { q: 'abc' }, 'id' => '123', 'document_id' => document.id } }
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
context 'with no header tools' do
|
71
|
+
before do
|
72
|
+
render_inline component
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'renders pagination' do
|
76
|
+
expect(page).to have_text 'Previous'
|
77
|
+
expect(page).to have_text 'Next'
|
78
|
+
expect(page).to have_text 'Start Over'
|
79
|
+
expect(page).to have_text 'Back to Search'
|
80
|
+
end
|
75
81
|
end
|
76
82
|
|
77
83
|
context 'has header tools' do
|
78
84
|
before do
|
79
85
|
blacklight_config.show.show_header_tools_component = show_header_tools_component
|
86
|
+
render_inline component
|
80
87
|
end
|
81
88
|
|
82
89
|
it 'renders the tools and pagination' do
|
83
|
-
expect(
|
84
|
-
expect(
|
85
|
-
expect(
|
86
|
-
expect(
|
87
|
-
expect(
|
88
|
-
expect(
|
90
|
+
expect(page).to have_text 'Previous'
|
91
|
+
expect(page).to have_text 'Next'
|
92
|
+
expect(page).to have_text 'Start Over'
|
93
|
+
expect(page).to have_text 'Back to Search'
|
94
|
+
expect(page).to have_text 'tool component content'
|
95
|
+
expect(page).to have_css '.row'
|
89
96
|
end
|
90
97
|
end
|
91
98
|
end
|
@@ -5,14 +5,7 @@ require 'spec_helper'
|
|
5
5
|
RSpec.describe Blacklight::Document::SidebarComponent, type: :component do
|
6
6
|
subject(:component) { described_class.new(presenter: document) }
|
7
7
|
|
8
|
-
let(:view_context) {
|
9
|
-
let(:render) do
|
10
|
-
component.render_in(view_context)
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:rendered) do
|
14
|
-
Capybara::Node::Simple.new(render)
|
15
|
-
end
|
8
|
+
let(:view_context) { vc_test_controller.view_context }
|
16
9
|
|
17
10
|
let(:document) { view_context.document_presenter(presented_document) }
|
18
11
|
|
@@ -26,7 +19,7 @@ RSpec.describe Blacklight::Document::SidebarComponent, type: :component do
|
|
26
19
|
|
27
20
|
before do
|
28
21
|
# Every call to view_context returns a different object. This ensures it stays stable.
|
29
|
-
allow(
|
22
|
+
allow(vc_test_controller).to receive_messages(view_context: view_context, blacklight_config: blacklight_config)
|
30
23
|
end
|
31
24
|
|
32
25
|
describe '#render_show_tools' do
|
@@ -35,13 +28,14 @@ RSpec.describe Blacklight::Document::SidebarComponent, type: :component do
|
|
35
28
|
allow(component).to receive(:render).with(an_instance_of(Blacklight::Document::MoreLikeThisComponent)).and_return("")
|
36
29
|
blacklight_config.show.show_tools_component = show_tools_component
|
37
30
|
allow(component).to receive(:render).with(an_instance_of(show_tools_component)).and_return(expected_html)
|
31
|
+
render_inline component
|
38
32
|
end
|
33
|
+
# rubocop:enable RSpec/SubjectStub
|
39
34
|
|
40
35
|
let(:show_tools_component) { Class.new(Blacklight::Document::ShowToolsComponent) }
|
41
36
|
|
42
37
|
it 'renders configured show_tools component' do
|
43
|
-
expect(
|
38
|
+
expect(page).to have_css 'div[@class="expected-show_tools"]'
|
44
39
|
end
|
45
|
-
# rubocop:enable RSpec/SubjectStub
|
46
40
|
end
|
47
41
|
end
|