feature spec cover

This commit is contained in:
sebastiencarceles 2023-02-24 10:49:11 +01:00
parent da6ce0f528
commit bd1bed940c
3 changed files with 12 additions and 1 deletions

View file

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

View file

@ -11,6 +11,7 @@ describe 'Prefilling a dossier (with a GET request):' do
let(:type_de_champ_datetime) { create(:type_de_champ_datetime, procedure: procedure) } 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_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_epci) { create(:type_de_champ_epci, 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) } let(:type_de_champ_repetition) { create(:type_de_champ_repetition, :with_types_de_champ, procedure: procedure) }
let(:text_value) { "My Neighbor Totoro is the best movie ever" } let(:text_value) { "My Neighbor Totoro is the best movie ever" }
let(:phone_value) { "invalid phone value" } let(:phone_value) { "invalid phone value" }
@ -22,6 +23,7 @@ describe 'Prefilling a dossier (with a GET request):' do
] ]
} }
let(:epci_value) { ['01', '200029999'] } let(:epci_value) { ['01', '200029999'] }
let(:commune_value) { ['01', '01457'] } # Vonnas (01540)
let(:sub_type_de_champs_repetition) { procedure.active_revision.children_of(type_de_champ_repetition) } let(:sub_type_de_champs_repetition) { procedure.active_revision.children_of(type_de_champ_repetition) }
let(:text_repetition_libelle) { sub_type_de_champs_repetition.first.libelle } let(:text_repetition_libelle) { sub_type_de_champs_repetition.first.libelle }
let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle } let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle }
@ -36,6 +38,7 @@ describe 'Prefilling a dossier (with a GET request):' do
"champ_#{type_de_champ_datetime.to_typed_id_for_query}" => datetime_value, "champ_#{type_de_champ_datetime.to_typed_id_for_query}" => datetime_value,
"champ_#{type_de_champ_multiple_drop_down_list.to_typed_id_for_query}" => multiple_drop_down_list_values, "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_epci.to_typed_id_for_query}" => epci_value,
"champ_#{type_de_champ_commune.to_typed_id_for_query}" => commune_value,
"champ_#{type_de_champ_repetition.to_typed_id_for_query}" => [ "champ_#{type_de_champ_repetition.to_typed_id_for_query}" => [
{ {
"champ_#{sub_type_de_champs_repetition.first.to_typed_id_for_query}": text_repetition_value, "champ_#{sub_type_de_champs_repetition.first.to_typed_id_for_query}": text_repetition_value,
@ -50,11 +53,13 @@ describe 'Prefilling a dossier (with a GET request):' do
Rails.cache.clear Rails.cache.clear
VCR.insert_cassette('api_geo_departements') VCR.insert_cassette('api_geo_departements')
VCR.insert_cassette('api_geo_communes')
VCR.insert_cassette('api_geo_epcis') VCR.insert_cassette('api_geo_epcis')
end end
after do after do
VCR.eject_cassette('api_geo_departements') VCR.eject_cassette('api_geo_departements')
VCR.eject_cassette('api_geo_communes')
VCR.eject_cassette('api_geo_epcis') VCR.eject_cassette('api_geo_epcis')
end end

View file

@ -12,6 +12,7 @@ describe 'Prefilling a dossier (with a POST request):' do
let(:type_de_champ_multiple_drop_down_list) { create(:type_de_champ_multiple_drop_down_list, 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_epci) { create(:type_de_champ_epci, procedure: procedure) }
let(:type_de_champ_repetition) { create(:type_de_champ_repetition, :with_types_de_champ, 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) }
let(:text_value) { "My Neighbor Totoro is the best movie ever" } let(:text_value) { "My Neighbor Totoro is the best movie ever" }
let(:phone_value) { "invalid phone value" } let(:phone_value) { "invalid phone value" }
let(:datetime_value) { "2023-02-01T10:32" } let(:datetime_value) { "2023-02-01T10:32" }
@ -22,6 +23,7 @@ describe 'Prefilling a dossier (with a POST request):' do
] ]
} }
let(:epci_value) { ['01', '200029999'] } let(:epci_value) { ['01', '200029999'] }
let(:commune_value) { ['01', '01457'] } # Vonnas (01540)
let(:sub_type_de_champs_repetition) { procedure.active_revision.children_of(type_de_champ_repetition) } let(:sub_type_de_champs_repetition) { procedure.active_revision.children_of(type_de_champ_repetition) }
let(:text_repetition_libelle) { sub_type_de_champs_repetition.first.libelle } let(:text_repetition_libelle) { sub_type_de_champs_repetition.first.libelle }
let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle } let(:integer_repetition_libelle) { sub_type_de_champs_repetition.second.libelle }
@ -33,11 +35,13 @@ describe 'Prefilling a dossier (with a POST request):' do
Rails.cache.clear Rails.cache.clear
VCR.insert_cassette('api_geo_departements') VCR.insert_cassette('api_geo_departements')
VCR.insert_cassette('api_geo_communes')
VCR.insert_cassette('api_geo_epcis') VCR.insert_cassette('api_geo_epcis')
end end
after do after do
VCR.eject_cassette('api_geo_departements') VCR.eject_cassette('api_geo_departements')
VCR.eject_cassette('api_geo_communes')
VCR.eject_cassette('api_geo_epcis') VCR.eject_cassette('api_geo_epcis')
end end
@ -136,7 +140,8 @@ describe 'Prefilling a dossier (with a POST request):' do
], ],
"champ_#{type_de_champ_datetime.to_typed_id_for_query}" => datetime_value, "champ_#{type_de_champ_datetime.to_typed_id_for_query}" => datetime_value,
"champ_#{type_de_champ_multiple_drop_down_list.to_typed_id_for_query}" => multiple_drop_down_list_values, "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_epci.to_typed_id_for_query}" => epci_value,
"champ_#{type_de_champ_commune.to_typed_id_for_query}" => commune_value
}.to_json }.to_json
JSON.parse(session.response.body)["dossier_url"].gsub("http://www.example.com", "") JSON.parse(session.response.body)["dossier_url"].gsub("http://www.example.com", "")
end end