This commit is contained in:
Lisa Durand 2023-11-28 12:43:43 +01:00 committed by Kara Diaby
parent 303230dd1d
commit 43f5f4e030
10 changed files with 124 additions and 109 deletions

View file

@ -3,7 +3,7 @@
%h2 Identité du demandeur
= render partial: "shared/dossiers/user_infos", locals: { user_deleted: @dossier.user_deleted?, email: @dossier.user_email_for(:display) }
= render partial: "shared/dossiers/user_infos", locals: { user_deleted: @dossier.user_deleted?, email: @dossier.user_email_for(:display), for_tiers: @dossier.for_tiers? }
- if @dossier.etablissement.present?
= render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: @dossier.etablissement, profile: 'instructeur' }

View file

@ -24,7 +24,7 @@
.fr-radio-rich__img
%span.fr-icon-parent-fill
%div{ "data-for-tiers-target" => "mandataireBlock" }
.mandataire-infos{ "data-for-tiers-target" => "mandataireBlock" }
.fr-alert.fr-alert--info.fr-mb-2w
%p.fr-notice__text= t('views.users.dossiers.identite.callout_text')
@ -32,43 +32,40 @@
%h2.fr-h4= t('views.users.dossiers.identite.self_title')
.fr-fieldset__element.fr-fieldset__element--short-text
= render Dsfr::InputComponent.new(form: f, attribute: :mandataire_first_name, opts: { "data-for-tiers-target" => "mandataireFirstName", id: 'mandataire_first_name' }) do |c|
- c.with_label do
= t('activerecord.attributes.dossier.mandataire_first_name')
= render Dsfr::InputComponent.new(form: f, attribute: :mandataire_first_name, opts: { "data-for-tiers-target" => "mandataireFirstName" })
.fr-fieldset__element.fr-fieldset__element--short-text
= render Dsfr::InputComponent.new(form: f, attribute: :mandataire_last_name, opts: { "data-for-tiers-target" => "mandataireLastName", id: 'mandataire_last_name' }) do |c|
- c.with_label do
= t('activerecord.attributes.dossier.mandataire_last_name')
= render Dsfr::InputComponent.new(form: f, attribute: :mandataire_last_name, opts: { "data-for-tiers-target" => "mandataireLastName" })
= f.fields_for :individual do |individual|
%fieldset.fr-fieldset
%legend.fr-fieldset__legend--regular.fr-fieldset__legend{ "data-for-tiers-target" => "mandataireTitle" }
%h2.fr-h4= t('views.users.dossiers.identite.self_title')
.individual-infos.mt-3
%fieldset.fr-fieldset
%legend.fr-fieldset__legend--regular.fr-fieldset__legend{ "data-for-tiers-target" => "mandataireTitle" }
%h2.fr-h4= t('views.users.dossiers.identite.self_title')
%legend.fr-fieldset__legend--regular.fr-fieldset__legend.hidden{ "data-for-tiers-target" => "beneficiaireTitle" }
%h2.fr-h4= t('views.users.dossiers.identite.beneficiaire_title')
.fr-fieldset__element
%fieldset.fr-fieldset
%legend.fr-fieldset__legend--regular.fr-fieldset__legend
= t('activerecord.attributes.individual.gender')
= render EditableChamp::AsteriskMandatoryComponent.new
.fr-fieldset__element
.fr-radio-group
= individual.radio_button :gender, Individual::GENDER_FEMALE, required: true, id: "identite_champ_radio_#{Individual::GENDER_FEMALE}"
%label.fr-label{ for: "identite_champ_radio_#{Individual::GENDER_FEMALE}" }
= Individual.human_attribute_name('gender.female')
.fr-fieldset__element
.fr-radio-group
= individual.radio_button :gender, Individual::GENDER_MALE, required: true, id: "identite_champ_radio_#{Individual::GENDER_MALE}"
%label.fr-label{ for: "identite_champ_radio_#{Individual::GENDER_MALE}" }
= Individual.human_attribute_name('gender.male')
%legend.fr-fieldset__legend--regular.fr-fieldset__legend.hidden{ "data-for-tiers-target" => "beneficiaireTitle" }
%h2.fr-h4= t('views.users.dossiers.identite.beneficiaire_title')
.fr-fieldset__element
%fieldset.fr-fieldset
%legend.fr-fieldset__legend--regular.fr-fieldset__legend
= t('activerecord.attributes.individual.gender')
= render EditableChamp::AsteriskMandatoryComponent.new
.fr-fieldset__element
.fr-radio-group
= individual.radio_button :gender, Individual::GENDER_FEMALE, required: true, id: "identite_champ_radio_#{Individual::GENDER_FEMALE}"
%label.fr-label{ for: "identite_champ_radio_#{Individual::GENDER_FEMALE}" }
= Individual.human_attribute_name('gender.female')
.fr-fieldset__element
.fr-radio-group
= individual.radio_button :gender, Individual::GENDER_MALE, required: true, id: "identite_champ_radio_#{Individual::GENDER_MALE}"
%label.fr-label{ for: "identite_champ_radio_#{Individual::GENDER_MALE}" }
= Individual.human_attribute_name('gender.male')
.fr-fieldset__element.fr-fieldset__element--short-text
= render Dsfr::InputComponent.new(form: individual, attribute: :prenom, opts: { autocomplete: 'given-name', id: 'indiv_first_name' })
.fr-fieldset__element.fr-fieldset__element--short-text
= render Dsfr::InputComponent.new(form: individual, attribute: :prenom, opts: { autocomplete: 'given-name' })
.fr-fieldset__element.fr-fieldset__element--short-text
= render Dsfr::InputComponent.new(form: individual, attribute: :nom, opts: { autocomplete: 'family-name', id: 'indiv_last_name' })
.fr-fieldset__element.fr-fieldset__element--short-text
= render Dsfr::InputComponent.new(form: individual, attribute: :nom, opts: { autocomplete: 'family-name' })
.width-100{ "data-for-tiers-target" => "beneficiaireNotificationBlock" }

