fix(dossier): update spec

This commit is contained in:
Paul Chavard 2022-12-20 21:29:53 +01:00
parent bd9fe7eb7c
commit 00218fded2
6 changed files with 104 additions and 18 deletions

View file

@ -15,7 +15,7 @@ describe Administrateurs::ProceduresController, type: :controller do
let(:zone_ids) { [zone.id] }
let(:tags) { "[\"planete\",\"environnement\"]" }
describe '#apercu' do
describe '#apercu', vcr: { cassette_name: 'api_geo_all' } do
render_views
let(:procedure) { create(:procedure, :with_all_champs) }

79
spec/fixtures/cassettes/api_geo_all.yml vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -196,7 +196,7 @@ describe Champ do
end
end
describe '#search_terms' do
describe '#search_terms', vcr: { cassette_name: 'api_geo_all' } do
let(:champ) { type_de_champ.champ.build(value: value) }
subject { champ.search_terms }
@ -247,9 +247,9 @@ describe Champ do
context 'for département champ' do
let(:type_de_champ) { build(:type_de_champ_departements) }
let(:value) { "69 - Rhône" }
let(:value) { "69" }
it { is_expected.to eq([value]) }
it { is_expected.to eq(['69 Rhône']) }
end
context 'for dossier link champ' do
@ -319,9 +319,9 @@ describe Champ do
context 'for pays champ' do
let(:type_de_champ) { build(:type_de_champ_pays) }
let(:value) { "FRANCE" }
let(:value) { "FR" }
it { is_expected.to eq([value]) }
it { is_expected.to eq(['France']) }
end
context 'for phone champ' do
@ -340,9 +340,9 @@ describe Champ do
context 'for region champ' do
let(:type_de_champ) { build(:type_de_champ_regions) }
let(:value) { "Île-de-France" }
let(:value) { "11" }
it { is_expected.to eq([value]) }
it { is_expected.to eq(['Île-de-France']) }
end
context 'for siret champ' do

View file

@ -1,4 +1,4 @@
describe 'wcag rules for usager', js: true do
describe 'wcag rules for usager', js: true, vcr: { cassette_name: 'api_geo_all' } do
let(:procedure) { create(:procedure, :published, :with_all_champs, :with_service, :for_individual) }
let(:password) { 'a very complicated password' }
let(:litteraire_user) { create(:user, password: password) }

View file

@ -1,4 +1,4 @@
describe 'Accessing the /patron page:' do
describe 'Accessing the /patron page:', vcr: { cassette_name: 'api_geo_all' } do
scenario 'I can display a page with all form fields and UI elements' do
visit patron_path
expect(page).to have_text('Icônes')

View file

@ -6,7 +6,14 @@ describe 'The user' do
let(:user_dossier) { user.dossiers.first }
let!(:dossier_to_link) { create(:dossier) }
scenario 'fill a dossier', js: true do
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }
before do
allow(Rails).to receive(:cache).and_return(memory_store)
Rails.cache.clear
end
scenario 'fill a dossier', js: true, vcr: { cassette_name: 'api_geo_all' } do
log_in(user, procedure)
fill_individual
@ -33,9 +40,9 @@ describe 'The user' do
select_combobox('multiple_choice_drop_down_list_long', 'alp', 'alpha')
select_combobox('multiple_choice_drop_down_list_long', 'cha', 'charly')
select_combobox('pays', 'aust', 'Australie')
select_combobox('regions', 'Ma', 'Martinique')
select_combobox('departements', 'Ai', '02 - Aisne')
select('Australie', from: form_id_for('pays'))
select('Martinique', from: form_id_for('regions'))
select('02 Aisne', from: form_id_for('departements'))
select_combobox('communes', 'Ai', '02 - Aisne', check: false)
select_combobox('communes', 'Ambl', 'Ambléon (01300)')
@ -65,7 +72,7 @@ describe 'The user' do
expect(JSON.parse(champ_value_for('multiple_drop_down_list'))).to match(['val1', 'val3'])
expect(champ_value_for('pays')).to eq('Australie')
expect(champ_value_for('regions')).to eq('Martinique')
expect(champ_value_for('departements')).to eq('02 - Aisne')
expect(champ_value_for('departements')).to eq('Aisne')
expect(champ_value_for('communes')).to eq('Ambléon (01300)')
expect(champ_value_for('dossier_link')).to eq('123')
expect(champ_value_for('piece_justificative')).to be_nil # antivirus hasn't approved the file yet
@ -86,10 +93,10 @@ describe 'The user' do
expect(page).to have_checked_field('val1')
expect(page).to have_checked_field('val3')
expect(page).to have_selected_value('simple_choice_drop_down_list_long', selected: 'bravo')
expect(page).to have_selected_value('pays', selected: 'Australie')
expect(page).to have_selected_value('regions', selected: 'Martinique')
expect(page).to have_selected_value('departements', selected: '02 Aisne')
check_selected_value('multiple_choice_drop_down_list_long', with: ['alpha', 'charly'])
check_selected_value('pays', with: 'Australie')
check_selected_value('regions', with: 'Martinique')
check_selected_value('departements', with: '02 - Aisne')
check_selected_value('communes', with: 'Ambléon (01300)')
expect(page).to have_field('dossier_link', with: '123')
expect(page).to have_text('file.pdf')