blacklight 8.2.2 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.github/workflows/ruby.yml +60 -62
  4. data/.rubocop.yml +229 -21
  5. data/.rubocop_todo.yml +22 -55
  6. data/Gemfile +2 -10
  7. data/README.md +2 -2
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.esm.js +5 -1
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  11. data/app/assets/javascripts/blacklight/blacklight.js +5 -1
  12. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  13. data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
  14. data/app/assets/stylesheets/blacklight/_bookmark.scss +30 -0
  15. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -4
  16. data/app/assets/stylesheets/blacklight/_constraints.scss +15 -9
  17. data/app/assets/stylesheets/blacklight/_controls.scss +0 -1
  18. data/app/assets/stylesheets/blacklight/_facets.scss +33 -37
  19. data/app/assets/stylesheets/blacklight/_header.scss +2 -35
  20. data/app/assets/stylesheets/blacklight/_icons.scss +3 -2
  21. data/app/assets/stylesheets/blacklight/_layout.scss +3 -0
  22. data/app/assets/stylesheets/blacklight/_mixins.scss +6 -21
  23. data/app/assets/stylesheets/blacklight/_search_form.scss +3 -8
  24. data/app/assets/stylesheets/blacklight/_search_history.scss +5 -5
  25. data/app/assets/stylesheets/blacklight/_search_results.scss +5 -2
  26. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +16 -10
  27. data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
  28. data/app/components/blacklight/advanced_search_form_component.rb +6 -0
  29. data/app/components/blacklight/constraint_layout_component.html.erb +2 -9
  30. data/app/components/blacklight/constraint_layout_component.rb +8 -0
  31. data/app/components/blacklight/constraints_component.rb +3 -3
  32. data/app/components/blacklight/document/action_component.rb +2 -1
  33. data/app/components/blacklight/document/bookmark_component.html.erb +2 -1
  34. data/app/components/blacklight/document/bookmark_component.rb +6 -0
  35. data/app/components/blacklight/document/page_header_component.html.erb +7 -0
  36. data/app/components/blacklight/document/page_header_component.rb +85 -0
  37. data/app/components/blacklight/document_component.rb +1 -1
  38. data/app/components/blacklight/facet_component.rb +1 -1
  39. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +1 -1
  40. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  41. data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +1 -1
  42. data/app/components/blacklight/facet_field_list_component.html.erb +1 -1
  43. data/app/components/blacklight/facet_item_component.rb +1 -1
  44. data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
  45. data/app/components/blacklight/icons/bookmark_icon_component.rb +17 -0
  46. data/app/components/blacklight/icons/icon_component.rb +9 -4
  47. data/app/components/blacklight/icons/remove_component.rb +16 -0
  48. data/app/components/blacklight/metadata_field_component.html.erb +1 -1
  49. data/app/components/blacklight/metadata_field_component.rb +5 -0
  50. data/app/components/blacklight/response/facet_group_component.rb +1 -1
  51. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  52. data/app/components/blacklight/response/sort_component.html.erb +1 -6
  53. data/app/components/blacklight/response/sort_component.rb +15 -0
  54. data/app/components/blacklight/search/per_page_component.html.erb +2 -0
  55. data/app/components/blacklight/search/per_page_component.rb +50 -0
  56. data/app/components/blacklight/search_bar_component.html.erb +1 -1
  57. data/app/components/blacklight/search_context/server_item_pagination_component.html.erb +4 -7
  58. data/app/components/blacklight/skip_link_component.html.erb +7 -0
  59. data/app/components/blacklight/skip_link_component.rb +17 -0
  60. data/app/components/blacklight/system/dropdown_button_component.rb +18 -0
  61. data/app/components/blacklight/system/dropdown_component.rb +4 -7
  62. data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
  63. data/app/components/blacklight/top_navbar_component.html.erb +2 -2
  64. data/app/components/blacklight/top_navbar_component.rb +4 -0
  65. data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -5
  66. data/app/helpers/blacklight/component_helper_behavior.rb +4 -4
  67. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -0
  68. data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
  69. data/app/javascript/blacklight/checkbox_submit.js +5 -1
  70. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -1
  71. data/app/presenters/blacklight/facet_checkbox_item_presenter.rb +11 -0
  72. data/app/presenters/blacklight/facet_field_presenter.rb +9 -1
  73. data/app/services/blacklight/search_service.rb +9 -1
  74. data/app/views/catalog/_per_page_widget.html.erb +1 -10
  75. data/app/views/catalog/_search_results.html.erb +1 -1
  76. data/app/views/catalog/_show_main_content.html.erb +1 -1
  77. data/app/views/catalog/show.html.erb +0 -2
  78. data/app/views/catalog/suggest.html.erb +1 -1
  79. data/app/views/kaminari/blacklight/_page.html.erb +14 -8
  80. data/app/views/layouts/blacklight/base.html.erb +3 -4
  81. data/app/views/shared/_flash_messages.html.erb +1 -1
  82. data/blacklight.gemspec +4 -0
  83. data/{docker-compose.yml → compose.yaml} +1 -1
  84. data/config/locales/blacklight.ar.yml +3 -0
  85. data/config/locales/blacklight.de.yml +3 -0
  86. data/config/locales/blacklight.en.yml +216 -229
  87. data/config/locales/blacklight.es.yml +3 -0
  88. data/config/locales/blacklight.fr.yml +3 -0
  89. data/config/locales/blacklight.hu.yml +3 -0
  90. data/config/locales/blacklight.it.yml +3 -0
  91. data/config/locales/blacklight.nl.yml +3 -0
  92. data/config/locales/blacklight.pt-BR.yml +3 -0
  93. data/config/locales/blacklight.sq.yml +3 -0
  94. data/config/locales/blacklight.zh.yml +3 -0
  95. data/lib/blacklight/abstract_repository.rb +6 -0
  96. data/lib/blacklight/configuration.rb +33 -19
  97. data/lib/blacklight/nested_open_struct_with_hash_access.rb +2 -2
  98. data/lib/blacklight/parameters.rb +1 -1
  99. data/lib/blacklight/solr/repository.rb +11 -4
  100. data/lib/blacklight/solr/request.rb +1 -1
  101. data/lib/blacklight/solr/response/facets.rb +1 -1
  102. data/lib/blacklight/solr/response/params.rb +1 -1
  103. data/lib/blacklight/solr/response.rb +0 -12
  104. data/lib/blacklight/solr/search_builder_behavior.rb +2 -2
  105. data/lib/blacklight/solr.rb +0 -6
  106. data/lib/blacklight.rb +4 -14
  107. data/lib/generators/blacklight/assets/propshaft_generator.rb +2 -2
  108. data/lib/generators/blacklight/models_generator.rb +1 -1
  109. data/package.json +1 -1
  110. data/spec/components/blacklight/advanced_search_form_component_spec.rb +2 -2
  111. data/spec/components/blacklight/constraint_layout_component_spec.rb +11 -11
  112. data/spec/components/blacklight/constraints_component_spec.rb +9 -9
  113. data/spec/components/blacklight/document/action_component_spec.rb +1 -1
  114. data/spec/components/blacklight/document/group_component_spec.rb +3 -3
  115. data/spec/components/blacklight/document/page_header_component_spec.rb +92 -0
  116. data/spec/components/blacklight/document/sidebar_component_spec.rb +3 -4
  117. data/spec/components/blacklight/document_component_spec.rb +41 -25
  118. data/spec/components/blacklight/facet_component_spec.rb +2 -2
  119. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +5 -5
  120. data/spec/components/blacklight/facet_field_list_component_spec.rb +13 -13
  121. data/spec/components/blacklight/facet_item_component_spec.rb +5 -5
  122. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +6 -6
  123. data/spec/components/blacklight/header_component_spec.rb +1 -2
  124. data/spec/components/blacklight/hidden_search_state_component_spec.rb +6 -6
  125. data/spec/components/blacklight/icons/icon_component_spec.rb +42 -0
  126. data/spec/components/blacklight/metadata_field_component_spec.rb +3 -3
  127. data/spec/components/blacklight/response/pagination_component_spec.rb +4 -4
  128. data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +1 -1
  129. data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +2 -4
  130. data/spec/components/blacklight/system/flash_message_component_spec.rb +5 -5
  131. data/spec/controllers/blacklight/catalog_spec.rb +2 -2
  132. data/spec/controllers/blacklight/{catalog/component_configuration_spec.rb → configurable_spec.rb} +1 -1
  133. data/spec/controllers/bookmarks_controller_spec.rb +10 -10
  134. data/spec/controllers/catalog_controller_spec.rb +29 -31
  135. data/spec/features/advanced_search_spec.rb +30 -16
  136. data/spec/features/alternate_controller_spec.rb +9 -9
  137. data/spec/features/axe_spec.rb +4 -4
  138. data/spec/features/bookmarks_spec.rb +34 -19
  139. data/spec/features/citation_spec.rb +1 -1
  140. data/spec/features/did_you_mean_spec.rb +23 -23
  141. data/spec/features/facet_missing_spec.rb +9 -9
  142. data/spec/features/facets_spec.rb +21 -20
  143. data/spec/features/modal_spec.rb +4 -4
  144. data/spec/features/record_view_spec.rb +2 -2
  145. data/spec/features/search_context_spec.rb +6 -6
  146. data/spec/features/search_crawler_spec.rb +5 -5
  147. data/spec/features/search_filters_spec.rb +65 -65
  148. data/spec/features/search_history_spec.rb +12 -12
  149. data/spec/features/search_pagination_spec.rb +10 -10
  150. data/spec/features/search_results_spec.rb +1 -1
  151. data/spec/features/search_sort_spec.rb +4 -4
  152. data/spec/features/search_spec.rb +25 -25
  153. data/spec/features/sitelinks_search_box_spec.rb +2 -2
  154. data/spec/features/sms_spec.rb +1 -1
  155. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +2 -2
  156. data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +20 -3
  157. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +2 -1
  158. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -8
  159. data/spec/helpers/blacklight_helper_spec.rb +13 -15
  160. data/spec/helpers/catalog_helper_spec.rb +3 -6
  161. data/spec/i18n_spec.rb +2 -1
  162. data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +1 -1
  163. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +1 -1
  164. data/spec/lib/blacklight/search_state_spec.rb +4 -4
  165. data/spec/lib/tasks/blacklight_task_spec.rb +2 -1
  166. data/spec/models/blacklight/configurable_spec.rb +1 -1
  167. data/spec/models/blacklight/configuration/context_spec.rb +1 -1
  168. data/spec/models/blacklight/configuration_spec.rb +14 -14
  169. data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -1
  170. data/spec/models/blacklight/document/cache_key_spec.rb +1 -1
  171. data/spec/models/blacklight/document_spec.rb +1 -1
  172. data/spec/models/blacklight/facet_paginator_spec.rb +14 -14
  173. data/spec/models/blacklight/icon_spec.rb +1 -1
  174. data/spec/models/blacklight/search_builder_spec.rb +1 -1
  175. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  176. data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -1
  177. data/spec/models/blacklight/solr/repository_spec.rb +33 -15
  178. data/spec/models/blacklight/solr/request_spec.rb +1 -1
  179. data/spec/models/blacklight/solr/response/facets_spec.rb +3 -3
  180. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
  181. data/spec/models/blacklight/solr/response/group_spec.rb +2 -2
  182. data/spec/models/blacklight/solr/response_spec.rb +3 -3
  183. data/spec/models/blacklight/solr/{search_builder_spec.rb → search_builder_behavior_spec.rb} +10 -20
  184. data/spec/models/blacklight/suggest/response_spec.rb +1 -1
  185. data/spec/models/blacklight/suggest_search_spec.rb +1 -1
  186. data/spec/models/blacklight/user_spec.rb +1 -1
  187. data/spec/models/bookmark_spec.rb +1 -1
  188. data/spec/models/solr_document_spec.rb +1 -1
  189. data/spec/presenters/blacklight/document_presenter_spec.rb +3 -4
  190. data/spec/presenters/blacklight/facet_checkbox_item_presenter_spec.rb +42 -0
  191. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +14 -0
  192. data/spec/presenters/blacklight/field_presenter_spec.rb +1 -1
  193. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -3
  194. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -1
  195. data/spec/presenters/{pipeline_spec.rb → blacklight/rendering/pipeline_spec.rb} +1 -1
  196. data/spec/presenters/blacklight/show_presenter_spec.rb +5 -6
  197. data/spec/presenters/{thumbnail_presenter_spec.rb → blacklight/thumbnail_presenter_spec.rb} +5 -3
  198. data/spec/requests/load_suggestions_spec.rb +5 -5
  199. data/spec/routing/catalog_routing_spec.rb +1 -1
  200. data/spec/services/blacklight/field_retriever_spec.rb +1 -1
  201. data/spec/services/blacklight/search_service_spec.rb +11 -11
  202. data/spec/spec_helper.rb +2 -2
  203. data/spec/support/features/search_helpers.rb +2 -2
  204. data/spec/support/features/session_helpers.rb +3 -3
  205. data/spec/test_app_templates/lib/generators/test_app_generator.rb +3 -3
  206. data/spec/views/catalog/_document.html.erb_spec.rb +1 -4
  207. data/spec/views/catalog/_document_list.html.erb_spec.rb +2 -2
  208. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +5 -6
  209. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +7 -7
  210. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +4 -4
  211. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -4
  212. data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -2
  213. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -7
  214. data/spec/views/catalog/email_success.html.erb_spec.rb +1 -1
  215. data/spec/views/catalog/facet.html.erb_spec.rb +1 -1
  216. data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -1
  217. data/spec/views/catalog/index.atom.builder_spec.rb +18 -19
  218. data/spec/views/catalog/index.html.erb_spec.rb +2 -4
  219. data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -8
  220. data/spec/views/catalog/show.html.erb_spec.rb +3 -5
  221. data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -2
  222. data/spec/views/catalog/sms_success.html.erb_spec.rb +1 -1
  223. data/spec/views/shared/_user_util_links.html.erb_spec.rb +2 -3
  224. data/tasks/blacklight.rake +5 -5
  225. metadata +84 -12
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe CatalogController, api: true do
3
+ RSpec.describe CatalogController, :api do
4
4
  let(:doc_id) { '2007020969' }
