2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-09-10 23:53:54 +02:00
|
|
|
describe 'wcag rules for usager', chrome: true do
|
2024-05-31 09:41:31 +02:00
|
|
|
let(:procedure) { create(:procedure, :published, :with_service, :for_individual) }
|
2024-09-03 17:45:37 +02:00
|
|
|
let(:password) { SECURE_PASSWORD }
|
2020-06-26 15:55:26 +02:00
|
|
|
let(:litteraire_user) { create(:user, password: password) }
|
|
|
|
|
2024-05-31 09:41:31 +02:00
|
|
|
def test_external_links_have_title_says_it_opens_in_a_new_tab
|
|
|
|
links = page.all("a[target=_blank]")
|
|
|
|
expect(links.count).to be_positive
|
2022-11-29 15:57:32 +01:00
|
|
|
|
2024-05-31 09:41:31 +02:00
|
|
|
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"
|
2022-11-29 15:57:32 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-05-31 09:41:31 +02:00
|
|
|
def test_aria_label_do_not_mix_with_title_attribute
|
|
|
|
elements = page.all("[aria-label][title]")
|
|
|
|
elements.each do |element|
|
|
|
|
expect(element[:title]).to be_blank, "path=#{path}, element title=\"#{element[:title]}\" mixes aria-label and title attributes"
|
2022-12-01 15:33:54 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-05-31 09:41:31 +02:00
|
|
|
def test_expect_axe_clean_without_main_navigation
|
2023-10-30 15:37:04 +01:00
|
|
|
# On page without main navigation content (like anonymous home page),
|
|
|
|
# there are either a bug in axe, either dsfr markup is not conform to wcag2a.
|
|
|
|
# There is no issue on pages having a child navigation.
|
|
|
|
expect(page).to be_axe_clean.excluding("#modal-header__menu")
|
|
|
|
expect(page).to be_axe_clean.within("#modal-header__menu").skipping("aria-prohibited-attr")
|
|
|
|
end
|
|
|
|
|
2020-06-26 15:55:26 +02:00
|
|
|
context 'pages without the need to be logged in' do
|
2022-11-29 15:57:32 +01:00
|
|
|
before do
|
|
|
|
visit path
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
2022-11-29 15:57:32 +01:00
|
|
|
context 'homepage' do
|
|
|
|
let(:path) { root_path }
|
2024-05-31 09:41:31 +02:00
|
|
|
it 'pass wcag tests' do
|
|
|
|
test_external_links_have_title_says_it_opens_in_a_new_tab
|
|
|
|
test_aria_label_do_not_mix_with_title_attribute
|
|
|
|
test_expect_axe_clean_without_main_navigation
|
|
|
|
end
|
2022-11-29 15:57:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'sign_up page' do
|
|
|
|
let(:path) { new_user_registration_path }
|
2024-05-31 09:41:31 +02:00
|
|
|
it 'pass wcag tests' do
|
|
|
|
test_external_links_have_title_says_it_opens_in_a_new_tab
|
|
|
|
test_aria_label_do_not_mix_with_title_attribute
|
|
|
|
test_expect_axe_clean_without_main_navigation
|
|
|
|
end
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'account confirmation page' do
|
|
|
|
visit new_user_registration_path
|
|
|
|
|
|
|
|
fill_in :user_email, with: "some@email.com"
|
|
|
|
fill_in :user_password, with: "epeciusetuir"
|
|
|
|
|
|
|
|
perform_enqueued_jobs do
|
|
|
|
click_button 'Créer un compte'
|
2024-05-31 09:41:31 +02:00
|
|
|
test_expect_axe_clean_without_main_navigation
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-30 15:37:04 +01:00
|
|
|
context 'sign_up confirmation' do
|
2022-11-29 15:57:32 +01:00
|
|
|
let(:path) { user_confirmation_path("user[email]" => "some@email.com") }
|
|
|
|
|
2024-05-31 09:41:31 +02:00
|
|
|
it 'pass wcag tests' do
|
|
|
|
test_external_links_have_title_says_it_opens_in_a_new_tab
|
|
|
|
test_aria_label_do_not_mix_with_title_attribute
|
|
|
|
end
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
2022-11-29 15:57:32 +01:00
|
|
|
context 'sign_in page' do
|
|
|
|
let(:path) { new_user_session_path }
|
2024-05-31 09:41:31 +02:00
|
|
|
it 'pass wcag tests' do
|
|
|
|
test_external_links_have_title_says_it_opens_in_a_new_tab
|
|
|
|
test_aria_label_do_not_mix_with_title_attribute
|
|
|
|
test_expect_axe_clean_without_main_navigation
|
|
|
|
end
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
2022-11-29 15:57:32 +01:00
|
|
|
context 'contact page' do
|
|
|
|
let(:path) { contact_path }
|
2024-05-31 09:41:31 +02:00
|
|
|
it 'pass wcag tests' do
|
|
|
|
test_external_links_have_title_says_it_opens_in_a_new_tab
|
|
|
|
test_aria_label_do_not_mix_with_title_attribute
|
|
|
|
test_expect_axe_clean_without_main_navigation
|
|
|
|
end
|
2022-11-29 15:57:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'commencer page' do
|
|
|
|
let(:path) { commencer_path(path: procedure.path) }
|
2024-05-31 09:41:31 +02:00
|
|
|
it 'pass wcag tests' do
|
|
|
|
test_external_links_have_title_says_it_opens_in_a_new_tab
|
|
|
|
test_aria_label_do_not_mix_with_title_attribute
|
|
|
|
test_expect_axe_clean_without_main_navigation
|
|
|
|
end
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
2022-11-29 15:57:32 +01:00
|
|
|
|
2022-11-02 17:16:25 +01:00
|
|
|
scenario 'commencer page, help dropdown' do
|
|
|
|
visit commencer_path(path: procedure.reload.path)
|
|
|
|
|
2024-08-05 15:37:00 +02:00
|
|
|
page.find(".fr-header__body .help-btn").click
|
2024-05-31 09:41:31 +02:00
|
|
|
test_expect_axe_clean_without_main_navigation
|
2022-11-02 17:16:25 +01:00
|
|
|
end
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context "logged in, depot d'un dossier as individual" do
|
|
|
|
before do
|
|
|
|
login_as litteraire_user, scope: :user
|
|
|
|
visit commencer_path(path: procedure.reload.path)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'écran identité usager' do
|
|
|
|
click_on 'Commencer la démarche'
|
2021-08-13 15:39:03 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# with no surprise, there's a lot of work on this one
|
|
|
|
scenario "dépot d'un dossier" do
|
|
|
|
click_on 'Commencer la démarche'
|
|
|
|
|
2023-09-05 14:42:56 +02:00
|
|
|
find('label', text: 'Monsieur')
|
2023-11-28 12:43:43 +01:00
|
|
|
within('.individual-infos') do
|
|
|
|
fill_in('Prénom', with: 'prenom')
|
|
|
|
fill_in('Nom', with: 'nom')
|
|
|
|
end
|
2024-04-12 17:59:50 +02:00
|
|
|
within "#identite-form" do
|
|
|
|
click_on 'Continuer'
|
|
|
|
end
|
2020-06-26 15:55:26 +02:00
|
|
|
|
2022-10-06 10:32:38 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "logged in, depot d'un dossier entreprise" do
|
2024-05-31 09:41:31 +02:00
|
|
|
let(:procedure) { create(:procedure, :with_service, :published) }
|
2020-06-26 15:55:26 +02:00
|
|
|
|
|
|
|
before do
|
|
|
|
login_as litteraire_user, scope: :user
|
|
|
|
visit commencer_path(path: procedure.reload.path)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario "écran identification de l'entreprise" do
|
|
|
|
click_on 'Commencer la démarche'
|
2022-10-06 10:32:38 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-06 10:32:38 +02:00
|
|
|
context "logged in, avec des dossiers déposés" do
|
2020-06-26 15:55:26 +02:00
|
|
|
let(:dossier) { create(:dossier, procedure: procedure, user: litteraire_user) }
|
|
|
|
before do
|
|
|
|
login_as litteraire_user, scope: :user
|
|
|
|
end
|
|
|
|
|
2022-10-06 10:32:38 +02:00
|
|
|
scenario 'liste des dossiers sans dossiers' do
|
2020-06-26 15:55:26 +02:00
|
|
|
visit dossiers_path
|
2021-08-13 15:39:03 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
2022-10-06 10:33:39 +02:00
|
|
|
scenario 'liste des dossiers avec des dossiers' do
|
|
|
|
dossier
|
|
|
|
visit dossiers_path
|
|
|
|
expect(page).to be_axe_clean
|
2022-10-06 10:34:08 +02:00
|
|
|
page.find("#actions_menu_dossier_#{dossier.id}_button").click
|
|
|
|
expect(page).to be_axe_clean
|
|
|
|
end
|
|
|
|
|
2020-06-26 15:55:26 +02:00
|
|
|
scenario 'dossier' do
|
|
|
|
visit dossier_path(dossier)
|
2022-10-06 10:32:38 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'merci' do
|
|
|
|
visit merci_dossier_path(dossier)
|
2021-08-13 15:39:03 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'demande' do
|
|
|
|
visit demande_dossier_path(dossier)
|
2021-08-13 15:39:03 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
2022-10-06 10:32:38 +02:00
|
|
|
scenario 'messagerie avec des messages' do
|
|
|
|
create(:commentaire, dossier: dossier, instructeur: procedure.instructeurs.first, body: 'hello')
|
|
|
|
create(:commentaire, dossier: dossier, email: dossier.user.email, body: 'hello')
|
2020-06-26 15:55:26 +02:00
|
|
|
visit messagerie_dossier_path(dossier)
|
2021-08-13 15:39:03 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'modifier' do
|
|
|
|
visit modifier_dossier_path(dossier)
|
2022-10-06 10:32:38 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'brouillon' do
|
|
|
|
visit brouillon_dossier_path(dossier)
|
2022-10-06 10:32:38 +02:00
|
|
|
expect(page).to be_axe_clean
|
2020-06-26 15:55:26 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|