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.
23 lines
592 B
Ruby
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
|