5
5
  let(:mock_document) { instance_double(SolrDocument, export_formats: {}) }
6
6
  let(:search_service) { instance_double(Blacklight::SearchService) }
@@ -24,26 +24,26 @@ RSpec.describe CatalogController, api: true do
24
24
  end
25
25
 
26
26
  # check each user manipulated parameter
27
- it "has docs and facets for query with results", integration: true do
27
+ it "has docs and facets for query with results", :integration do
28
28
  get :index, params: { q: user_query }
29
29
  expect(assigns(:response).docs).not_to be_empty
30
30
  assert_facets_have_values(assigns(:response).aggregations)
31
31
  end
32
32
 
33
- it "has docs and facets for existing facet value", integration: true do
33
+ it "has docs and facets for existing facet value", :integration do
34
34
  get :index, params: { f: { "format" => 'Book' } }
35
35
  expect(assigns(:response).docs).not_to be_empty
36
36
  assert_facets_have_values(assigns(:response).aggregations)
37
37
  end
38
38
 
39
- it "has docs and facets for non-default results per page", integration: true do
39
+ it "has docs and facets for non-default results per page", :integration do
40
40
  num_per_page = 7
41
41
  get :index, params: { per_page: num_per_page }
42
42
  expect(assigns(:response).docs).to have(num_per_page).items