View file

@ -3,8 +3,11 @@ shared_examples "the user has got a prefilled dossier, owned by themselves" do
expect(dossier.user).to eq(user)
expect(page).to have_current_path identite_dossier_path(procedure.dossiers.last)
expect(page).to have_field('Prénom', with: prenom_value)
expect(page).to have_field('Nom', with: nom_value)
within('.individual-infos') do
expect(page).to have_field('Prénom', with: prenom_value)
expect(page).to have_field('Nom', with: nom_value)
end
click_on 'Continuer'
expect(page).to have_current_path(brouillon_dossier_path(dossier))

View file

@ -122,8 +122,10 @@ describe 'wcag rules for usager', js: true do
click_on 'Commencer la démarche'
find('label', text: 'Monsieur')
fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'nom', visible: true)
within('.individual-infos') do
fill_in('Prénom', with: 'prenom')
fill_in('Nom', with: 'nom')
end
click_on 'Continuer'
expect(page).to be_axe_clean

View file

@ -267,8 +267,10 @@ describe 'fetch API Particulier Data', js: true do
click_on 'Commencer la démarche'
find('label', text: 'Monsieur').click
fill_in('indiv_first_name', with: 'prenom', visible: true)
fill_in('indiv_last_name', with: 'nom', visible: true)
within('.individual-infos') do
fill_in('Prénom', with: 'prenom')
fill_in('Nom', with: 'nom')
end
click_button('Continuer')
@ -325,9 +327,10 @@ describe 'fetch API Particulier Data', js: true do
click_on 'Commencer la démarche'
find('label', text: 'Monsieur').click
fill_in('indiv_first_name', with: 'Georges', visible: true)
fill_in('indiv_last_name', with: 'Moustaki', visible: true)
within('.individual-infos') do
fill_in('Prénom', with: 'Georges')
fill_in('Nom', with: 'Moustaki')
end
click_button('Continuer')
fill_in "Identifiant", with: 'wrong code'
@ -398,9 +401,10 @@ describe 'fetch API Particulier Data', js: true do
click_on 'Commencer la démarche'
find('label', text: 'Madame').click
fill_in('indiv_first_name', with: 'Dubois', visible: true)
fill_in('indiv_last_name', with: 'Angela Claire Louise', visible: true)
within('.individual-infos') do
fill_in('Prénom', with: 'Angela Claire Louise')
fill_in('Nom', with: 'Dubois')
end
click_button('Continuer')
fill_in "INE", with: 'wrong code'
@ -461,9 +465,10 @@ describe 'fetch API Particulier Data', js: true do
click_on 'Commencer la démarche'
find('label', text: 'Madame').click
fill_in('indiv_last_name', with: 'FERRI', visible: true)
fill_in('indiv_first_name', with: 'Karine', visible: true)
within('.individual-infos') do
fill_in('Prénom', with: 'Karine')
fill_in('Nom', with: 'FERRI')
end
click_button('Continuer')
fill_in 'Le numéro fiscal', with: numero_fiscal

