From de436e33a409a1117b87ac9ef7eeb8009412c110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 12 Jun 2021 16:01:42 +0200 Subject: [PATCH] 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/ --- spec/components/budgets/investments/votes_component_spec.rb | 2 +- spec/system/budgets/votes_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/components/budgets/investments/votes_component_spec.rb b/spec/components/budgets/investments/votes_component_spec.rb index 6a3e6ab98..888d41ef5 100644 --- a/spec/components/budgets/investments/votes_component_spec.rb +++ b/spec/components/budgets/investments/votes_component_spec.rb @@ -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 diff --git a/spec/system/budgets/votes_spec.rb b/spec/system/budgets/votes_spec.rb index a53b58438..8c5e64137 100644 --- a/spec/system/budgets/votes_spec.rb +++ b/spec/system/budgets/votes_spec.rb @@ -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. "\