2021-10-26 11:44:53 +02:00
|
|
|
|
require 'system/users/dossier_shared_examples.rb'
|
2018-09-24 16:25:34 +02:00
|
|
|
|
|
2018-08-07 16:32:11 +02:00
|
|
|
|
describe 'Dossier details:' do
|
|
|
|
|
let(:user) { create(:user) }
|
2018-09-24 15:54:46 +02:00
|
|
|
|
let(:procedure) { create(:simple_procedure) }
|
2020-01-07 17:47:22 +01:00
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, :with_individual, :with_commentaires, user: user, procedure: procedure) }
|
2018-08-07 16:32:11 +02:00
|
|
|
|
|
|
|
|
|
before do
|
2018-09-25 11:24:41 +02:00
|
|
|
|
visit_dossier dossier
|
2018-08-07 16:32:11 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-08-10 16:17:19 +02:00
|
|
|
|
scenario 'the user can see the summary of the dossier status' do
|
2018-08-07 16:32:11 +02:00
|
|
|
|
expect(page).to have_current_path(dossier_path(dossier))
|
|
|
|
|
expect(page).to have_content(dossier.id)
|
2018-08-10 16:17:19 +02:00
|
|
|
|
expect(page).to have_selector('.status-explanation')
|
2018-09-11 18:40:10 +02:00
|
|
|
|
expect(page).to have_text(dossier.commentaires.last.body)
|
2018-08-07 16:32:11 +02:00
|
|
|
|
end
|
|
|
|
|
|
2022-05-18 14:27:26 +02:00
|
|
|
|
scenario 'the user can download a deposit receipt' do
|
|
|
|
|
visit dossier_path(dossier)
|
|
|
|
|
expect(page).to have_link("Obtenir une attestation de dépôt de dossier", href: %r{dossiers/#{dossier.id}/papertrail.pdf})
|
2022-05-04 10:48:57 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-09-18 17:45:24 +02:00
|
|
|
|
describe "the user can see the mean time they are expected to wait" do
|
2020-07-15 11:08:15 +02:00
|
|
|
|
context "when the dossier is in construction" do
|
2019-04-10 16:29:03 +02:00
|
|
|
|
it "displays the estimated wait duration" do
|
2023-11-28 17:04:19 +01:00
|
|
|
|
allow_any_instance_of(Procedure).to receive(:stats_usual_traitement_time).and_return([1.day, 1.day, 1.day])
|
2018-09-25 11:24:41 +02:00
|
|
|
|
visit dossier_path(dossier)
|
2023-11-28 17:04:19 +01:00
|
|
|
|
expect(page).to have_text("Dans le meilleur des cas, le délai d’instruction est : 1 jour")
|
2018-09-18 17:47:41 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-07-15 11:08:15 +02:00
|
|
|
|
context "when the dossier is in instruction" do
|
2020-01-07 17:47:22 +01:00
|
|
|
|
let(:dossier) { create(:dossier, :en_instruction, :with_individual, :with_commentaires, user: user, procedure: procedure) }
|
2018-09-18 17:45:24 +02:00
|
|
|
|
|
2019-04-10 16:29:03 +02:00
|
|
|
|
it "displays the estimated wait duration" do
|
2023-11-28 17:04:19 +01:00
|
|
|
|
allow_any_instance_of(Procedure).to receive(:stats_usual_traitement_time).and_return([1.day, 1.day, 1.day])
|
2018-09-25 11:24:41 +02:00
|
|
|
|
visit dossier_path(dossier)
|
2023-11-28 17:04:19 +01:00
|
|
|
|
expect(page).to have_text("Dans le meilleur des cas, le délai d’instruction est : 1 jour")
|
2018-09-18 17:45:24 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-10-02 14:50:53 +02:00
|
|
|
|
scenario 'the user is redirected from old URLs' do
|
|
|
|
|
visit "/users/dossiers/#{dossier.id}/recapitulatif"
|
|
|
|
|
expect(page).to have_current_path(dossier_path(dossier))
|
|
|
|
|
end
|
|
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
|
context 'with js', js: true do
|
2022-09-08 11:26:18 +02:00
|
|
|
|
it_behaves_like 'the user can edit the submitted demande'
|
|
|
|
|
it_behaves_like 'the user can send messages to the instructeur'
|
|
|
|
|
end
|
2018-09-05 13:56:12 +02:00
|
|
|
|
|
2018-08-07 16:32:11 +02:00
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def visit_dossier(dossier)
|
|
|
|
|
visit dossier_path(dossier)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(new_user_session_path)
|
|
|
|
|
fill_in 'user_email', with: user.email
|
|
|
|
|
fill_in 'user_password', with: user.password
|
|
|
|
|
click_on 'Se connecter'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(dossier_path(dossier))
|
|
|
|
|
end
|
|
|
|
|
end
|