feature spec cover

This commit is contained in:
sebastiencarceles 2023-02-16 14:26:05 +01:00
parent 447ea1b9a8
commit 8b25503f7e
3 changed files with 15 additions and 2 deletions

View file

@ -26,5 +26,6 @@ shared_examples "the user has got a prefilled dossier, owned by themselves" do
expect(page).to have_field(type_de_champ_epci.libelle, with: epci_value.last)
expect(page).to have_field(type_de_champ_dossier_link.libelle, with: dossier_link_value)
expect(page).to have_selector("input[value='Vonnas (01540)']")
expect(page).to have_content(annuaire_education_value.last)
end
end

View file

@ -13,6 +13,7 @@ describe 'Prefilling a dossier (with a GET request):', js: true do
let(:type_de_champ_datetime) { create(:type_de_champ_datetime, procedure: procedure) }
let(:type_de_champ_multiple_drop_down_list) { create(:type_de_champ_multiple_drop_down_list, procedure: procedure) }
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
let(:type_de_champ_annuaire_education) { create(:type_de_champ_annuaire_education, procedure: procedure) }
let(:type_de_champ_dossier_link) { create(:type_de_champ_dossier_link, procedure: procedure) }
let(:type_de_champ_commune) { create(:type_de_champ_communes, procedure: procedure) }
let(:type_de_champ_repetition) { create(:type_de_champ_repetition, :with_types_de_champ, procedure: procedure) }
@ -36,6 +37,7 @@ describe 'Prefilling a dossier (with a GET request):', js: true do
let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle }
let(:text_repetition_value) { "First repetition text" }
let(:integer_repetition_value) { "42" }
let(:annuaire_education_value) { '0050009H' }
let(:entry_path) {
commencer_path(
@ -54,7 +56,8 @@ describe 'Prefilling a dossier (with a GET request):', js: true do
"champ_#{sub_type_de_champs_repetition.first.to_typed_id_for_query}": text_repetition_value,
"champ_#{sub_type_de_champs_repetition.second.to_typed_id_for_query}": integer_repetition_value
}
]
],
"champ_#{type_de_champ_annuaire_education.to_typed_id_for_query}" => annuaire_education_value
)
}
@ -71,6 +74,9 @@ describe 'Prefilling a dossier (with a GET request):', js: true do
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json'))
stub_request(:get, /https:\/\/data.education.gouv.fr\/api\/records\/1.0/)
.to_return(status: 200, body: File.read('spec/fixtures/files/api_education/annuaire_education.json'))
VCR.insert_cassette('api_geo_departements')
VCR.insert_cassette('api_geo_communes')
VCR.insert_cassette('api_geo_epcis')

View file

@ -13,6 +13,7 @@ describe 'Prefilling a dossier (with a POST request):', js: true do
let(:type_de_champ_datetime) { create(:type_de_champ_datetime, procedure: procedure) }
let(:type_de_champ_multiple_drop_down_list) { create(:type_de_champ_multiple_drop_down_list, procedure: procedure) }
let(:type_de_champ_epci) { create(:type_de_champ_epci, procedure: procedure) }
let(:type_de_champ_annuaire_education) { create(:type_de_champ_annuaire_education, procedure: procedure) }
let(:type_de_champ_dossier_link) { create(:type_de_champ_dossier_link, procedure: procedure) }
let(:type_de_champ_repetition) { create(:type_de_champ_repetition, :with_types_de_champ, procedure: procedure) }
let(:type_de_champ_commune) { create(:type_de_champ_communes, procedure: procedure) }
@ -36,6 +37,7 @@ describe 'Prefilling a dossier (with a POST request):', js: true do
let(:text_repetition_value) { "First repetition text" }
let(:integer_repetition_value) { "42" }
let(:dossier_link_value) { '42' }
let(:annuaire_education_value) { '0050009H' }
before do
allow(Rails).to receive(:cache).and_return(memory_store)
@ -50,6 +52,9 @@ describe 'Prefilling a dossier (with a POST request):', js: true do
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json'))
stub_request(:get, /https:\/\/data.education.gouv.fr\/api\/records\/1.0/)
.to_return(status: 200, body: File.read('spec/fixtures/files/api_education/annuaire_education.json'))
VCR.insert_cassette('api_geo_departements')
VCR.insert_cassette('api_geo_communes')
VCR.insert_cassette('api_geo_epcis')
@ -160,7 +165,8 @@ describe 'Prefilling a dossier (with a POST request):', js: true do
"champ_#{type_de_champ_multiple_drop_down_list.to_typed_id_for_query}" => multiple_drop_down_list_values,
"champ_#{type_de_champ_epci.to_typed_id_for_query}" => epci_value,
"champ_#{type_de_champ_dossier_link.to_typed_id_for_query}" => dossier_link_value,
"champ_#{type_de_champ_commune.to_typed_id_for_query}" => commune_value
"champ_#{type_de_champ_commune.to_typed_id_for_query}" => commune_value,
"champ_#{type_de_champ_annuaire_education.to_typed_id_for_query}" => annuaire_education_value
}.to_json
JSON.parse(session.response.body)["dossier_url"].gsub("http://www.example.com", "")
end