Update specs
This commit is contained in:
parent
8a2f079acb
commit
653270d02f
2 changed files with 18 additions and 15 deletions
|
@ -8,6 +8,6 @@ class APIGeoTestController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def communes
|
def communes
|
||||||
render json: [{ nom: 'Ambléon' }]
|
render json: [{ nom: 'Ambléon', code: '01006', codesPostaux: ['01300'] }]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ feature 'The user' do
|
||||||
let!(:procedure) { create(:procedure, :published, :for_individual, :with_all_champs_mandatory) }
|
let!(:procedure) { create(:procedure, :published, :for_individual, :with_all_champs_mandatory) }
|
||||||
let(:user_dossier) { user.dossiers.first }
|
let(:user_dossier) { user.dossiers.first }
|
||||||
|
|
||||||
scenario 'fill a dossier', js: true, vcr: { cassette_name: 'api_geo_departements_regions_et_communes' } do
|
scenario 'fill a dossier', js: true do
|
||||||
log_in(user, procedure)
|
log_in(user, procedure)
|
||||||
|
|
||||||
fill_individual
|
fill_individual
|
||||||
|
@ -30,13 +30,10 @@ feature 'The user' do
|
||||||
select('AUSTRALIE', from: 'pays')
|
select('AUSTRALIE', from: 'pays')
|
||||||
|
|
||||||
select_champ_geo('regions', 'Ma', 'Martinique')
|
select_champ_geo('regions', 'Ma', 'Martinique')
|
||||||
select('Martinique', from: 'regions')
|
|
||||||
|
|
||||||
select_champ_geo('departements', 'Ai', '02 - Aisne')
|
select_champ_geo('departements', 'Ai', '02 - Aisne')
|
||||||
select('02 - Aisne', from: 'departements')
|
|
||||||
|
|
||||||
select_champ_geo('communes', 'Am', 'Ambléon')
|
select_champ_geo('communes', 'Ambl', 'Ambléon (01300)')
|
||||||
select('Ambléon', from: 'communes')
|
|
||||||
|
|
||||||
check('engagement')
|
check('engagement')
|
||||||
fill_in('dossier_link', with: '123')
|
fill_in('dossier_link', with: '123')
|
||||||
|
@ -64,7 +61,7 @@ feature 'The user' do
|
||||||
expect(champ_value_for('pays')).to eq('AUSTRALIE')
|
expect(champ_value_for('pays')).to eq('AUSTRALIE')
|
||||||
expect(champ_value_for('regions')).to eq('Martinique')
|
expect(champ_value_for('regions')).to eq('Martinique')
|
||||||
expect(champ_value_for('departements')).to eq('02 - Aisne')
|
expect(champ_value_for('departements')).to eq('02 - Aisne')
|
||||||
expect(champ_value_for('communes')).to eq('Ambléon')
|
expect(champ_value_for('communes')).to eq('Ambléon (01300)')
|
||||||
expect(champ_value_for('engagement')).to eq('on')
|
expect(champ_value_for('engagement')).to eq('on')
|
||||||
expect(champ_value_for('dossier_link')).to eq('123')
|
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
|
expect(champ_value_for('piece_justificative')).to be_nil # antivirus hasn't approved the file yet
|
||||||
|
@ -87,9 +84,9 @@ feature 'The user' do
|
||||||
expect(page).to have_selected_value('simple_choice_drop_down_list_long', selected: 'bravo')
|
expect(page).to have_selected_value('simple_choice_drop_down_list_long', selected: 'bravo')
|
||||||
expect(page).to have_selected_value('multiple_choice_drop_down_list_long', selected: ['alpha', 'charly'])
|
expect(page).to have_selected_value('multiple_choice_drop_down_list_long', selected: ['alpha', 'charly'])
|
||||||
expect(page).to have_selected_value('pays', selected: 'AUSTRALIE')
|
expect(page).to have_selected_value('pays', selected: 'AUSTRALIE')
|
||||||
expect(page).to have_selected_value('regions', selected: 'Martinique')
|
expect(page).to have_hidden_field('regions', with: 'Martinique')
|
||||||
expect(page).to have_selected_value('departements', selected: '02 - Aisne')
|
expect(page).to have_hidden_field('departements', with: '02 - Aisne')
|
||||||
expect(page).to have_selected_value('communes', selected: 'Ambléon')
|
expect(page).to have_hidden_field('communes', with: 'Ambléon (01300)')
|
||||||
expect(page).to have_checked_field('engagement')
|
expect(page).to have_checked_field('engagement')
|
||||||
expect(page).to have_field('dossier_link', with: '123')
|
expect(page).to have_field('dossier_link', with: '123')
|
||||||
expect(page).to have_text('file.pdf')
|
expect(page).to have_text('file.pdf')
|
||||||
|
@ -321,6 +318,10 @@ feature 'The user' do
|
||||||
e.sibling('.datetime').first('select')[:id][0..-4]
|
e.sibling('.datetime').first('select')[:id][0..-4]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def have_hidden_field(libelle, with:)
|
||||||
|
have_css("##{form_id_for(libelle)}[value=\"#{with}\"]")
|
||||||
|
end
|
||||||
|
|
||||||
def champ_value_for(libelle)
|
def champ_value_for(libelle)
|
||||||
champs = user_dossier.champs
|
champs = user_dossier.champs
|
||||||
champs.find { |c| c.libelle == libelle }.value
|
champs.find { |c| c.libelle == libelle }.value
|
||||||
|
@ -351,10 +352,12 @@ feature 'The user' do
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_champ_geo(champ, fill_with, value)
|
def select_champ_geo(champ, fill_with, value)
|
||||||
find(".editable-champ-#{champ} .select2-container").click
|
input = find("input[aria-label=#{champ}")
|
||||||
id = find('.select2-container--open [role=listbox]')[:id]
|
input.click
|
||||||
find("[aria-controls=#{id}]").fill_in with: fill_with
|
input.fill_in with: fill_with
|
||||||
expect(page).to have_content(value)
|
selector = "li[data-option-value=\"#{value}\"]"
|
||||||
find('li', text: value).click
|
find(selector).click
|
||||||
|
expect(page).to have_css(selector)
|
||||||
|
expect(page).to have_hidden_field(champ, with: value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue