Files
nairobi/spec/components/shared/avatar_component_spec.rb
Javi Martín 360a181c18 Use aria-hidden when rendering SVG avatars
It looks like not all screen readers identify SVG images with empty aria
labels as a decorative image, as reported by the Axe accessibility
engine.

So we're using `aria-hidden` instead, since we don't want the text of
the SVG to be read by screen readers. We're using `aria-hidden` instead
of the `presentation` role for the reasons mentioned in commit
35659d441.
2024-11-12 18:25:20 +01:00

23 lines
592 B
Ruby

require "rails_helper"
describe Shared::AvatarComponent do
let(:user) { double(id: 1, name: "Johnny") }
let(:component) { Shared::AvatarComponent.new(user) }
it "does not contain redundant text already present around it" do
render_inline component
expect(page).to have_css "svg", count: 1
expect(page).to have_css "svg[role='img'][aria-hidden='true']"
end
it "shows the initial letter of the name" do
render_inline component
page.find("svg") do |avatar|
expect(avatar).to have_text "J"
expect(avatar).not_to have_text "Johnny"
end
end
end