Use aria-label in admin table actions

This way screen reader users will know which record they're going to
access when focusing on a link to a certain action. Otherwise they'd
hear something like "Edit, link", and they wouldn't know which record
they'll end up editing if they follow the link.
This commit is contained in:
Javi Martín
2021-08-17 22:29:11 +02:00
parent 6a2c01b119
commit 2b4b2f3442
13 changed files with 189 additions and 5 deletions

View File

@@ -1,14 +1,16 @@
require "rails_helper"
describe Admin::TableActionsComponent, controller: Admin::BaseController do
let(:record) { create(:banner) }
let(:record) { create(:banner, title: "Important!") }
it "renders links to edit and destroy a record by default" do
render_inline Admin::TableActionsComponent.new(record)
expect(page).to have_css "a", count: 2
expect(page).to have_css "a[href*='edit']", text: "Edit"
expect(page).to have_css "a[data-method='delete']", text: "Delete"
expect(page).to have_css "a[href*='edit']", exact_text: "Edit"
expect(page).to have_css "a[aria-label='Edit Important!']", exact_text: "Edit"
expect(page).to have_css "a[data-method='delete']", exact_text: "Delete"
expect(page).to have_css "a[aria-label='Delete Important!']", exact_text: "Delete"
end
context "actions parameter is passed" do