Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing header nav partial with header component #3136

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hudajkhan
Copy link
Contributor

Context
Relates to having tests pass with Blacklight 8.3 and using a Spotlight HeaderComponent instead of shared/_header_navbar. The Spotlight header is almost exactly the same as the default Blacklight header except it does not include the search bar (which is elsewhere on the page).
Refer to #3047 and this comment which includes a checklist of tests to fix: #3047 (comment)

For 8.3, the following tests are failing:

  • rspec ./spec/views/shared/_header_navbar.html.erb_spec.rb:8 # shared/_header_navbar has nav links
  • rspec ./spec/views/spotlight/pages/show.html.erb_spec.rb:46 # spotlight/pages/show when rendering with layout does not double-escape HTML entities in the HTML title
  • rspec ./spec/views/spotlight/pages/show.html.erb_spec.rb:50 # spotlight/pages/show when rendering with layout includes analytics reporting

What this pull request does

  • Removes the header_navbar partial.
  • Creates a Spotlight HeaderComponent whose partial displays on the top bar.
  • Adds the Spotlight Header Component to the configuration as the header component.
  • Adds blacklight configuration information for the show html rspec to pass.

How to test
These tests should still pass in Blacklight 7.

How to test with Blacklight 8: Generate test app (.internal_test_app). Update the internal test app's Gemfile to use Blacklight 8.3. Run bundle install for the internal test app. Then run rspec ./spec/views/spotlight/pages/show.html.erb_spec.rb:46 and rspec ./spec/views/spotlight/pages/show.html.erb_spec.rb:50.

@cbeer
Copy link
Member

cbeer commented Sep 20, 2024

I wonder if there's a backwards-compatible way to introduce this change (that won't require downstream applications to add the header_component configuration).

Maybe we could keep the header_navbar partial?

<% if blacklight_config.header_component.present? && blacklight_config.header_component != Blacklight::HeaderComponent %>
<%= render blacklight_config.header_component.new(blacklight_config: blacklight_config) %>
<% else %>
<%# TODO: deprecation warning to encourage downstream to add the config? %>
<%= render Spotlight::HeaderComponent.new(blacklight_config: blacklight_config) %>
<% end %>

@hudajkhan
Copy link
Contributor Author

@cbeer I brought the partial back and its associated test and set up with a deprecation warning.

@@ -0,0 +1,13 @@
# frozen_string_literal: true

describe 'shared/_header_navbar', type: :view do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe 'shared/_header_navbar', type: :view do
RSpec.describe 'shared/_header_navbar', type: :view do


it 'has nav links' do
render
expect(rendered).to have_selector '#user-util-collapse', text: 'links'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have a view test at all? View tests are deprecated in rails. Instead can you use a request test, feature test, or a component test?

<%= render blacklight_config.header_component.new(blacklight_config: blacklight_config) %>
<% else %>
<%= render Spotlight::HeaderComponent.new(blacklight_config: blacklight_config) %>
<% ActiveSupport::Deprecation.warn("_header_navbar.html.erb will be deprecated in future versions. Please use Blaclight configuration to specify your HeaderComponent.") %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<% ActiveSupport::Deprecation.warn("_header_navbar.html.erb will be deprecated in future versions. Please use Blaclight configuration to specify your HeaderComponent.") %>
<% ActiveSupport::Deprecation.warn("_header_navbar.html.erb will be deprecated in future versions. Please use Blacklight configuration to specify your HeaderComponent.") %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Blacklight 8
3 participants