43
43
  assert_facets_have_values(assigns(:response).aggregations)
44
44
  end
45
45
 
46
- it "has docs and facets for second page", integration: true do
46
+ it "has docs and facets for second page", :integration do
47
47
  page = 2
48
48
  get :index, params: { page: page }
49
49
  expect(assigns(:response).docs).not_to be_empty
@@ -51,7 +51,7 @@ RSpec.describe CatalogController, api: true do
51
51
  assert_facets_have_values(assigns(:response).aggregations)
52
52
  end
53
53
 
54
- it "has no docs or facet values for query without results", integration: true do
54
+ it "has no docs or facet values for query without results", :integration do
55
55
  get :index, params: { q: 'sadfdsafasdfsadfsadfsadf' } # query for no results
56
56
  expect(assigns(:response).docs).to be_empty
57
57
  assigns(:response).aggregations.each_value do |facet|
@@ -59,12 +59,12 @@ RSpec.describe CatalogController, api: true do
59
59
  end
60
60
  end
61
61
 
62
- it "shows 0 results when the user asks for an invalid value to a custom facet query", integration: true do
62
+ it "shows 0 results when the user asks for an invalid value to a custom facet query", :integration do
63
63
  get :index, params: { f: { example_query_facet_field: ['bogus'] } } # bogus custom facet value
