Use a component test to check a link title
In regular system tests, we prefer testing against the text of the link because it's easier to recognize which link we're talking about. I was wondering whether we should remove the `title` attribute completely and use just the `aria-label` attribute. Quoting The Paciello Group blog [1]: "If you want to hide content from mobile and tablet users as well as assistive tech users and keyboard only users, use the title attribute." However, there's a case where mouse users might find the title attribute useful. When visiting an investment page, the connection between the "Support" link and the investment is not as clear as it is in the investments index page, so it might not be clear what you're supporting. As mentioned, though, this information will only be relevant for mouse users, who nowadays represent less than half of our users. [1] https://www.tpgi.com/using-the-html-title-attribute-updated/
This commit is contained in:
@@ -16,7 +16,7 @@ describe Budgets::Investments::VotesComponent, type: :component do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_link count: 1
|
||||
expect(page).to have_link "Support"
|
||||
expect(page).to have_link "Support", title: "Support this project"
|
||||
expect(page).to have_link "Support Renovate sidewalks in Main Street"
|
||||
end
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ describe "Votes" do
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within(".supports") do
|
||||
click_link "Support this project"
|
||||
click_link "Support"
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
expect(page).to have_content "You have already supported this investment project. "\
|
||||
|
||||
Reference in New Issue
Block a user