View file

@ -1,4 +1,4 @@
describe 'Creating a new dossier:' do
describe 'Creating a new dossier:', js: true do
let(:user) { create(:user) }
let(:siret) { '41816609600051' }
let(:siren) { siret[0...9] }
@ -22,8 +22,8 @@ describe 'Creating a new dossier:' do
expect(page).to have_title(libelle)
find('label', text: 'Monsieur').click
fill_in('indiv_first_name', with: 'prenom')
fill_in('indiv_last_name', with: 'nom')
fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'nom', visible: true)
end
shared_examples 'the user can create a new draft' do
@ -31,26 +31,20 @@ describe 'Creating a new dossier:' do
click_button('Continuer')
expect(page).to have_current_path(brouillon_dossier_path(procedure.dossiers.last))
expect(user.dossiers.first.individual.birthdate).to eq(expected_birthday)
end
end
context 'when the birthday is asked' do
let(:ask_birthday) { true }
let(:expected_birthday) { Date.new(1987, 10, 14) }
let(:expected_birthday) { Date.new(1987, 12, 10) }
before do
fill_in 'Date de naissance', with: birthday_format
end
context 'when the browser supports `type=date` input fields' do
let(:birthday_format) { '1987-10-14' }
it_behaves_like 'the user can create a new draft'
end
context 'when the browser does not support `type=date` input fields' do
let(:birthday_format) { '1987-10-14' }
context 'when the birthday is asked' do
let(:birthday_format) { '12-10-1987' }
it_behaves_like 'the user can create a new draft'
end
end
@ -60,43 +54,49 @@ describe 'Creating a new dossier:' do
let(:expected_birthday) { nil }
it_behaves_like 'the user can create a new draft'
end
end
context 'when identifying as mandataire' do
let(:libelle) { "[title] with characters to escape : '@*^$" }
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, ask_birthday: ask_birthday, libelle: libelle) }
let(:ask_birthday) { false }
let(:expected_birthday) { nil }
context 'when individual fill dossier for a tiers' do
it 'completes the form with email notification method selected' do
find('label', text: 'Pour un bénéficiaire : membre de la famille, proche, mandant...').click
before do
visit commencer_path(path: procedure.path)
click_on 'Commencer la démarche'
within('.mandataire-infos') do
fill_in('Prénom', with: 'John')
fill_in('Nom', with: 'Doe')
end
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last)
expect(page).to have_title(libelle)
find('label', text: 'Monsieur').click
find('#radio-tiers-manage').click
fill_in('mandataire_first_name', with: 'John')
fill_in('mandataire_last_name', with: 'Doe')
within('.individual-infos') do
fill_in('Prénom', with: 'prenom')
fill_in('Nom', with: 'nom')
end
find('label', text: 'Monsieur').click
fill_in('indiv_first_name', with: 'prenom')
fill_in('indiv_last_name', with: 'nom')
end
find('label', text: 'Par e-mail').click
fill_in('dossier_individual_attributes_email', with: 'prenom.nom@mail.com')
click_button('Continuer')
expect(procedure.dossiers.last.individual.notification_method == 'email')
expect(page).to have_current_path(brouillon_dossier_path(procedure.dossiers.last))
end
it 'completes the form with email notification method selected' do
find('#notification_method_email').click
fill_in('dossier_individual_attributes_email', with: 'prenom.nom@mail.com')
click_button('Continuer')
expect(procedure.dossiers.last.individual.notification_method == 'email')
expect(page).to have_current_path(brouillon_dossier_path(procedure.dossiers.last))
end
it 'completes the form with no notification method selected' do
find('label', text: 'Pour un bénéficiaire : membre de la famille, proche, mandant...').click
it 'completes the form with no notification method selected' do
find('#notification_method_no_notification').click
click_button('Continuer')
expect(procedure.dossiers.last.individual.notification_method.empty?)
expect(page).to have_current_path(brouillon_dossier_path(procedure.dossiers.last))
within('.mandataire-infos') do
fill_in('Prénom', with: 'John')
fill_in('Nom', with: 'Doe')
end
find('label', text: 'Monsieur').click
within('.individual-infos') do
fill_in('Prénom', with: 'prenom')
fill_in('Nom', with: 'nom')
end
find('label', text: 'Pas de notification').click
click_button('Continuer')
expect(procedure.dossiers.last.individual.notification_method.empty?)
expect(page).to have_current_path(brouillon_dossier_path(procedure.dossiers.last))
end
end
end

