blacklight 9.0.0 → 9.1.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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/.env +3 -3
  3. data/.github/matrix.json +12 -18
  4. data/.github/workflows/lint.yml +1 -1
  5. data/.github/workflows/test.yml +4 -3
  6. data/.rubocop.yml +72 -7
  7. data/.rubocop_todo.yml +142 -268
  8. data/Gemfile +1 -1
  9. data/README.md +2 -9
  10. data/VERSION +1 -1
  11. data/app/assets/builds/blacklight.css +37 -23
  12. data/app/assets/images/blacklight/logo-dark.svg +184 -0
  13. data/app/assets/images/blacklight/logo.svg +184 -0
  14. data/app/assets/javascripts/blacklight/blacklight.esm.js +128 -45
  15. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  16. data/app/assets/javascripts/blacklight/blacklight.js +128 -45
  17. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  18. data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
  19. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +17 -0
  20. data/app/assets/stylesheets/blacklight/_constraints.scss +2 -2
  21. data/app/assets/stylesheets/blacklight/_facets.scss +14 -10
  22. data/app/assets/stylesheets/blacklight/_header.scss +0 -4
  23. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +5 -9
  24. data/app/components/blacklight/facets/inclusive_constraint_component.html.erb +1 -1
  25. data/app/components/blacklight/icons/checkmark_component.rb +16 -0
  26. data/app/components/blacklight/icons/circle_half_component.rb +16 -0
  27. data/app/components/blacklight/icons/moon_stars_component.rb +17 -0
  28. data/app/components/blacklight/icons/sun_component.rb +16 -0
  29. data/app/components/blacklight/metadata_field_component.rb +1 -1
  30. data/app/components/blacklight/search_navbar_component.html.erb +1 -1
  31. data/app/components/blacklight/theme_switcher_component.html.erb +31 -0
  32. data/app/components/blacklight/theme_switcher_component.rb +6 -0
  33. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  34. data/app/controllers/concerns/blacklight/bookmarks.rb +8 -14
  35. data/app/controllers/concerns/blacklight/catalog.rb +9 -10
  36. data/app/controllers/concerns/blacklight/controller.rb +54 -11
  37. data/app/controllers/concerns/blacklight/guest_user.rb +51 -0
  38. data/app/controllers/concerns/blacklight/search_context.rb +1 -1
  39. data/app/controllers/concerns/blacklight/search_history.rb +3 -1
  40. data/app/controllers/concerns/blacklight/searchable.rb +18 -0
  41. data/app/helpers/blacklight/layout_helper_behavior.rb +7 -0
  42. data/app/javascript/blacklight-frontend/color_theme_switcher.js +85 -0
  43. data/app/javascript/blacklight-frontend/index.js +2 -0
  44. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -2
  45. data/app/models/concerns/blacklight/document.rb +1 -1
  46. data/app/models/concerns/blacklight/user.rb +36 -0
  47. data/app/presenters/blacklight/field_presenter.rb +1 -1
  48. data/app/presenters/blacklight/rendering/microdata.rb +1 -0
  49. data/app/services/blacklight/bookmarks_search_builder.rb +4 -4
  50. data/app/services/blacklight/search_service.rb +46 -33
  51. data/app/values/blacklight/types.rb +1 -1
  52. data/app/views/catalog/_email_form.html.erb +3 -3
  53. data/app/views/catalog/_home_text.html.erb +1 -1
  54. data/app/views/catalog/_sms_form.html.erb +4 -4
  55. data/app/views/catalog/index.rss.builder +4 -4
  56. data/app/views/catalog/opensearch.json.jbuilder +3 -0
  57. data/app/views/catalog/opensearch.xml.builder +2 -2
  58. data/app/views/layouts/blacklight/base.html.erb +13 -1
  59. data/app/views/shared/_user_util_links.html.erb +18 -5
  60. data/blacklight.gemspec +3 -3
  61. data/config/locales/blacklight.ar.yml +5 -0
  62. data/config/locales/blacklight.ca.yml +5 -0
  63. data/config/locales/blacklight.de.yml +6 -2
  64. data/config/locales/blacklight.en.yml +5 -0
  65. data/config/locales/blacklight.es.yml +5 -0
  66. data/config/locales/blacklight.fr.yml +5 -0
  67. data/config/locales/blacklight.hu.yml +5 -0
  68. data/config/locales/blacklight.it.yml +6 -2
  69. data/config/locales/blacklight.nl.yml +5 -0
  70. data/config/locales/blacklight.pt-BR.yml +6 -2
  71. data/config/locales/blacklight.sq.yml +5 -0
  72. data/config/locales/blacklight.zh.yml +5 -0
  73. data/lib/blacklight/component.rb +1 -1
  74. data/lib/blacklight/configuration/action_config_map_entry.rb +31 -0
  75. data/lib/blacklight/configuration/display_field.rb +1 -0
  76. data/lib/blacklight/configuration/field.rb +6 -6
  77. data/lib/blacklight/configuration/fields.rb +1 -1
  78. data/lib/blacklight/configuration/sort_field.rb +2 -2
  79. data/lib/blacklight/configuration.rb +30 -19
  80. data/lib/blacklight/parameters.rb +1 -1
  81. data/lib/blacklight/search_builder.rb +58 -19
  82. data/lib/blacklight/search_state.rb +4 -0
  83. data/lib/blacklight/solr/request.rb +8 -1
  84. data/lib/blacklight/solr/response/group_response.rb +1 -1
  85. data/lib/blacklight/solr/response/spelling.rb +8 -8
  86. data/lib/blacklight/solr/response.rb +2 -21
  87. data/lib/blacklight/solr/search_builder_behavior.rb +3 -9
  88. data/lib/blacklight.rb +2 -2
  89. data/lib/generators/blacklight/assets/importmap_generator.rb +2 -2
  90. data/lib/generators/blacklight/assets_generator.rb +1 -1
  91. data/lib/generators/blacklight/controller_generator.rb +1 -1
  92. data/lib/generators/blacklight/document_generator.rb +1 -1
  93. data/lib/generators/blacklight/install_generator.rb +6 -4
  94. data/lib/generators/blacklight/models_generator.rb +1 -1
  95. data/lib/generators/blacklight/search_builder_generator.rb +1 -1
  96. data/lib/generators/blacklight/solr_generator.rb +1 -1
  97. data/lib/generators/blacklight/templates/catalog_controller.rb +20 -1
  98. data/lib/generators/blacklight/templates/solr/conf/schema.xml +264 -178
  99. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +6 -14
  100. data/lib/generators/blacklight/test_support_generator.rb +1 -1
  101. data/lib/generators/blacklight/user_generator.rb +66 -5
  102. data/lib/railties/blacklight.rake +4 -4
  103. data/package.json +2 -2
  104. data/spec/components/blacklight/document/action_component_spec.rb +1 -1
  105. data/spec/components/blacklight/document/group_component_spec.rb +1 -1
  106. data/spec/components/blacklight/document_component_spec.rb +9 -9
  107. data/spec/components/blacklight/facet_component_spec.rb +2 -2
  108. data/spec/components/blacklight/facets/index_navigation_component_spec.rb +1 -2
  109. data/spec/components/blacklight/facets/list_component_spec.rb +1 -1
  110. data/spec/components/blacklight/facets/suggest_component_spec.rb +1 -2
  111. data/spec/components/blacklight/metadata_field_component_spec.rb +26 -0
  112. data/spec/components/blacklight/skip_link_component_spec.rb +2 -2
  113. data/spec/controllers/application_controller_spec.rb +71 -0
  114. data/spec/controllers/bookmarks_controller_spec.rb +18 -5
  115. data/spec/controllers/catalog_controller_spec.rb +7 -5
  116. data/spec/features/advanced_search_spec.rb +29 -16
  117. data/spec/features/alternate_controller_spec.rb +4 -4
  118. data/spec/features/axe_spec.rb +34 -22
  119. data/spec/features/bookmarks_spec.rb +13 -13
  120. data/spec/features/dark_mode_spec.rb +42 -0
  121. data/spec/features/did_you_mean_spec.rb +27 -27
  122. data/spec/features/facet_missing_spec.rb +3 -3
  123. data/spec/features/record_view_spec.rb +14 -14
  124. data/spec/features/search_context_spec.rb +8 -8
  125. data/spec/features/search_filters_spec.rb +16 -16
  126. data/spec/features/search_formats_spec.rb +2 -2
  127. data/spec/features/search_history_spec.rb +11 -11
  128. data/spec/features/search_pagination_spec.rb +17 -17
  129. data/spec/features/search_results_spec.rb +3 -3
  130. data/spec/features/search_sort_spec.rb +4 -4
  131. data/spec/features/search_spec.rb +20 -20
  132. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +15 -15
  133. data/spec/helpers/blacklight_helper_spec.rb +1 -1
  134. data/spec/helpers/catalog_helper_spec.rb +7 -7
  135. data/spec/integration/generators/blacklight/user_generator_spec.rb +60 -0
  136. data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +1 -1
  137. data/spec/models/blacklight/configurable_spec.rb +1 -1
  138. data/spec/models/blacklight/configuration_spec.rb +0 -19
  139. data/spec/models/blacklight/document/dublin_core_spec.rb +2 -2
  140. data/spec/models/blacklight/facet_paginator_spec.rb +1 -1
  141. data/spec/models/blacklight/search_builder_spec.rb +15 -3
  142. data/spec/models/blacklight/solr/repository_spec.rb +10 -2
  143. data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +3 -5
  144. data/spec/models/blacklight/user_spec.rb +32 -5
  145. data/spec/models/bookmark_spec.rb +1 -1
  146. data/spec/models/record_mailer_spec.rb +8 -8
  147. data/spec/models/search_spec.rb +1 -1
  148. data/spec/models/solr_document_spec.rb +4 -0
  149. data/spec/presenters/blacklight/index_presenter_spec.rb +1 -0
  150. data/spec/presenters/blacklight/rendering/pipeline_spec.rb +1 -0
  151. data/spec/presenters/blacklight/show_presenter_spec.rb +1 -0
  152. data/spec/presenters/blacklight/thumbnail_presenter_spec.rb +1 -0
  153. data/spec/services/blacklight/search_service_spec.rb +7 -7
  154. data/spec/spec_helper.rb +3 -12
  155. data/spec/support/features/session_helpers.rb +13 -4
  156. data/spec/support/features/turbo_helpers.rb +13 -0
  157. data/spec/support/features.rb +2 -0
  158. data/spec/support/user_helpers.rb +24 -0
  159. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  160. data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
  161. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
  162. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +5 -5
  163. data/spec/views/catalog/index.html.erb_spec.rb +2 -2
  164. data/spec/views/catalog/show.html.erb_spec.rb +3 -4
  165. data/spec/views/shared/_user_util_links.html.erb_spec.rb +56 -0
  166. data/template.demo.rb +2 -1
  167. metadata +30 -22
  168. data/.hound.yml +0 -4
  169. data/.jshintrc +0 -22
  170. data/app/assets/images/blacklight/logo.png +0 -0
