From 0949c6e607dbae2dd53d45999af8b557f515ea63 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Thu, 24 Oct 2024 08:39:21 -0500 Subject: [PATCH] Switch to using the bookmark icon by default Fixes #3227 --- lib/blacklight/configuration.rb | 4 +-- spec/features/bookmarks_spec.rb | 45 ++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/lib/blacklight/configuration.rb b/lib/blacklight/configuration.rb index 131479bbf..41af9a2f7 100644 --- a/lib/blacklight/configuration.rb +++ b/lib/blacklight/configuration.rb @@ -137,8 +137,8 @@ def initialized_default_configuration? # @!attribute bookmark_icon_component # @since v8.3.1 # component class used to render a document - # set to Blacklight::Icons::BookmarkIconComponent to replace checkbox with icon - property :bookmark_icon_component, default: nil + # set to nil if a checkbox is prefered to the icon + property :bookmark_icon_component, default: Blacklight::Icons::BookmarkIconComponent # @!attribute index # General configuration for all views diff --git a/spec/features/bookmarks_spec.rb b/spec/features/bookmarks_spec.rb index d33853d0f..2c42cffca 100644 --- a/spec/features/bookmarks_spec.rb +++ b/spec/features/bookmarks_spec.rb @@ -45,13 +45,25 @@ expect(page).to have_content 'Successfully removed bookmark.' end - it 'shows bookmarks as checkboxes', :js do - visit solr_document_path('2007020969') - check 'Bookmark' + context 'when bookmark_icon_component is set to nil' do + let!(:default_bookmark_icon_component) { CatalogController.blacklight_config.bookmark_icon_component } - visit solr_document_path('2007020969') - expect(page).to have_css('input[type="checkbox"][checked]') - uncheck 'In Bookmarks' + before do + CatalogController.blacklight_config.bookmark_icon_component = nil + end + + after do + CatalogController.blacklight_config.bookmark_icon_component = default_bookmark_icon_component + end + + it 'shows bookmarks as checkboxes', :js do + visit solr_document_path('2007020969') + check 'Bookmark' + + visit solr_document_path('2007020969') + expect(page).to have_css('input[type="checkbox"][checked]') + uncheck 'In Bookmarks' + end end it "adds bookmarks after a user logs in" do @@ -87,18 +99,8 @@ expect(page).to have_content 'Ci an zhou bian' end - context "has bookmark icon" do - let!(:default_bookmark_icon_component) { CatalogController.blacklight_config.bookmark_icon_component } - - before do - CatalogController.blacklight_config.bookmark_icon_component = Blacklight::Icons::BookmarkIconComponent - end - - after do - CatalogController.blacklight_config.bookmark_icon_component = default_bookmark_icon_component - end - - it 'shows bookmark icon instead of checkbox', :js do + context "when the bookmark icon is configured (default)" do + it 'shows bookmark icon', :js do visit solr_document_path('2007020969') expect(page).to have_css('.blacklight-icons-bookmark') find('.blacklight-icons-bookmark').click @@ -122,12 +124,13 @@ it 'adds and removes bookmarks', :js do visit solr_document_path('2007020969') expect(page).to have_no_css('#bookmarks_nav') - check 'Bookmark' + find('.blacklight-icons-bookmark').click + expect(page).to have_content 'In Bookmarks' visit solr_document_path('2007020969') - expect(page).to have_css('input[type="checkbox"][checked]') - uncheck 'In Bookmarks' + expect(find('.toggle-bookmark-input', visible: false)).to be_checked + find('.blacklight-icons-bookmark').click end end end