View file

@ -75,8 +75,10 @@ describe 'dropdown list with other option activated', js: true do
def fill_individual
find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'Nom', visible: true)
within('.individual-infos') do
fill_in('Prénom', with: 'prenom')
fill_in('Nom', with: 'nom')
end
click_on 'Continuer'
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
end

View file

@ -81,8 +81,10 @@ describe 'linked dropdown lists' do
def fill_individual
find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'nom', visible: true)
within('.individual-infos') do
fill_in('Prénom', with: 'prenom')
fill_in('Nom', with: 'nom')
end
click_on 'Continuer'
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
end

View file

@ -8,6 +8,7 @@ describe 'user access to the list of their dossiers', js: true do
let!(:dossier_refuse) { create(:dossier, :refuse, user: user) }
let!(:dossier_a_corriger) { create(:dossier_correction, dossier: dossier_en_construction_2) }
let!(:dossier_archived) { create(:dossier, :en_instruction, :archived, user: user) }
let!(:dossier_for_tiers) { create(:dossier, :en_instruction, :for_tiers_with_notification, user: user) }
let(:dossiers_per_page) { 25 }
let(:last_updated_dossier) { dossier_en_construction }
@ -30,7 +31,7 @@ describe 'user access to the list of their dossiers', js: true do
expect(page).to have_content(dossier_en_construction.procedure.libelle)
expect(page).to have_content(dossier_en_instruction.procedure.libelle)
expect(page).to have_content(dossier_archived.procedure.libelle)
expect(page).to have_text('5 en cours')
expect(page).to have_text('6 en cours')
expect(page).to have_text('2 traités')
end
@ -52,25 +53,26 @@ describe 'user access to the list of their dossiers', js: true do
scenario 'the user can navigate through the other pages' do
expect(page).not_to have_link(dossier_en_instruction.procedure.libelle)
page.click_link("Suivant")
page.click_link("Suivant")
expect(page).to have_link(dossier_en_instruction.procedure.libelle)
expect(page).to have_text('5 en cours')
expect(page).to have_text('6 en cours')
expect(page).to have_text('2 traités')
end
end
context 'when the dossier is for_tiers' do
let(:dossier) { create(:dossier, :for_tiers_without_notification, user: user) }
let(:individual) { dossier.individual }
let(:individual) { dossier_for_tiers.individual }
it 'displays the name of the mandataire' do
expect(page).to have_content("#{individual.prenom} #{individual.nom}, dossier rempli par le mandataire #{dossier.mandataire_full_name}")
expect(page).to have_content("#{individual.prenom} #{individual.nom}, dossier rempli par le mandataire #{dossier_for_tiers.mandataire_full_name}")
end
end
context 'when user uses filter' do
scenario 'user filters state on tab "en-cours"' do
expect(page).to have_text('5 en cours')
expect(page).to have_text('6 en cours')
expect(page).to have_text('2 traités')
expect(page).to have_text('5 sur 5 dossiers')
expect(page).to have_text('6 sur 6 dossiers')
click_on('Sélectionner un filtre')
expect(page).to have_select 'Statut', selected: 'Sélectionner un statut', options: ['Sélectionner un statut', 'Brouillon', 'En construction', 'En instruction', 'À corriger']
@ -90,7 +92,7 @@ describe 'user access to the list of their dossiers', js: true do
scenario 'user filters state on tab "traité"' do
visit dossiers_path(statut: 'traites')
expect(page).to have_text('5 en cours')
expect(page).to have_text('6 en cours')
expect(page).to have_text('2 traités')
expect(page).to have_text('2 sur 2 dossiers')
@ -110,11 +112,11 @@ describe 'user access to the list of their dossiers', js: true do
scenario 'user filters by created_at' do
dossier_en_construction.update!(created_at: Date.yesterday)
expect(page).to have_text('5 sur 5 dossiers')
expect(page).to have_text('6 sur 6 dossiers')
click_on('Sélectionner un filtre')
fill_in 'from_created_at_date', with: Date.today
click_on('Appliquer les filtres')
expect(page).to have_text('4 sur 4 dossiers')
expect(page).to have_text('5 sur 5 dossiers')
end
scenario 'user uses multiple filters' do
@ -122,11 +124,11 @@ describe 'user access to the list of their dossiers', js: true do
expect(page).to have_select 'Statut', selected: 'Sélectionner un statut', options: ['Sélectionner un statut', 'Brouillon', 'En construction', 'En instruction', 'À corriger']
expect(page).to have_text('5 sur 5 dossiers')
expect(page).to have_text('6 sur 6 dossiers')
click_on('Sélectionner un filtre')
fill_in 'from_created_at_date', with: Date.today
click_on('Appliquer les filtres')
expect(page).to have_text('4 sur 4 dossiers')
expect(page).to have_text('5 sur 5 dossiers')
expect(page).to have_text('1 filtre actif')
click_on('Sélectionner un filtre')
@ -141,7 +143,7 @@ describe 'user access to the list of their dossiers', js: true do
expect(page).to have_text('1 dossier')
expect(page).to have_text('3 filtres actifs')
click_on('3 filtres actifs')
expect(page).to have_text('5 sur 5 dossiers')
expect(page).to have_text('6 sur 6 dossiers')
expect(page).not_to have_text('5 filtres actifs')
end
end
@ -283,7 +285,7 @@ describe 'user access to the list of their dossiers', js: true do
describe "filter by procedure" do
context "when dossiers are on different procedures" do
it "can filter by procedure" do
expect(page).to have_text('5 en cours')
expect(page).to have_text('6 en cours')
expect(page).to have_text('2 traités')
expect(page).to have_select('procedure_id', selected: 'Toutes les démarches')
select dossier_brouillon.procedure.libelle, from: 'procedure_id'

View file

@ -10,8 +10,10 @@ describe 'users/dossiers/identite', type: :view do
subject! { render }
it 'has identity fields' do
expect(rendered).to have_field(id: 'indiv_first_name')
expect(rendered).to have_field(id: 'indiv_last_name')
within('.individual-infos') do
expect(rendered).to have_field(id: 'Prenom')
expect(rendered).to have_field(id: 'Nom')
end
end
context 'when the demarche asks for the birthdate' do