@@ -35,7 +35,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
35
35
  expect(page).to have_css('.blacklight-language_ssim')
36
36
 
37
37
  within('.blacklight-language_ssim') do
38
- expect(page).to have_content 'Language'
38
+ expect(page).to have_text 'Language'
39
39
  end
40
40
  end
41
41
 
@@ -53,15 +53,15 @@ RSpec.describe "Blacklight Advanced Search Form" do
53
53
  it 'scopes searches to fields' do
54
54
  fill_in 'Title', with: 'Medicine'
55
55
  click_on 'advanced-search-submit'
56
- expect(page).to have_content 'Remove constraint Title: Medicine'
57
- expect(page).to have_content 'Strong Medicine speaks'
56
+ expect(page).to have_text 'Remove constraint Title: Medicine'
57
+ expect(page).to have_text 'Strong Medicine speaks'
58
58
  expect(page).to have_css('article.document', count: 1)
59
59
  end
60
60
 
61
61
  it 'does not render spellcheck/did you mean? section' do
62
62
  fill_in 'All Fields', with: 'tibet'
63
63
  click_on 'advanced-search-submit'
64
- expect(page).to have_content 'Remove constraint All Fields: tibet'
64
+ expect(page).to have_text 'Remove constraint All Fields: tibet'
65
65
  expect(page).to have_css('article.document', count: 2)