64
64
  expect(assigns(:response).docs).to be_empty
65
65
  end
66
66
 
67
- it "returns results (possibly 0) when the user asks for a valid value to a custom facet query", integration: true do
67
+ it "returns results (possibly 0) when the user asks for a valid value to a custom facet query", :integration do
68
68
  get :index, params: { f: { example_query_facet_field: ['years_25'] } } # valid custom facet value with some results
69
69
  expect(assigns(:response).docs).not_to be_empty
70
70
  end
@@ -74,7 +74,7 @@ RSpec.describe CatalogController, api: true do
74
74
  expect(assigns(:response).docs).to be_empty
75
75
  end
76
76
 
77
- it "has a spelling suggestion for an appropriately poor query", integration: true do
77
+ it "has a spelling suggestion for an appropriately poor query", :integration do
78
78
  get :index, params: { q: 'boo' }
79
79
  expect(assigns(:response).spelling.words).not_to be_nil
80
80
  end
@@ -95,12 +95,12 @@ RSpec.describe CatalogController, api: true do
95
95
 
96
96
  # check with no user manipulation
97
97
  describe "for default query" do
98
- it "gets documents when no query", integration: true do
98
+ it "gets documents when no query", :integration do
99
99
  get :index
100
100
  expect(assigns(:response).docs).not_to be_empty
101
101
  end
102
102
 
103
- it "gets facets when no query", integration: true do
103
+ it "gets facets when no query", :integration do
104
104
  get :index
105
105
  assert_facets_have_values(assigns(:response).aggregations)
106
106
  end
@@ -113,14 +113,14 @@ RSpec.describe CatalogController, api: true do
113
113
  end
114
114
 
115
115
  # NOTE: status code is always 200 in isolation mode ...
116
- it "HTTP status code for GET should be 200", integration: true do
116
+ it "HTTP status code for GET should be 200", :integration do
117
117
  get :index
118
118
  expect(response).to be_successful
119
119
  end
120
120
  end
121
121
 
122
122
  describe "with format :rss" do
123
- it "gets the feed", integration: true do
123
+ it "gets the feed", :integration do
124
124
  get :index, params: { format: 'rss' }
125
125
  expect(response).to be_successful
126
126
  end
@@ -133,7 +133,7 @@ RSpec.describe CatalogController, api: true do
133
133
  expect(response).to be_successful
134
134
  end
135
135
 
136
- let(:json) { JSON.parse(response.body) }
136
+ let(:json) { response.parsed_body }
137
137
  let(:pages) { json['meta']['pages'] }
138
138
  let(:docs) { json['data'] }
139
139
  let(:facets) { json['included'].select { |x| x['type'] == 'facet' } }
@@ -251,7 +251,7 @@ RSpec.describe CatalogController, api: true do
251
251
 
252
252
  it "HTTP status code for redirect should be 303" do
253
253
  put :track, params: { id: doc_id, counter: 3 }
254
- expect(response.status).to eq 303
254
+ expect(response).to have_http_status :see_other
255
255
  end
256
256
 
257
257
  it "redirects to the path given in the redirect param" do
