Use Capybara methods to find/click/check links
We applied the Capybara/SpecificMatcher in commit f52a86b46. However,
this rule doesn't convert methods finding <a> tags to methods finding
links because <a> tags only count as links when they've got the `href`
attribute. For instance, in the `xss_spec.rb` file we check what happens
when clicking on an anchor tag because we're testing that the `href`
attribute has been removed and so we can't use `click_link`.
So, basically, we can't enable a rule to automatically detect when we're
using `have_css` instead of `have_link`, but we should still do it
because `have_link` adds an extra check which affects accessibility
since it makes sure the tag has the `href` attribute and so it's
recognizable as a link by screen readers.
This commit is contained in:
@@ -55,8 +55,10 @@ describe "Admin custom information texts", :admin do
|
||||
visit admin_site_customization_information_texts_path
|
||||
|
||||
within("#information-texts-tabs") { click_link "Proposals" }
|
||||
expect(find("a[href=\"/admin/site_customization/information_texts?tab=proposals\"].is-active"))
|
||||
.to have_content "Proposals"
|
||||
|
||||
expect(page).to have_link "Proposals",
|
||||
href: "/admin/site_customization/information_texts?tab=proposals",
|
||||
class: "is-active"
|
||||
end
|
||||
|
||||
context "Globalization" do
|
||||
|
||||
@@ -155,7 +155,7 @@ describe "Polls" do
|
||||
within ".js-questions" do
|
||||
expect(page).to have_css ".nested-fields", count: 2
|
||||
within first(".nested-fields") do
|
||||
find("a.delete").click
|
||||
click_link class: "delete"
|
||||
end
|
||||
expect(page).to have_css ".nested-fields", count: 1
|
||||
end
|
||||
@@ -177,7 +177,7 @@ describe "Polls" do
|
||||
within ".js-questions .js-answers" do
|
||||
expect(page).to have_css ".nested-fields", count: 2
|
||||
within first(".nested-fields") do
|
||||
find("a.delete").click
|
||||
click_link class: "delete"
|
||||
end
|
||||
expect(page).to have_css ".nested-fields", count: 1
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ describe "Debates" do
|
||||
within("#debates") do
|
||||
expect(page).to have_content debate.title
|
||||
expect(page).to have_content debate.description
|
||||
expect(page).to have_css("a[href='#{debate_path(debate)}']", text: debate.title)
|
||||
expect(page).to have_link debate.title, href: debate_path(debate)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -110,7 +110,7 @@ describe "Proposals" do
|
||||
expect(page).to have_content(proposal1.title)
|
||||
expect(page).to have_content(proposal1.summary)
|
||||
expect(page).not_to have_content(proposal2.title)
|
||||
expect(page).to have_css("a[href='#{management_proposal_path(proposal1)}']", text: proposal1.title)
|
||||
expect(page).to have_link proposal1.title, href: management_proposal_path(proposal1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -133,9 +133,9 @@ describe "Proposals" do
|
||||
|
||||
within(".proposals-list") do
|
||||
expect(page).to have_css(".proposal", count: 2)
|
||||
expect(page).to have_css("a[href='#{management_proposal_path(proposal1)}']", text: proposal1.title)
|
||||
expect(page).to have_link proposal1.title, href: management_proposal_path(proposal1)
|
||||
expect(page).to have_content(proposal1.summary)
|
||||
expect(page).to have_css("a[href='#{management_proposal_path(proposal2)}']", text: proposal2.title)
|
||||
expect(page).to have_link proposal2.title, href: management_proposal_path(proposal2)
|
||||
expect(page).to have_content(proposal2.summary)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ describe "Proposals" do
|
||||
featured_proposals.each do |featured_proposal|
|
||||
within("#featured-proposals") do
|
||||
expect(page).to have_content featured_proposal.title
|
||||
expect(page).to have_css("a[href='#{proposal_path(featured_proposal)}']")
|
||||
expect(page).to have_link href: proposal_path(featured_proposal)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ describe "Proposals" do
|
||||
within("#proposals") do
|
||||
expect(page).to have_content proposal.title
|
||||
expect(page).to have_content proposal.summary
|
||||
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.title)
|
||||
expect(page).to have_link proposal.title, href: proposal_path(proposal)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -130,8 +130,8 @@ describe "Tags" do
|
||||
|
||||
expect(page).to have_content "Debate updated successfully."
|
||||
within(".tags") do
|
||||
expect(page).to have_css("a", text: "Economía")
|
||||
expect(page).to have_css("a", text: "Hacienda")
|
||||
expect(page).to have_link "Economía"
|
||||
expect(page).to have_link "Hacienda"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -166,8 +166,8 @@ describe "Tags" do
|
||||
|
||||
expect(page).to have_content "Proposal updated successfully."
|
||||
within(".tags") do
|
||||
expect(page).to have_css("a", text: "Economía")
|
||||
expect(page).to have_css("a", text: "Hacienda")
|
||||
expect(page).to have_link "Economía"
|
||||
expect(page).to have_link "Hacienda"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -102,8 +102,8 @@ describe "Tags" do
|
||||
|
||||
expect(page).to have_content "Debate updated successfully."
|
||||
within(".tags") do
|
||||
expect(page).to have_css("a", text: "Economía")
|
||||
expect(page).to have_css("a", text: "Hacienda")
|
||||
expect(page).to have_link "Economía"
|
||||
expect(page).to have_link "Hacienda"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user