add specs

This commit is contained in:
Lisa Durand 2023-03-06 17:09:42 +01:00
parent 5b0570d289
commit 01afa998b6
2 changed files with 39 additions and 1 deletions

View file

@ -344,10 +344,11 @@ describe Experts::AvisController, type: :controller do
let(:invite_linked_dossiers) { nil }
let(:introduction_file) { fixture_file_upload('spec/fixtures/files/piece_justificative_0.pdf', 'application/pdf') }
let(:confidentiel) { false }
let(:question_label) { '' }
before do
Timecop.freeze(now)
post :create_avis, params: { id: previous_avis.id, procedure_id:, avis: { emails:, introduction:, experts_procedure:, confidentiel:, invite_linked_dossiers:, introduction_file: } }
post :create_avis, params: { id: previous_avis.id, procedure_id:, avis: { emails:, introduction:, experts_procedure:, confidentiel:, invite_linked_dossiers:, introduction_file:, question_label: } }
created_avis.reload
end
@ -373,6 +374,15 @@ describe Experts::AvisController, type: :controller do
end
end
context 'with a question' do
let(:question_label) { "question" }
it do
expect(created_avis.question_label).to eq('question')
expect(response).to redirect_to(instruction_expert_avis_path(previous_avis.procedure, previous_avis))
end
end
context 'ask review with attachment' do
let(:emails) { "[\"toto@totomail.com\"]" }

View file

@ -10,6 +10,7 @@ describe 'Inviting an expert:' do
let(:dossier) { create(:dossier, :en_construction, :with_dossier_link, procedure: procedure) }
let(:champ) { dossier.champs_public.first }
let(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) }
let(:avis_with_question) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true, question_label: 'Question ?') }
context 'when I dont already have an account' do
let(:password) { 'This is an expert password' }
@ -82,6 +83,33 @@ describe 'Inviting an expert:' do
expect(page).to have_text('1 avis donné')
end
scenario 'I can give a yes/no answer to a question' do
avis_with_question # create avis
login_as expert.user, scope: :user
visit expert_all_avis_path
expect(page).to have_text('1 avis à donner')
expect(page).to have_text('0 avis donnés')
click_on '1 avis à donner'
click_on avis.dossier.user.email
within('.tabs') { click_on 'Avis' }
expect(page).to have_text("Demandeur : #{avis.claimant.email}")
expect(page).to have_text('Question ?')
expect(page).to have_text('Cet avis est confidentiel')
choose 'oui'
fill_in 'avis_answer', with: 'Ma réponse dexpert.'
click_on 'Envoyer votre avis'
expect(page).to have_content('Votre réponse est enregistrée')
expect(page).to have_content('Ma réponse dexpert.')
expect(page).to have_content('oui')
within('.breadcrumbs') { click_on 'Avis' }
expect(page).to have_text('1 avis donné')
end
# scenario 'I can invite other experts' do
# end