66
66
  expect(page).to have_no_css('#spell')
67
67
  end
@@ -73,16 +73,16 @@ RSpec.describe "Blacklight Advanced Search Form" do
73
73
  check 'Urdu 3'
74
74
  end
75
75
  click_on 'advanced-search-submit'
76
- expect(page).to have_content 'Pākistānī ʻaurat dorāhe par'
77
- expect(page).to have_no_content 'Ajikto kŭrŏk chŏrŏk sasimnikka : and 아직도 그럭 저럭 사십니까'
76
+ expect(page).to have_text 'Pākistānī ʻaurat dorāhe par'
77
+ expect(page).to have_no_text 'Ajikto kŭrŏk chŏrŏk sasimnikka : and 아직도 그럭 저럭 사십니까'
78
78
  expect(page).to have_css('article.document', count: 1)
79
79
  end
80
80
 
81
81
  it 'handles boolean queries' do
82
82
  fill_in 'All Fields', with: 'history NOT strong'
83
83
  click_on 'advanced-search-submit'
84
- expect(page).to have_content('Ci an zhou bian')
85
- expect(page).to have_no_content('Strong Medicine speaks')
84
+ expect(page).to have_text('Ci an zhou bian')
85
+ expect(page).to have_no_text('Strong Medicine speaks')
86
86
  expect(page).to have_css('article.document', count: 10)
87
87
  end
88
88
 
@@ -90,7 +90,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
90
90
  fill_in 'All Fields', with: 'history'
91
91
  fill_in 'Author', with: 'hearth'
92
92
  click_on 'advanced-search-submit'
93
- expect(page).to have_content('Strong Medicine speaks')
93
+ expect(page).to have_text('Strong Medicine speaks')
94
94
  expect(page).to have_css('article.document', count: 1)
