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:
Javi Martín
2021-06-12 16:01:42 +02:00
parent 42ffc62d12
commit de436e33a4
2 changed files with 2 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ describe Budgets::Investments::VotesComponent, type: :component do
render_inline component render_inline component
expect(page).to have_link count: 1 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" expect(page).to have_link "Support Renovate sidewalks in Main Street"
end end

View File

@@ -42,7 +42,7 @@ describe "Votes" do
visit budget_investments_path(budget, heading_id: heading.id) visit budget_investments_path(budget, heading_id: heading.id)
within(".supports") do within(".supports") do
click_link "Support this project" click_link "Support"
expect(page).to have_content "1 support" expect(page).to have_content "1 support"
expect(page).to have_content "You have already supported this investment project. "\ expect(page).to have_content "You have already supported this investment project. "\