test(a11y): verify on basic pages external link say it will open a new tab

This commit is contained in:
Colin Darie 2022-11-29 15:57:32 +01:00
parent 8c16eb1543
commit acdd0b2350

View file

@ -7,15 +7,32 @@ describe 'wcag rules for usager', js: true do
procedure.active_revision.types_de_champ_public.find { |tdc| tdc.type_champ == TypeDeChamp.type_champs.fetch(:carte) }.destroy procedure.active_revision.types_de_champ_public.find { |tdc| tdc.type_champ == TypeDeChamp.type_champs.fetch(:carte) }.destroy
end end
shared_examples "external links have title says it opens in a new tab" do
it do
links = page.all("a[target=_blank]")
expect(links.count).to be_positive
links.each do |link|
expect(link[:title]).to include("Nouvel onglet"), "link #{link[:href]} does not have title mentioning it opens in a new tab"
end
end
end
context 'pages without the need to be logged in' do context 'pages without the need to be logged in' do
scenario 'homepage' do before do
visit root_path visit path
expect(page).to be_axe_clean
end end
scenario 'sign_up page' do context 'homepage' do
visit new_user_registration_path let(:path) { root_path }
expect(page).to be_axe_clean it { expect(page).to be_axe_clean }
it_behaves_like "external links have title says it opens in a new tab"
end
context 'sign_up page' do
let(:path) { new_user_registration_path }
it { expect(page).to be_axe_clean }
it_behaves_like "external links have title says it opens in a new tab"
end end
scenario 'account confirmation page' do scenario 'account confirmation page' do
@ -30,20 +47,30 @@ describe 'wcag rules for usager', js: true do
end end
end end
scenario 'sign_in page' do context 'sign_upc confirmation' do
visit new_user_session_path let(:path) { user_confirmation_path("user[email]" => "some@email.com") }
expect(page).to be_axe_clean.excluding '#user_email'
it_behaves_like "external links have title says it opens in a new tab"
end end
scenario 'contact page' do context 'sign_in page' do
visit contact_path let(:path) { new_user_session_path }
expect(page).to be_axe_clean it { expect(page).to be_axe_clean.excluding '#user_email' }
it_behaves_like "external links have title says it opens in a new tab"
end end
scenario 'commencer page' do context 'contact page' do
visit commencer_path(path: procedure.reload.path) let(:path) { contact_path }
expect(page).to be_axe_clean it { expect(page).to be_axe_clean }
it_behaves_like "external links have title says it opens in a new tab"
end end
context 'commencer page' do
let(:path) { commencer_path(path: procedure.path) }
it { expect(page).to be_axe_clean }
it_behaves_like "external links have title says it opens in a new tab"
end
scenario 'commencer page, help dropdown' do scenario 'commencer page, help dropdown' do
visit commencer_path(path: procedure.reload.path) visit commencer_path(path: procedure.reload.path)