95
95
  end
96
96
 
@@ -99,10 +99,23 @@ RSpec.describe "Blacklight Advanced Search Form" do
99
99
  fill_in 'All Fields', with: 'history'
100
100
  fill_in 'Subject', with: 'women'
101
101
  click_on 'advanced-search-submit'
102
- expect(page).to have_content('Ci an zhou bian')
103
- expect(page).to have_content('Pākistānī ʻaurat dorāhe par')
102
+ expect(page).to have_text('Ci an zhou bian')
103
+ expect(page).to have_text('Pākistānī ʻaurat dorāhe par')
104
104
  expect(page).to have_css('article.document', count: 10)
105
105
  end
106
+
107
+ it 'returns all records when no query is present' do
108
+ click_on 'advanced-search-submit'
109
+ expect(page).to have_text('1 - 10 of 30')
110
+ end
111
+
112
+ it 'performs a faceted search when query is present' do
113
+ within '#facet-language_ssim' do
114
+ check 'Urdu 3'
115
+ end
116
+ click_on 'advanced-search-submit'
117
+ expect(page).to have_css('article.document', count: 3)
118
+ end
106
119
  end
107
120
 
108
121
  describe "prepopulated advanced search form" do
@@ -135,8 +148,8 @@ RSpec.describe "Blacklight Advanced Search Form" do
135
148
  it "does not have multiple parameters for a search field" do
136
149
  fill_in 'Title', with: 'bread'
137
150
  click_on 'advanced-search-submit'
138
- expect(page.current_url).to match(/bread/)
139
- expect(page.current_url).not_to match(/medicine/)
151
+ expect(page.current_url).to include('bread')
152
+ expect(page.current_url).not_to include('medicine')
140
153
  end
141
154
 
142
155
  it "clears the prepopulated fields when the Start Over button is pressed" do
@@ -149,14 +162,14 @@ RSpec.describe "Blacklight Advanced Search Form" do
149
162
 
150
163
  it 'creates constraints for fields not included in advanced search form' do
151
164
  within('div.constraints') do
152
- expect(page).to have_content('Format:Book')
165
+ expect(page).to have_text('Format:Book')
153
166
  end
154
167
  end
155
168
 
156
169
  it 'does not create constraints for fields included in the advanced search form' do
157
170
  within('div.constraints') do
158
- expect(page).to have_no_content('Title:medicine')
159
- expect(page).to have_no_content('Language:Tibetan')
171
+ expect(page).to have_no_text('Title:medicine')
172
+ expect(page).to have_no_text('Language:Tibetan')
160
173
  end
161
174
  end
162
175
  end
@@ -6,11 +6,11 @@ RSpec.describe "Alternate Controller Behaviors" do
6
6
  expect(page).to have_css("form[action='#{search_alternate_url}']")
7
7
  fill_in "q", with: "history"
8
8
  click_on 'search'
9
- expect(current_path).to match /#{search_alternate_path}/
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'
12
12
  end
