2024-04-29 00:17:15 +02:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2023-03-06 15:51:08 +01:00
|
|
|
|
describe 'shared/_procedure_description', type: :view do
|
2023-01-31 18:52:47 +01:00
|
|
|
|
let(:estimated_duration_visible) { true }
|
|
|
|
|
let(:procedure) { create(:procedure, :published, :with_service, estimated_duration_visible:) }
|
2020-05-27 11:25:43 +02:00
|
|
|
|
|
|
|
|
|
subject { render partial: 'shared/procedure_description', locals: { procedure: procedure } }
|
|
|
|
|
|
|
|
|
|
it 'renders the view' do
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).to have_selector('.procedure-logos')
|
|
|
|
|
expect(rendered).to have_text(procedure.libelle)
|
|
|
|
|
expect(rendered).to have_text(procedure.description)
|
2022-05-31 16:58:03 +02:00
|
|
|
|
expect(rendered).to have_text('Temps de remplissage estimé')
|
2023-06-01 14:54:58 +02:00
|
|
|
|
expect(rendered).not_to have_text('Quelles sont les pièces justificatives à fournir')
|
2023-06-06 10:38:46 +02:00
|
|
|
|
expect(rendered).not_to have_text('Qu’est-ce que le cadre législatif « silence vaut accord » ?')
|
2020-05-27 11:25:43 +02:00
|
|
|
|
end
|
|
|
|
|
|
2023-01-31 18:52:47 +01:00
|
|
|
|
context 'procedure with estimated duration not visible' do
|
|
|
|
|
let(:estimated_duration_visible) { false }
|
|
|
|
|
it 'hides the estimated duration' do
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).not_to have_text('Temps de remplissage estimé')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-27 11:25:43 +02:00
|
|
|
|
it 'does not show empty date limite' do
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).not_to have_text('Date limite')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when the procedure has an auto_archive date' do
|
|
|
|
|
let(:procedure) { create(:procedure, :published, :with_service, :with_auto_archive) }
|
|
|
|
|
it 'shows the auto_archive_on' do
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).to have_text('Date limite')
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-06-01 14:54:58 +02:00
|
|
|
|
|
2023-07-06 13:23:32 +02:00
|
|
|
|
context 'when procedure has notice' do
|
|
|
|
|
let(:procedure) { create(:procedure, :published, :with_notice) }
|
|
|
|
|
before do
|
|
|
|
|
allow(view).to receive(:administrateur_signed_in?).and_return(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'shows a link to the notice' do
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).to have_link("Télécharger le guide de la démarche")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2023-07-27 16:46:20 +02:00
|
|
|
|
context 'when procedure has usual_traitement_time' do
|
2023-11-24 14:40:05 +01:00
|
|
|
|
before do
|
2023-11-28 17:04:19 +01:00
|
|
|
|
allow(procedure).to receive(:stats_usual_traitement_time).and_return([1.day, 1.day, 1.day])
|
2023-11-24 14:40:05 +01:00
|
|
|
|
end
|
2023-07-27 16:46:20 +02:00
|
|
|
|
|
|
|
|
|
it 'shows a usual traitement text' do
|
|
|
|
|
subject
|
2023-11-14 18:33:01 +01:00
|
|
|
|
expect(rendered).to have_text("Quels sont les délais d'instruction pour cette démarche ?")
|
2023-11-28 17:04:19 +01:00
|
|
|
|
expect(rendered).to have_text("Dans le meilleur des cas, le délai d’instruction est : 1 jour.")
|
2023-07-27 16:46:20 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2023-06-01 14:54:58 +02:00
|
|
|
|
context 'when the procedure has pieces jointes' do
|
2024-01-23 09:52:20 +01:00
|
|
|
|
let(:procedure) { create(:procedure, :draft, types_de_champ_public: [{ type: :titre_identite }, { type: :piece_justificative }, { type: :siret }]) }
|
2023-06-01 14:54:58 +02:00
|
|
|
|
it 'shows the pieces jointes list for draft procedure' do
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).to have_text('Quelles sont les pièces justificatives à fournir')
|
|
|
|
|
expect(rendered).to have_text('Libelle du champ')
|
|
|
|
|
expect(rendered).to have_selector('.pieces_jointes ul li', count: 2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'shows the pieces jointes list for published procedure' do
|
|
|
|
|
procedure.publish!
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).to have_text('Quelles sont les pièces justificatives à fournir')
|
|
|
|
|
expect(rendered).to have_text('Libelle du champ')
|
|
|
|
|
expect(rendered).to have_selector('.pieces_jointes ul li', count: 2)
|
|
|
|
|
end
|
2023-06-22 09:50:38 +02:00
|
|
|
|
|
|
|
|
|
it 'shows the manual description pieces jointes list if admin filled one' do
|
|
|
|
|
procedure.update!(description_pj: 'une description des pj manuelle')
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).to have_text('Quelles sont les pièces justificatives à fournir')
|
|
|
|
|
expect(rendered).to have_text('une description des pj manuelle')
|
|
|
|
|
end
|
2023-06-01 14:54:58 +02:00
|
|
|
|
end
|
2023-06-06 10:38:46 +02:00
|
|
|
|
|
|
|
|
|
context 'when the procedure is sva' do
|
2023-10-10 20:26:39 +02:00
|
|
|
|
before { travel_to Time.zone.local(2023, 1, 1) }
|
2023-06-06 10:38:46 +02:00
|
|
|
|
let(:procedure) { create(:procedure, :published, :sva) }
|
2023-06-28 16:34:50 +02:00
|
|
|
|
|
2023-06-06 10:38:46 +02:00
|
|
|
|
it 'shows an explanation text' do
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).to have_text('Cette démarche applique le « Silence Vaut Accord »')
|
2023-06-28 16:34:50 +02:00
|
|
|
|
expect(rendered).to have_text('dans les 2 mois')
|
|
|
|
|
expect(rendered).to have_text("2 mars 2023")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when unit is weeks' do
|
|
|
|
|
before {
|
|
|
|
|
procedure.sva_svr["unit"] = "weeks"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it 'shows an human period' do
|
|
|
|
|
subject
|
|
|
|
|
expect(rendered).to have_text('dans les 2 semaines')
|
|
|
|
|
expect(rendered).to have_text("16 janvier 2023")
|
|
|
|
|
end
|
2023-06-06 10:38:46 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2023-11-24 14:40:05 +01:00
|
|
|
|
|
|
|
|
|
context 'caching', caching: true do
|
|
|
|
|
it "works" do
|
2024-04-26 15:36:30 +02:00
|
|
|
|
expect(procedure).to receive(:public_wrapped_partionned_pjs).once
|
2023-11-24 14:40:05 +01:00
|
|
|
|
2.times { render partial: 'shared/procedure_description', locals: { procedure: } }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'cache_key depends of revision' do
|
|
|
|
|
render partial: 'shared/procedure_description', locals: { procedure: }
|
|
|
|
|
expect(rendered).not_to have_text('new pj')
|
|
|
|
|
|
|
|
|
|
procedure.draft_revision.add_type_de_champ(type_champ: :piece_justificative, libelle: 'new pj')
|
|
|
|
|
procedure.publish_revision!
|
|
|
|
|
|
|
|
|
|
render partial: 'shared/procedure_description', locals: { procedure: }
|
|
|
|
|
expect(rendered).to have_text('new pj')
|
|
|
|
|
end
|
2024-02-15 18:45:13 +01:00
|
|
|
|
|
|
|
|
|
context 'draft procedure' do
|
|
|
|
|
let(:procedure) { create(:procedure, :draft) }
|
|
|
|
|
|
|
|
|
|
it 'respect revision changes on brouillon' do
|
|
|
|
|
render partial: 'shared/procedure_description', locals: { procedure: }
|
|
|
|
|
expect(rendered).not_to have_text('new pj')
|
|
|
|
|
|
|
|
|
|
procedure.draft_revision.add_type_de_champ(type_champ: :piece_justificative, libelle: 'new pj')
|
|
|
|
|
|
|
|
|
|
render partial: 'shared/procedure_description', locals: { procedure: }
|
|
|
|
|
expect(rendered).to have_text('new pj')
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-11-24 14:40:05 +01:00
|
|
|
|
end
|
2020-05-27 11:25:43 +02:00
|
|
|
|
end
|