Skip to content

Commit

Permalink
Aria label for download must include count displayed in viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-collier committed Nov 17, 2023
1 parent b19e874 commit 8ff636f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions app/components/embed/footer_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
<% end %>

<% if viewer.show_download? %>
<% file_count = viewer.purl_object.downloadable_files.length %>
<% download_file_label = 'No files available for download' %>
<% download_file_label = "#{file_count} #{'file'.pluralize(file_count)} available for download" if file_count > 0 %>
<button
class='sul-embed-footer-tool sul-embed-btn sul-em bed-btn-toolbar sul-embed-btn-default sul-i-download-3'
aria-expanded='false' aria-label='open download panel'
aria-expanded='false' aria-label='<%= download_file_label %>'
data-sul-embed-toggle='sul-embed-download-panel'>
<% file_count = viewer.purl_object.downloadable_files.length %>
<% if file_count > 0 %>
<span class='sul-embed-footer-tool sul-embed-download-count'
aria-label='number of downloadable files'><%= file_count %></span>
<span class='sul-embed-footer-tool sul-embed-download-count'><%= file_count %></span>
<% end %>
</button>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion spec/components/embed/footer_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
it "returns the object's footer" do
expect(page).to have_css 'div.sul-embed-footer'
expect(page).to have_css '[aria-label="open embed this panel"]'
expect(page).to have_css '[aria-label="open download panel"]'
expect(page).to have_css '[aria-label="2 files available for download"]'
end

describe 'fullscreen button' do
Expand Down
6 changes: 4 additions & 2 deletions spec/features/download_panel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,19 @@
stub_purl_xml_response_with_fixture(multi_media_purl)
visit_iframe_response
expect(page).to have_css '.sul-embed-body.sul-embed-media' # so shows download count
expect(page).to have_css 'button.sul-i-download-3[aria-label="2 files available for download"]'
within '.sul-i-download-3' do
expect(page).to have_css '.sul-embed-download-count[aria-label="number of downloadable files"]', text: 2
expect(page).to have_css '.sul-embed-download-count', text: 2
end
end

it 'only counts downloadable files' do
stub_purl_xml_response_with_fixture(world_restricted_download_purl)
visit_iframe_response
expect(page).to have_css '.sul-embed-body.sul-embed-media' # so shows download count
expect(page).to have_css 'button.sul-i-download-3[aria-label="1 file available for download"]'
within '.sul-i-download-3' do
expect(page).to have_css '.sul-embed-download-count[aria-label="number of downloadable files"]', text: 1
expect(page).to have_css '.sul-embed-download-count', text: 1
end
end
end
Expand Down

0 comments on commit 8ff636f

Please sign in to comment.