13
- expect(current_path).to match /#{search_alternate_path}/
13
+ expect(current_path).to match(/#{search_alternate_path}/)
14
14
  end
15
15
 
16
16
  it "has the correct search field form" do
@@ -18,9 +18,9 @@ RSpec.describe "Alternate Controller Behaviors" do
18
18
  expect(page).to have_css("form[action='#{search_alternate_url}']")
19
19
  fill_in "q", with: "history"
20
20
  click_on 'search'
21
- expect(current_path).to match /#{search_alternate_path}/
21
+ expect(current_path).to match(/#{search_alternate_path}/)
22
22
  click_on 'relevance'
23
- expect(current_path).to match /#{search_alternate_path}/
23
+ expect(current_path).to match(/#{search_alternate_path}/)
24
24
  end
25
25
 
26
26
  it "displays document thumbnails" do
@@ -1,33 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe 'Accessibility testing', :js, api: false do
4
- it 'validates the home page' do
5
- visit root_path
6
- expect(page).to be_axe_clean
7
- end
4
+ %w[dark light].each do |theme|
5
+ context "with #{theme} theme" do
6
+ before do
7
+ visit root_path
8
+ find_by_id('bl-theme-switcher').click
9
+ find("[data-bs-theme-value='#{theme}']").click
10
+ end
8
11
 
9
- it 'validates the catalog page' do
10
- visit root_path
11
- fill_in "q", with: 'history'
12
- click_on 'search'
12
+ it 'validates the home page' do
13
+ visit root_path
14
+ expect(page).to be_axe_clean
15
+ end
13
16
 
14
- expect(page).to be_axe_clean
17
+ it 'validates the catalog page' do
18
+ visit root_path
19
+ fill_in "q", with: 'history'
20
+ click_on 'search'
21
+ wait_for_turbo
15
22
 
16
- within '.accordion-item.blacklight-language_ssim' do
17
- click_on 'Language'
18
- click_on "Tibetan"
19
- end
23
+ expect(page).to be_axe_clean
20
24
 
21
- expect(page).to be_axe_clean
22
- end
25
+ within '.accordion-item.blacklight-language_ssim' do
26
+ click_on 'Language'
27
+ click_on "Tibetan"
28
+ end
29
+ wait_for_turbo
23
30
 
24
- it 'validates the advanced search form' do
25
- visit advanced_search_catalog_path
26
- expect(page).to be_axe_clean
27
- end
31
+ expect(page).to be_axe_clean
32
+ end
33
+
34
+ it 'validates the advanced search form' do
35
+ visit advanced_search_catalog_path
36
+ expect(page).to be_axe_clean
37
+ end
28
38
 
29
- it 'validates the single results page' do
30
- visit solr_document_path('2007020969')
31
- expect(page).to be_axe_clean
39
+ it 'validates the single results page' do
40
+ visit solr_document_path('2007020969')
41
+ expect(page).to be_axe_clean
42
+ end
43
+ end
32
44
  end
33
45
  end
@@ -11,7 +11,7 @@ RSpec.describe "Bookmarks" do
11
11
  sign_in 'user1'
12
12
  visit root_path
13
13
  click_on 'Bookmarks'
14
- expect(page).to have_content 'You have no bookmarks'
14
+ expect(page).to have_text 'You have no bookmarks'
15
15
  end
16
16
  end
17
17
 
@@ -20,8 +20,8 @@ RSpec.describe "Bookmarks" do
20
20
  click_on 'Bookmark'
21
21
  click_on 'Bookmarks'
22
22
  click_on 'Clear Bookmarks'
23
- expect(page).to have_content 'Cleared your bookmarks.'
24
- expect(page).to have_content 'You have no bookmarks'
23
+ expect(page).to have_text 'Cleared your bookmarks.'
24
+ expect(page).to have_text 'You have no bookmarks'
25
25
  end
26
26
 
27
27
  it "add and remove bookmarks from search results" do
@@ -30,11 +30,11 @@ RSpec.describe "Bookmarks" do
30
30
  fill_in "q", with: 'Sumadhvavijayaḥ'
31
31
  click_on 'search'
32
32
  click_on 'Bookmark'
33
- expect(page).to have_content 'Successfully added bookmark.'
33
+ expect(page).to have_text 'Successfully added bookmark.'
34
34
  fill_in "q", with: 'Sumadhvavijayaḥ'
35
35
  click_on 'search'
36
36
  click_on 'Remove bookmark'
37
- expect(page).to have_content 'Successfully removed bookmark.'
37
+ expect(page).to have_text 'Successfully removed bookmark.'
38
38
  end
39
39
 
40
40
  it "adds and delete bookmarks from the show page" do
@@ -42,7 +42,7 @@ RSpec.describe "Bookmarks" do
42
42
  visit solr_document_path('2007020969')
43
43
  click_on 'Bookmark'
44
44
  click_on 'Remove bookmark'
45
- expect(page).to have_content 'Successfully removed bookmark.'
45
+ expect(page).to have_text 'Successfully removed bookmark.'
46
46
  end
47
47
 
48
48
  context 'when bookmark_icon_component is set to nil' do
@@ -72,7 +72,7 @@ RSpec.describe "Bookmarks" do
72
72
  sign_in 'user1'
73
73
  visit bookmarks_path
74
74
  expect(page).to have_button("Remove bookmark")
75
- expect(page).to have_content("Strong Medicine speaks")
75
+ expect(page).to have_text("Strong Medicine speaks")
76
76
  end
77
77
 
78
78
  it "cites items in bookmarks" do
@@ -80,7 +80,7 @@ RSpec.describe "Bookmarks" do
80
80
  click_on 'Bookmark'
81
81
  click_on 'Bookmarks'
82
82
  click_on 'Cite'
83
- expect(page).to have_content 'Strong Medicine speaks'
83
+ expect(page).to have_text 'Strong Medicine speaks'
84
84
  end
85
85
 
86
86
  it "cites all items in current bookmarks" do
@@ -91,12 +91,12 @@ RSpec.describe "Bookmarks" do
91
91
  click_on 'Bookmark'
92
92
 
93
93
  visit "/bookmarks?per_page=1"
94
- expect(page).to have_content 'Strong Medicine speaks'
95
- expect(page).to have_no_content 'Ci an zhou bian'
94
+ expect(page).to have_text 'Strong Medicine speaks'
95
+ expect(page).to have_no_text 'Ci an zhou bian'
96
96
 
97
97
  click_on 'Cite'
98
- expect(page).to have_content 'Strong Medicine speaks'
99
- expect(page).to have_content 'Ci an zhou bian'
98
+ expect(page).to have_text 'Strong Medicine speaks'
99
+ expect(page).to have_text 'Ci an zhou bian'
100
100
  end
101
101
 
102
102
  context "when the bookmark icon is configured (default)" do
@@ -126,7 +126,7 @@ RSpec.describe "Bookmarks" do
126
126
  expect(page).to have_no_css('#bookmarks_nav')
127
127
  find('.blacklight-icons-bookmark').click
128
128
 
129
- expect(page).to have_content 'In Bookmarks'
129
+ expect(page).to have_text 'In Bookmarks'
130
130
 
131
131
  visit solr_document_path('2007020969')
132
132
  expect(find('.toggle-bookmark-input', visible: false)).to be_checked
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe 'Dark mode', :js do
4
+ it 'sets data-bs-theme="dark" on the html element when dark mode is selected' do
5
+ visit root_path
6
+
7
+ find_by_id('bl-theme-switcher').click
8
+ find('[data-bs-theme-value="dark"]').click
9
+
10
+ expect(page).to have_css('html[data-bs-theme="dark"]')
11
+ end
12
+
13
+ it 'sets data-bs-theme="light" on the html element when light mode is selected' do
14
+ visit root_path
15
+
16
+ find_by_id('bl-theme-switcher').click
17
+ find('[data-bs-theme-value="dark"]').click
18
+
19
+ find_by_id('bl-theme-switcher').click
20
+ find('[data-bs-theme-value="light"]').click
21
+
22
+ expect(page).to have_css('html[data-bs-theme="light"]')
23
+ end
24
+
25
+ context 'when dark mode support is disabled in the configuration' do
26
+ before do
27
+ allow(Blacklight::Configuration).to receive(:new).and_wrap_original do |m, *args|
28
+ config = m.call(*args)
29
+ config.dark_mode_support = false
30
+ config
31
+ end
32
+ end
33
+
34
+ it 'uses light mode and does not render the theme switcher' do
35
+ visit root_path
36
+
37
+ expect(page).to have_link('Login') # avoid negation right after visiting
38
+ expect(page).to have_no_css('html[data-bs-theme="dark"]')
39
+ expect(page).to have_no_css('#bl-theme-switcher')
40
+ end
41
+ end
42
+ end
@@ -8,10 +8,10 @@ RSpec.describe "Did You Mean" do
8
8
  fill_in "q", with: 'politica'
9
9
  click_on 'search'
10
10
 
11
- expect(page).to have_content("Did you mean")
11
+ expect(page).to have_text("Did you mean")
12
12
  click_on 'policy'
13
- within ("#sortAndPerPage") do
14
- expect(page).to have_content "1 - 2 of 2"
13
+ within("#sortAndPerPage") do
14
+ expect(page).to have_text "1 - 2 of 2"
15
15
  end
16
16
  end
17
17
  end
@@ -24,12 +24,12 @@ RSpec.describe "Did You Mean" do
24
24
  fill_in "q", with: 'yehudiyam'
25
25
  click_on 'search'
26
26
 
27
- expect(page).to have_content("Did you mean")
27
+ expect(page).to have_text("Did you mean")
28
28
  click_on 'yehudiyim'
29
- within ("#sortAndPerPage") do
30
- expect(page).to have_content "1 entry found"
29
+ within("#sortAndPerPage") do
30
+ expect(page).to have_text "1 entry found"
31
31
  end
32
- within ("select#search_field") do
32
+ within("select#search_field") do
33
33
  expect(page).to have_css("option[selected]", text: "Title")
34
34
  end
35
35
  end
@@ -43,12 +43,12 @@ RSpec.describe "Did You Mean" do
43
43
  fill_in "q", with: 'shirma'
44
44
  click_on 'search'
45
45
 
46
- expect(page).to have_content("Did you mean")
46
+ expect(page).to have_text("Did you mean")
47
47
  click_on 'sharma'
48
- within ("#sortAndPerPage") do
49
- expect(page).to have_content "1 entry found"
48
+ within("#sortAndPerPage") do
49
+ expect(page).to have_text "1 entry found"
50
50
  end
51
- within ("select#search_field") do
51
+ within("select#search_field") do
52
52
  expect(page).to have_css("option[selected]", text: "Author")
53
53
  end
54
54
  end
@@ -62,12 +62,12 @@ RSpec.describe "Did You Mean" do
62
62
  fill_in "q", with: 'wome'
63
63
  click_on 'search'
64
64
 
65
- expect(page).to have_content("Did you mean")
65
+ expect(page).to have_text("Did you mean")
66
66
  click_on 'women'
67
- within ("#sortAndPerPage") do
68
- expect(page).to have_content "1 - 3 of 3"
67
+ within("#sortAndPerPage") do
68
+ expect(page).to have_text "1 - 3 of 3"
69
69
  end
70
- within ("select#search_field") do
70
+ within("select#search_field") do
71
71
  expect(page).to have_css("option[selected]", text: "Subject")
72
72
  end
73
73
  end
@@ -78,7 +78,7 @@ RSpec.describe "Did You Mean" do
78
78
  fill_in "q", with: 'ooofda ooofda'
79
79
  click_on 'search'
80
80
 
81
- expect(page).to have_no_content("Did you mean")
81
+ expect(page).to have_no_text("Did you mean")
82
82
  end
83
83
 
84
84
  it "has separate suggestions" do
@@ -86,15 +86,15 @@ RSpec.describe "Did You Mean" do
86
86
  click_on 'search'
87
87
 
88
88
  within(".suggest") do
89
- expect(page).to have_content("Did you mean")
89
+ expect(page).to have_text("Did you mean")
90
90
  expect(page).to have_link('policy')
91
91
  expect(page).to have_link('bon')
92
92
  expect(page).to have_no_link('policy bon')
93
93
  end
94
94
 
95
95
  click_on 'bon'
96
- within ("#sortAndPerPage") do
97
- expect(page).to have_content "1 entry found"
96
+ within("#sortAndPerPage") do
97
+ expect(page).to have_text "1 entry found"
98
98
  end
99
99
  end
100
100
 
@@ -103,7 +103,7 @@ RSpec.describe "Did You Mean" do
103
103
  click_on 'search'
104
104
 
105
105
  within(".suggest") do
106
- expect(page).to have_content("Did you mean")
106
+ expect(page).to have_text("Did you mean")
107
107
  expect(page).to have_link('bon', count: 1)
108
108
  expect(page).to have_no_link('bon bon')
109
109
  end
@@ -114,10 +114,10 @@ RSpec.describe "Did You Mean" do
114
114
  fill_in "q", with: 'ayaz'
115
115
  click_on 'search'
116
116
 
117
- expect(page).to have_content("Did you mean")
117
+ expect(page).to have_text("Did you mean")
118
118
  click_on 'bya'
119
- within ("#sortAndPerPage") do
120
- expect(page).to have_content "1 - 3 of 3"
119
+ within("#sortAndPerPage") do
120
+ expect(page).to have_text "1 - 3 of 3"
121
121
  end
122
122
  end
123
123
 
@@ -125,7 +125,7 @@ RSpec.describe "Did You Mean" do
125
125
  # polit gives 5 results in 30 record demo index - 5 is default cutoff
126
126
  fill_in "q", with: 'polit'
127
127
  click_on 'search'
128
- expect(page).to have_content("Did you mean")
128
+ expect(page).to have_text("Did you mean")
129
129
  end
130
130
 
131
131
  context 'spellcheck collations are enabled' do
@@ -141,10 +141,10 @@ RSpec.describe "Did You Mean" do
141
141
  fill_in "q", with: 'Yoshido Hajime'
142
142
  click_on 'search'
143
143
 
144
- expect(page).to have_content("Did you mean")
144
+ expect(page).to have_text("Did you mean")
145
145
  click_on 'yoshida Hajime'
146
- within ("#sortAndPerPage") do
147
- expect(page).to have_content "1 - 2 of 2"
146
+ within("#sortAndPerPage") do
147
+ expect(page).to have_text "1 - 2 of 2"
148
148
  end
149
149
  end
150
150
  end
@@ -23,7 +23,7 @@ RSpec.describe "Facet missing" do
23
23
  end
24
24
 
25
25
  within "#sortAndPerPage" do
26
- expect(page).to have_content "1 - 10 of 13"
26
+ expect(page).to have_text "1 - 10 of 13"
27
27
  end
28
28
 
29
29
  expect(page).to have_css(".constraint-value", text: "Region")
@@ -44,7 +44,7 @@ RSpec.describe "Facet missing" do
44
44
  end
45
45
 
46
46
  expect(page).to have_no_link "remove"
47
- expect(page).to have_content("Welcome!")
47
+ expect(page).to have_text("Welcome!")
48
48
  end
49
49
  end
50
50
 
@@ -61,7 +61,7 @@ RSpec.describe "Facet missing" do
61
61
  end
62
62
 
63
63
  expect(page).to have_no_link "remove"
64
- expect(page).to have_content("Welcome!")
64
+ expect(page).to have_text("Welcome!")
65
65
  end
66
66
  end
67
67
  end
@@ -3,16 +3,16 @@
3
3
  RSpec.describe "Record View" do
4
4
  it "displays a normal record" do
5
5
  visit solr_document_path('2007020969')
6
- expect(page).to have_content "Title:"
7
- expect(page).to have_content "Strong Medicine speaks"
8
- expect(page).to have_content "Subtitle:"
9
- expect(page).to have_content "a Native American elder has her say : an oral history"
10
- expect(page).to have_content "Author:"
11
- expect(page).to have_content "Hearth, Amy Hill, 1958-"
12
- expect(page).to have_content "Format:"
13
- expect(page).to have_content "Book"
14
- expect(page).to have_content "Call number:"
15
- expect(page).to have_content "E99.D2 H437 2008"
6
+ expect(page).to have_text "Title:"
7
+ expect(page).to have_text "Strong Medicine speaks"
8
+ expect(page).to have_text "Subtitle:"
9
+ expect(page).to have_text "a Native American elder has her say : an oral history"
10
+ expect(page).to have_text "Author:"
11
+ expect(page).to have_text "Hearth, Amy Hill, 1958-"
12
+ expect(page).to have_text "Format:"
13
+ expect(page).to have_text "Book"
14
+ expect(page).to have_text "Call number:"
15
+ expect(page).to have_text "E99.D2 H437 2008"
16
16
  tmp_value = Capybara.ignore_hidden_elements
17
17
  Capybara.ignore_hidden_elements = false
18
18
  expect(page).to have_css("link[rel=alternate]")
@@ -21,13 +21,13 @@ RSpec.describe "Record View" do
21
21
 
22
22
  it "does not display blank titles" do
23
23
  visit solr_document_path('2008305903')
24
- expect(page).to have_no_content "More Information:"
24
+ expect(page).to have_no_text "More Information:"
25
25
  end
26
26
 
27
27
  it "does not display vernacular records" do
28
28
  visit solr_document_path('2009373513')
29
- expect(page).to have_content "次按驟變"
30
- expect(page).to have_content "林行止"
31
- expect(page).to have_content "臺北縣板橋市"
29
+ expect(page).to have_text "次按驟變"
30
+ expect(page).to have_text "林行止"
31
+ expect(page).to have_text "臺北縣板橋市"
32
32
  end
33
33
  end
@@ -5,12 +5,12 @@ RSpec.describe "Search Results context" do
5
5
  search_for ''
6
6
  click_on 'Pluvial nectar of blessings'
7
7
  search_id = Search.last.id.to_s
8
- expect(page).to have_content "« Previous | 10 of 30 | Next »"
8
+ expect(page).to have_text "« Previous | 10 of 30 | Next »"
9
9
  prev = page.find(".pagination-search-widgets .previous")
10
10
  expect(prev['data-context-href']).to eq "/catalog/2003546302/track?counter=9&document_id=2003546302&search_id=#{search_id}"
11
11
 
12
12
  click_on "« Previous"
13
- expect(page).to have_content "U21.2 .W85 2003"
13
+ expect(page).to have_text "U21.2 .W85 2003"
14
14
 
15
15
  prev = page.find(".pagination-search-widgets .previous")
16
16
  expect(prev['data-context-href']).to eq "/catalog/2004310986/track?counter=8&document_id=2004310986&search_id=#{search_id}"
@@ -19,8 +19,8 @@ RSpec.describe "Search Results context" do
19
19
  it "redirects context urls to the original url", :js do
20
20
  search_for ''
21
21
  first('.index_title a').click
22
- expect(page).to have_content "« Previous | 1 of 30 | Next »"
23
- expect(page.current_url).to have_no_content "/track"
22
+ expect(page).to have_text "« Previous | 1 of 30 | Next »"
23
+ expect(page.current_url).to have_no_text "/track"
24
24
  end
25
25
 
26
26
  it 'shows "Back to Search" and "Start Over links"' do
@@ -39,19 +39,19 @@ RSpec.describe "Search Results context" do
39
39
  # Go to the number 9 result separately
40
40
  visit '/catalog/2003546302'
41
41
  expect(page).to have_no_css '.page-links'
42
- expect(page).to have_no_content "« Previous | 10 of 30 | Next »"
42
+ expect(page).to have_no_text "« Previous | 10 of 30 | Next »"
43
43
  end
44
44
 
45
45
  context "navigating between search results using context pagination" do
46
46
  it "updates the back to search link with the current search pagination context", :js do
47
47
  search_for ''
48
- expect(page).to have_content "1 - 10"
48
+ expect(page).to have_text "1 - 10"
49
49
  find_all('.index_title a').last.click
50
50
  click_on "Next »"
51
51
 
52
- expect(page).to have_content "Naqdī barā-yi tamām-i"
52
+ expect(page).to have_text "Naqdī barā-yi tamām-i"
53
53
  click_on "Back to Search"
54
- expect(page).to have_content "11 - 20"
54
+ expect(page).to have_text "11 - 20"
55
55
  end
56
56
  end
57
57
  end