chore(spec): corrige les spec cassées et remanie un peu des specs ecrites

This commit is contained in:
Martin 2023-02-20 06:57:41 +01:00 committed by mfo
parent a89f5d373f
commit 5e10e680dc
2 changed files with 7 additions and 16 deletions

View file

@ -117,13 +117,14 @@ FactoryBot.define do
factory :champ_departements, class: 'Champs::DepartementChamp' do factory :champ_departements, class: 'Champs::DepartementChamp' do
type_de_champ { association :type_de_champ_departements, procedure: dossier.procedure } type_de_champ { association :type_de_champ_departements, procedure: dossier.procedure }
value { '01' }
end end
factory :champ_communes, class: 'Champs::CommuneChamp' do factory :champ_communes, class: 'Champs::CommuneChamp' do
type_de_champ { association :type_de_champ_communes, procedure: dossier.procedure } type_de_champ { association :type_de_champ_communes, procedure: dossier.procedure }
value { 'Coye-la-Forêt (60580)' } value { 'Coye-la-Forêt (60580)' }
value_json { { "departement" => "Oise", "code_departement" => "60" } } value_json { { "departement" => "Oise", "code_departement" => "60" } }
external_id { { external_id: "60172" } } external_id { "60172" }
end end
factory :champ_epci, class: 'Champs::EpciChamp' do factory :champ_epci, class: 'Champs::EpciChamp' do

View file

@ -94,7 +94,7 @@ describe "procedure filters" do
click_button "Ajouter le filtre" click_button "Ajouter le filtre"
end end
describe 'with a vcr cassette', vcr: { cassette_name: 'api_geo_departements' } do describe 'with a vcr cached cassette' do
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) } let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
before do before do
@ -102,7 +102,7 @@ describe "procedure filters" do
Rails.cache.clear Rails.cache.clear
end end
scenario "should be able to find by departements with custom enum lookup", js: true do scenario "should be able to find by departements with custom enum lookup", js: true, vcr: { cassette_name: 'api_geo_departements' } do
departement_champ = new_unfollow_dossier.champs.find(&:departement?) departement_champ = new_unfollow_dossier.champs.find(&:departement?)
departement_champ.update!(value: 'Oise', external_id: '60') departement_champ.update!(value: 'Oise', external_id: '60')
departement_champ.reload departement_champ.reload
@ -116,26 +116,16 @@ describe "procedure filters" do
find("select#value", visible: false) # w8 for filter to be applied find("select#value", visible: false) # w8 for filter to be applied
expect(page).to have_link(new_unfollow_dossier.id.to_s) expect(page).to have_link(new_unfollow_dossier.id.to_s)
end end
end
describe 'with a vcr cassette', vcr: { cassette_name: 'api_geo_regions' } do scenario "should be able to find by region with custom enum lookup", js: true, vcr: { cassette_name: 'api_geo_regions' } do
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) } region_champ = new_unfollow_dossier.champs.find(&:region?)
before do
allow(Rails).to receive(:cache).and_return(memory_store)
Rails.cache.clear
end
scenario "should be able to find by departements with custom enum lookup", js: true do
region_champ = new_unfollow_dossier.champs.find(&:regions?)
region_champ.update!(value: 'Bretagne', external_id: '53') region_champ.update!(value: 'Bretagne', external_id: '53')
region_champ.reload region_champ.reload
champ_select_value = "#{region_champ.external_id} #{region_champ.value}"
click_on 'Sélectionner un filtre' click_on 'Sélectionner un filtre'
select region_champ.libelle, from: "Colonne" select region_champ.libelle, from: "Colonne"
find("select#value", visible: true) find("select#value", visible: true)
select champ_select_value, from: "Valeur" select region_champ.value, from: "Valeur"
click_button "Ajouter le filtre" click_button "Ajouter le filtre"
find("select#value", visible: false) # w8 for filter to be applied find("select#value", visible: false) # w8 for filter to be applied
expect(page).to have_link(new_unfollow_dossier.id.to_s) expect(page).to have_link(new_unfollow_dossier.id.to_s)