@@ -285,7 +285,7 @@ RSpec.describe CatalogController, api: true do
285
285
  it "gets the raw solr document" do
286
286
  get :raw, params: { id: doc_id, format: 'json' }
287
287
  expect(response).to be_successful
288
- json = JSON.parse response.body
288
+ json = response.parsed_body
289
289
  expect(json.keys).to match_array(
290
290
  %w[id _version_ author_addl_tsim author_tsim format isbn_ssim
291
291
  language_ssim lc_1letter_ssim lc_alpha_ssim lc_b4cutter_ssim
@@ -310,7 +310,7 @@ RSpec.describe CatalogController, api: true do
310
310
  # SHOW ACTION
311
311
  describe "show action" do
312
312
  describe "with format :html" do
313
- it "gets document", integration: true do
313
+ it "gets document", :integration do
314
314
  get :show, params: { id: doc_id }
315
315
  expect(assigns[:document]).not_to be_nil
316
316
  end
@@ -321,7 +321,7 @@ RSpec.describe CatalogController, api: true do
321
321
  it "gets the feed" do
322
322
  get :show, params: { id: doc_id, format: 'json' }
323
323
  expect(response).to be_successful
324
- json = JSON.parse response.body
324
+ json = response.parsed_body
325
325
  expect(json["data"]["attributes"].keys).to match_array(
326
326
  %w[author_tsim format isbn_ssim language_ssim lc_callnum_ssim
327
327
  published_ssim subtitle_tsim title title_tsim url_suppl_ssim]
@@ -335,9 +335,8 @@ RSpec.describe CatalogController, api: true do
335
335
 
336
336
  before do
337
337
  allow(mock_document).to receive_messages(export_formats: {})
338
- allow(controller).to receive(:search_service).and_return(search_service)
339
338
  expect(search_service).to receive(:fetch).and_return(mock_document)
340
- allow(controller).to receive(:current_search_session).and_return(current_search)
339
+ allow(controller).to receive_messages(search_service: search_service, current_search_session: current_search)
341
340
  end
342
341
 
343
342
  context 'if counter is present in session' do
@@ -389,7 +388,7 @@ RSpec.describe CatalogController, api: true do
389
388
  end
390
389
 
391
390
  # NOTE: status code is always 200 in isolation mode ...
392
- it "HTTP status code for GET should be 200", integration: true do
391
+ it "HTTP status code for GET should be 200", :integration do
393
392
  get :show, params: { id: doc_id }
394
393
  expect(response).to be_successful
395
394
  end
@@ -612,10 +611,10 @@ RSpec.describe CatalogController, api: true do
612
611
  it "is successful" do
613
612
  get :facet, params: { id: 'format' }
614
613
  expect(response).to be_successful
615
- expect(assigns[:response]).to be_kind_of Blacklight::Solr::Response
616
- expect(assigns[:facet]).to be_kind_of Blacklight::Configuration::FacetField
617
- expect(assigns[:display_facet]).to be_kind_of Blacklight::Solr::Response::Facets::FacetField
618
- expect(assigns[:pagination]).to be_kind_of Blacklight::Solr::FacetPaginator
614
+ expect(assigns[:response]).to be_a Blacklight::Solr::Response
615
+ expect(assigns[:facet]).to be_a Blacklight::Configuration::FacetField
616
+ expect(assigns[:display_facet]).to be_a Blacklight::Solr::Response::Facets::FacetField
617
+ expect(assigns[:pagination]).to be_a Blacklight::Solr::FacetPaginator
619
618
  end
620
619
  end
621
620
 
@@ -624,7 +623,7 @@ RSpec.describe CatalogController, api: true do
624
623
  it "is successful" do
625
624
  get :facet, params: { id: 'format', format: 'json' }
626
625
  expect(response).to be_successful
627
- json = JSON.parse(response.body)
626
+ json = response.parsed_body
628
627
  expect(json["response"]["facets"]["items"].first["value"]).to eq 'Book'
629
628
  end
630
629
  end
@@ -639,7 +638,7 @@ RSpec.describe CatalogController, api: true do
639
638
 
640
639
  expect(response).to be_successful
641
640
 
642
- expect(assigns[:facet]).to be_kind_of Blacklight::Configuration::FacetField
641
+ expect(assigns[:facet]).to be_a Blacklight::Configuration::FacetField
643
642
  expect(assigns[:facet].key).to eq 'params_key'
644
643
  expect(assigns[:facet].field).to eq 'format'
645
644
 
@@ -741,8 +740,7 @@ RSpec.describe CatalogController, api: true do
741
740
  describe "#add_show_tools_partial", api: false do
742
741
  before do
743
742
  described_class.blacklight_config.add_show_tools_partial(:like, callback: :perform_like, validator: :validate_like_params)
744
- allow(controller).to receive(:solr_document_url).and_return('http://test.host/catalog/1')
745
- allow(controller).to receive(:action_documents).and_return(1)
743
+ allow(controller).to receive_messages(solr_document_url: 'http://test.host/catalog/1', action_documents: 1)
746
744
  Rails.application.routes.draw do
747
745
  get 'catalog/like', as: :catalog_like
748
746
  end
@@ -796,7 +794,7 @@ RSpec.describe CatalogController, api: true do
796
794
  end
797
795
 
798
796
  describe "page_links" do
799
- it "has prev/next docs and result set data for non-empty result sets", integration: true do
797
+ it "has prev/next docs and result set data for non-empty result sets", :integration do
800
798
  get :page_links, params: { f: { "format" => 'Book' }, counter: 2 }
801
799
  expect(assigns(:page_link_data)).not_to be_empty
802
800
  expect(assigns(:page_link_data).fetch(:prev, nil)).to end_with('counter=1')
@@ -804,7 +802,7 @@ RSpec.describe CatalogController, api: true do
804
802
  expect(assigns(:page_link_data).fetch(:totalRaw, nil)).to be 30
805
803
  end
806
804
 
807
- it "is empty for empty result sets", integration: true do
805
+ it "is empty for empty result sets", :integration do
808
806
  get :page_links, params: { f: { "format" => 'empty-result-set' }, counter: 1 }
809
807
  expect(assigns(:page_link_data)).to be_empty
810
808
  end
@@ -27,16 +27,16 @@ RSpec.describe "Blacklight Advanced Search Form" do
27
27
  end
28
28
 
29
29
  it "has field and facet blocks" do
30
- expect(page).to have_selector('.query-criteria')
31
- expect(page).to have_selector('.limit-criteria')
30
+ expect(page).to have_css('.query-criteria')
31
+ expect(page).to have_css('.limit-criteria')
32
32
  end
33
33
 
34
34
  describe "query column" do
35
35
  it "gives the user a choice between and/or queries" do
36
- expect(page).to have_selector('#op')
36
+ expect(page).to have_css('#op')
37
37
  within('#op') do
38
- expect(page).to have_selector('option[value="must"]')
39
- expect(page).to have_selector('option[value="should"]')
38
+ expect(page).to have_css('option[value="must"]')
39
+ expect(page).to have_css('option[value="should"]')
40
40
  end
41
41
  end
42
42
 
@@ -50,7 +50,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
50
50
 
51
51
  describe "facet column" do
52
52
  it "lists facets" do
53
- expect(page).to have_selector('.blacklight-language_ssim')
53
+ expect(page).to have_css('.blacklight-language_ssim')
54
54
 
55
55
  within('.blacklight-language_ssim') do
56
56
  expect(page).to have_content 'Language'
@@ -63,7 +63,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
63
63
  click_on 'advanced-search-submit'
64
64
  expect(page).to have_content 'Remove constraint Title: Medicine'
65
65
  expect(page).to have_content 'Strong Medicine speaks'
66
- expect(page).to have_selector('article.document', count: 1)
66
+ expect(page).to have_css('article.document', count: 1)
67
67
  end
68
68
 
69
69
  it 'can limit to facets' do
@@ -72,16 +72,16 @@ RSpec.describe "Blacklight Advanced Search Form" do
72
72
  check 'Urdu 3'
73
73
  click_on 'advanced-search-submit'
74
74
  expect(page).to have_content 'Pākistānī ʻaurat dorāhe par'
75
- expect(page).not_to have_content 'Ajikto kŭrŏk chŏrŏk sasimnikka : and 아직도 그럭 저럭 사십니까'
76
- expect(page).to have_selector('article.document', count: 1)
75
+ expect(page).to have_no_content 'Ajikto kŭrŏk chŏrŏk sasimnikka : and 아직도 그럭 저럭 사십니까'
76
+ expect(page).to have_css('article.document', count: 1)
77
77
  end
78
78
 
79
79
  it 'handles boolean queries' do
80
80
  fill_in 'All Fields', with: 'history NOT strong'
81
81
  click_on 'advanced-search-submit'
82
82
  expect(page).to have_content('Ci an zhou bian')
83
- expect(page).not_to have_content('Strong Medicine speaks')
84
- expect(page).to have_selector('article.document', count: 10)
83
+ expect(page).to have_no_content('Strong Medicine speaks')
84
+ expect(page).to have_css('article.document', count: 10)
85
85
  end
86
86
 
87
87
  it 'handles queries in multiple fields with the ALL operator' do
@@ -89,7 +89,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
89
89
  fill_in 'Author', with: 'hearth'
90
90
  click_on 'advanced-search-submit'
91
91
  expect(page).to have_content('Strong Medicine speaks')
92
- expect(page).to have_selector('article.document', count: 1)
92
+ expect(page).to have_css('article.document', count: 1)
93
93
  end
94
94
 
95
95
  it 'handles queries in multiple fields with the ANY operator' do
@@ -99,17 +99,29 @@ RSpec.describe "Blacklight Advanced Search Form" do
99
99
  click_on 'advanced-search-submit'
100
100
  expect(page).to have_content('Ci an zhou bian')
101
101
  expect(page).to have_content('Pākistānī ʻaurat dorāhe par')
102
- expect(page).to have_selector('article.document', count: 10)
102
+ expect(page).to have_css('article.document', count: 10)
103
103
  end
104
104
  end
105
105
 
106
106
  describe "prepopulated advanced search form" do
107
107
  before do
108
- visit '/catalog/advanced?op=must&clause[0][field]=title&clause[0]query=medicine'
108
+ visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&sort=author'
109
109
  end
110
110
 
111
- it "does not create hidden inputs for search fields" do
111
+ it 'prepopulates the expected fields' do
112
112
  expect(page).to have_field 'Title', with: 'medicine'
113
+ expect(page).to have_field 'Tibetan', checked: true
114
+ expect(page).to have_select 'op', selected: 'all'
115
+ expect(page).to have_select 'sort', selected: 'author'
116
+ end
117
+
118
+ it "does not create hidden inputs for fields included in adv search form" do
119
+ within('form.advanced') do
120
+ expect(page).to have_no_field('clause[1][query]', type: :hidden, with: 'medicine')
121
+ expect(page).to have_no_field('f_inclusive[language_ssim][]', type: :hidden, with: 'Tibetan')
122
+ expect(page).to have_no_field('op', type: :hidden, with: 'must')
123
+ expect(page).to have_no_field('sort', type: :hidden, with: 'author')
124
+ end
113
125
  end
114
126
 
115
127
  it "does not have multiple parameters for a search field" do
@@ -121,8 +133,10 @@ RSpec.describe "Blacklight Advanced Search Form" do
121
133
 
122
134
  it "clears the prepopulated fields when the Start Over button is pressed" do
123
135
  expect(page).to have_field 'Title', with: 'medicine'
136
+ expect(page).to have_field 'Tibetan', checked: true
124
137
  click_on 'Start over'
125
- expect(page).not_to have_field 'Title', with: 'medicine'
138
+ expect(page).to have_no_field 'Title', with: 'medicine'
139
+ expect(page).to have_no_field 'Tibetan', checked: true
126
140
  end
127
141
  end
128
142
  end
@@ -3,9 +3,9 @@
3
3
  RSpec.describe "Alternate Controller Behaviors" do
4
4
  it "has the correct per-page form" do
5
5
  visit search_alternate_path
6
- expect(page).to have_selector("form[action='#{search_alternate_url}']")
6
+ expect(page).to have_css("form[action='#{search_alternate_url}']")
7
7
  fill_in "q", with: "history"
8
- click_button 'search'
8
+ click_on 'search'
9
9
  expect(current_path).to match /#{search_alternate_path}/
10
10
  within "#per_page-dropdown .dropdown-menu" do
11
11
  click_on '10 per page'
@@ -15,9 +15,9 @@ RSpec.describe "Alternate Controller Behaviors" do
15
15
 
16
16
  it "has the correct search field form" do
17
17
  visit search_alternate_path
18
- expect(page).to have_selector("form[action='#{search_alternate_url}']")
18
+ expect(page).to have_css("form[action='#{search_alternate_url}']")
19
19
  fill_in "q", with: "history"
20
- click_button 'search'
20
+ click_on 'search'
21
21
  expect(current_path).to match /#{search_alternate_path}/
22
22
  click_on 'relevance'
23
23
  expect(current_path).to match /#{search_alternate_path}/
@@ -25,11 +25,11 @@ RSpec.describe "Alternate Controller Behaviors" do
25
25
 
26
26
  it "displays document thumbnails" do
27
27
  visit search_alternate_path
28
- expect(page).to have_selector("form[action='#{search_alternate_url}']")
28
+ expect(page).to have_css("form[action='#{search_alternate_url}']")
29
29
  fill_in "q", with: "history"
30
- click_button 'search'
31
- expect(page).to have_selector ".document-thumbnail"
32
- expect(page).to have_selector ".document-thumbnail a[data-context-href]"
33
- expect(page).to have_selector ".document-thumbnail a img"
30
+ click_on 'search'
31
+ expect(page).to have_css ".document-thumbnail"
32
+ expect(page).to have_css ".document-thumbnail a[data-context-href]"
33
+ expect(page).to have_css ".document-thumbnail a img"
34
34
  end
35
35
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe 'Accessibility testing', api: false, js: true do
3
+ RSpec.describe 'Accessibility testing', :js, api: false do
4
4
  it 'validates the home page' do
5
5
  visit root_path
6
6
  expect(page).to be_accessible
@@ -9,13 +9,13 @@ RSpec.describe 'Accessibility testing', api: false, js: true do
9
9
  it 'validates the catalog page' do
10
10
  visit root_path
11
11
  fill_in "q", with: 'history'
12
- click_button 'search'
12
+ click_on 'search'
13
13
 
14
14
  expect(page).to be_accessible
15
15
 
16
16
  within '.card.blacklight-language_ssim' do
17
- click_button 'Language'
18
- click_link "Tibetan"
17
+ click_on 'Language'
18
+ click_on "Tibetan"
19
19
  end
20
20
 
21
21
  expect(page).to be_accessible
@@ -5,16 +5,16 @@ RSpec.describe "Bookmarks" do
5
5
  it "has a link to the history page" do
6
6
  sign_in 'user1'
7
7
  visit root_path
8
- click_link 'Bookmarks'
8
+ click_on 'Bookmarks'
9
9
  expect(page).to have_content 'You have no bookmarks'
10
10
  end
11
11
  end
12
12
 
13
13
  it "clears bookmarks" do
14
14
  visit solr_document_path('2007020969')
15
- click_button 'Bookmark'
16
- click_link 'Bookmarks'
17
- click_link 'Clear Bookmarks'
15
+ click_on 'Bookmark'
16
+ click_on 'Bookmarks'
17
+ click_on 'Clear Bookmarks'
18
18
  expect(page).to have_content 'Cleared your bookmarks.'
19
19
  expect(page).to have_content 'You have no bookmarks'
20
20
  end
@@ -23,24 +23,24 @@ RSpec.describe "Bookmarks" do
23
23
  sign_in 'user1'
24
24
  visit root_path
25
25
  fill_in "q", with: 'Sumadhvavijayaḥ'
26
- click_button 'search'
27
- click_button 'Bookmark'
26
+ click_on 'search'
27
+ click_on 'Bookmark'
28
28
  expect(page).to have_content 'Successfully added bookmark.'
29
29
  fill_in "q", with: 'Sumadhvavijayaḥ'
30
- click_button 'search'
31
- click_button 'Remove bookmark'
30
+ click_on 'search'
31
+ click_on 'Remove bookmark'
32
32
  expect(page).to have_content 'Successfully removed bookmark.'
33
33
  end
34
34
 
35
35
  it "adds and delete bookmarks from the show page" do
36
36
  sign_in 'user1'
37
37
  visit solr_document_path('2007020969')
38
- click_button 'Bookmark'
39
- click_button 'Remove bookmark'
38
+ click_on 'Bookmark'
39
+ click_on 'Remove bookmark'
40
40
  expect(page).to have_content 'Successfully removed bookmark.'
41
41
  end
42
42
 
43
- it 'shows bookmarks as checkboxes', js: true do
43
+ it 'shows bookmarks as checkboxes', :js do
44
44
  visit solr_document_path('2007020969')
45
45
  check 'Bookmark'
46
46
 
@@ -51,7 +51,7 @@ RSpec.describe "Bookmarks" do
51
51
 
52
52
  it "adds bookmarks after a user logs in" do
53
53
  visit solr_document_path('2007020969')
54
- click_button 'Bookmark'
54
+ click_on 'Bookmark'
55
55
  sign_in 'user1'
56
56
  visit bookmarks_path
57
57
  expect(page).to have_button("Remove bookmark")
@@ -60,25 +60,40 @@ RSpec.describe "Bookmarks" do
60
60
 
61
61
  it "cites items in bookmarks" do
62
62
  visit solr_document_path('2007020969')
63
- click_button 'Bookmark'
64
- click_link 'Bookmarks'
65
- click_link 'Cite'
63
+ click_on 'Bookmark'
64
+ click_on 'Bookmarks'
65
+ click_on 'Cite'
66
66
  expect(page).to have_content 'Strong Medicine speaks'
67
67
  end
68
68
 
69
69
  it "cites all items in current bookmarks" do
70
70
  visit solr_document_path('2009373513') # Ci an zhou bian
71
- click_button 'Bookmark'
71
+ click_on 'Bookmark'
72
72
 
73
73
  visit solr_document_path('2007020969') # Strong Medicine speaks
74
- click_button 'Bookmark'
74
+ click_on 'Bookmark'
75
75
 
76
76
  visit "/bookmarks?per_page=1"
77
77
  expect(page).to have_content 'Strong Medicine speaks'
78
- expect(page).not_to have_content 'Ci an zhou bian'
78
+ expect(page).to have_no_content 'Ci an zhou bian'
79
79
 
80
- click_link 'Cite'
80
+ click_on 'Cite'
81
81
  expect(page).to have_content 'Strong Medicine speaks'
82
82
  expect(page).to have_content 'Ci an zhou bian'
83
83
  end
84
+
85
+ context "has bookmark icon" do
86
+ before do
87
+ CatalogController.blacklight_config.bookmark_icon_component = Blacklight::Icons::BookmarkIconComponent
88
+ end
89
+
90
+ it 'shows bookmark icon instead of checkbox', :js do
91
+ visit solr_document_path('2007020969')
92
+ expect(page).to have_css('.blacklight-icons-bookmark')
93
+ find('.blacklight-icons-bookmark').click
94
+
95
+ expect(find('.toggle-bookmark[type="checkbox"]', visible: false)).to be_checked
96
+ find('.blacklight-icons-bookmark').click
97
+ end
98
+ end
84
99
  end
@@ -4,7 +4,7 @@ RSpec.describe 'Citation functionality' do
4
4
  before { visit solr_document_path('2007020969') }
5
5
 
6
6
  it 'displays the Cite modal with expected header' do
7
- click_link 'Cite'
7
+ click_on 'Cite'
8
8
  expect(find('div.modal-header')).to have_text 'Cite'
9
9
  end
10
10
  end