From bd1bed940c3afde16754a13d510158dc62e575b1 Mon Sep 17 00:00:00 2001 From: sebastiencarceles Date: Fri, 24 Feb 2023 10:49:11 +0100 Subject: [PATCH] feature spec cover --- spec/support/shared_examples_for_prefilled_dossier.rb | 1 + spec/system/users/dossier_prefill_get_spec.rb | 5 +++++ spec/system/users/dossier_prefill_post_spec.rb | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/support/shared_examples_for_prefilled_dossier.rb b/spec/support/shared_examples_for_prefilled_dossier.rb index 8a1b07a7e..239506e59 100644 --- a/spec/support/shared_examples_for_prefilled_dossier.rb +++ b/spec/support/shared_examples_for_prefilled_dossier.rb @@ -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.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 diff --git a/spec/system/users/dossier_prefill_get_spec.rb b/spec/system/users/dossier_prefill_get_spec.rb index 78a1ef8f4..eedf28cec 100644 --- a/spec/system/users/dossier_prefill_get_spec.rb +++ b/spec/system/users/dossier_prefill_get_spec.rb @@ -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_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_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(:text_value) { "My Neighbor Totoro is the best movie ever" } 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(:commune_value) { ['01', '01457'] } # Vonnas (01540) 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(: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_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_commune.to_typed_id_for_query}" => commune_value, "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, @@ -50,11 +53,13 @@ describe 'Prefilling a dossier (with a GET request):' do Rails.cache.clear VCR.insert_cassette('api_geo_departements') + VCR.insert_cassette('api_geo_communes') VCR.insert_cassette('api_geo_epcis') end after do VCR.eject_cassette('api_geo_departements') + VCR.eject_cassette('api_geo_communes') VCR.eject_cassette('api_geo_epcis') end diff --git a/spec/system/users/dossier_prefill_post_spec.rb b/spec/system/users/dossier_prefill_post_spec.rb index 55f90cbfa..5fc2119e8 100644 --- a/spec/system/users/dossier_prefill_post_spec.rb +++ b/spec/system/users/dossier_prefill_post_spec.rb @@ -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_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_commune) { create(:type_de_champ_communes, procedure: procedure) } let(:text_value) { "My Neighbor Totoro is the best movie ever" } let(:phone_value) { "invalid phone value" } 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(:commune_value) { ['01', '01457'] } # Vonnas (01540) 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(: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 VCR.insert_cassette('api_geo_departements') + VCR.insert_cassette('api_geo_communes') VCR.insert_cassette('api_geo_epcis') end after do VCR.eject_cassette('api_geo_departements') + VCR.eject_cassette('api_geo_communes') VCR.eject_cassette('api_geo_epcis') 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_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 JSON.parse(session.response.body)["dossier_url"].gsub("http://www.example.com", "") end