fix system spec

This commit is contained in:
simon lehericey 2022-04-08 15:27:35 +02:00
parent 4bbe2db668
commit 579578cf0c
2 changed files with 29 additions and 6 deletions

View file

@ -90,8 +90,22 @@ describe 'Inviting an expert:' do
let(:commentaire) { create(:commentaire, instructeur: instructeur, dossier: dossier) } let(:commentaire) { create(:commentaire, instructeur: instructeur, dossier: dossier) }
before do before do
champ.piece_justificative_file.attach(io: File.open(path), filename: "piece_justificative_0.pdf", content_type: "application/pdf") champ
dossier.champs_private << create(:champ_piece_justificative, :with_piece_justificative_file, private: true, dossier: dossier) .piece_justificative_file
.attach(io: File.open(path),
filename: "piece_justificative_0.pdf",
content_type: "application/pdf",
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE })
dossier.champs_private << create(:champ_piece_justificative, private: true, dossier: dossier)
dossier.champs_private
.first
.piece_justificative_file
.attach(io: File.open(path),
filename: "piece_justificative_0.pdf",
content_type: "application/pdf",
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE })
end end
scenario 'An Expert can download an archive containing attachments without any private champ, bill signature and operations logs' do scenario 'An Expert can download an archive containing attachments without any private champ, bill signature and operations logs' do
@ -102,7 +116,7 @@ describe 'Inviting an expert:' do
click_on '1 avis à donner' click_on '1 avis à donner'
click_on avis.dossier.user.email click_on avis.dossier.user.email
find(:css, '.attached').click find(:css, '[aria-controls=print-pj-menu]').click
click_on 'Télécharger le dossier et toutes ses pièces jointes' click_on 'Télécharger le dossier et toutes ses pièces jointes'
# For some reason, clicking the download link does not trigger the download in the headless browser ; # For some reason, clicking the download link does not trigger the download in the headless browser ;
# So we need to go to the download link directly # So we need to go to the download link directly

View file

@ -194,14 +194,18 @@ describe 'Instructing a dossier:', js: true do
before do before do
dossier.passer_en_instruction!(instructeur: instructeur) dossier.passer_en_instruction!(instructeur: instructeur)
champ.piece_justificative_file.attach(io: File.open(path), filename: "piece_justificative_0.pdf", content_type: "application/pdf") champ.piece_justificative_file
.attach(io: File.open(path),
filename: "piece_justificative_0.pdf",
content_type: "application/pdf",
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE })
log_in(instructeur.email, password) log_in(instructeur.email, password)
visit instructeur_dossier_path(procedure, dossier) visit instructeur_dossier_path(procedure, dossier)
end end
scenario 'A instructeur can download an archive containing a single attachment' do scenario 'A instructeur can download an archive containing a single attachment' do
find(:css, '.attached').click find(:css, '[aria-controls=print-pj-menu]').click
click_on 'Télécharger le dossier et toutes ses pièces jointes' click_on 'Télécharger le dossier et toutes ses pièces jointes'
# For some reason, clicking the download link does not trigger the download in the headless browser ; # For some reason, clicking the download link does not trigger the download in the headless browser ;
# So we need to go to the download link directly # So we need to go to the download link directly
@ -219,7 +223,12 @@ describe 'Instructing a dossier:', js: true do
end end
scenario 'A instructeur can download an archive containing several identical attachments' do scenario 'A instructeur can download an archive containing several identical attachments' do
commentaire.piece_jointe.attach(io: File.open(path), filename: "piece_justificative_0.pdf", content_type: "application/pdf") commentaire
.piece_jointe
.attach(io: File.open(path),
filename: "piece_justificative_0.pdf",
content_type: "application/pdf",
metadata: { virus_scan_result: ActiveStorage::VirusScanner::SAFE })
visit telecharger_pjs_instructeur_dossier_path(procedure, dossier) visit telecharger_pjs_instructeur_dossier_path(procedure, dossier)
DownloadHelpers.wait_for_download DownloadHelpers.wait_for_download