spec
This commit is contained in:
parent
c61e411328
commit
d1e3a0d29f
1 changed files with 39 additions and 11 deletions
|
@ -274,30 +274,58 @@ describe 'The user' do
|
||||||
context 'with condition' do
|
context 'with condition' do
|
||||||
include Logic
|
include Logic
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_yes_no, :with_type_de_champ) }
|
let(:procedure) do
|
||||||
let(:revision) { procedure.published_revision }
|
procedure = create(:procedure, :for_individual).tap do |p|
|
||||||
let(:yes_no_type_de_champ) { revision.types_de_champ.first }
|
p.draft_revision.add_type_de_champ(type_champ: :integer_number, libelle: 'age')
|
||||||
let(:type_de_champ) { revision.types_de_champ.last }
|
p.draft_revision.add_type_de_champ(type_champ: :yes_no, libelle: 'permis de conduire')
|
||||||
let(:condition) { ds_eq(champ_value(yes_no_type_de_champ.stable_id), constant(true)) }
|
p.draft_revision.add_type_de_champ(type_champ: :integer_number, libelle: 'tonnage')
|
||||||
|
end
|
||||||
|
|
||||||
before { type_de_champ.update(condition: condition) }
|
age, permis, tonnage = procedure.draft_revision.types_de_champ.all
|
||||||
|
|
||||||
|
permis.update(condition: greater_than_eq(champ_value(age.stable_id), constant(18)))
|
||||||
|
tonnage.update(condition: ds_eq(champ_value(permis.stable_id), constant(true)))
|
||||||
|
|
||||||
|
procedure.publish!
|
||||||
|
|
||||||
|
procedure
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'fill a dossier', js: true do
|
scenario 'fill a dossier', js: true do
|
||||||
log_in(user, procedure)
|
log_in(user, procedure)
|
||||||
|
|
||||||
|
age, permis, tonnage = user.dossiers.first.champs.to_a
|
||||||
|
|
||||||
fill_individual
|
fill_individual
|
||||||
|
|
||||||
expect(page).to have_field(type_de_champ.libelle, with: '', visible: false)
|
expect(page).to have_css('label', text: 'age', visible: true)
|
||||||
|
expect(page).to have_no_css('label', text: 'permis de conduire', visible: true)
|
||||||
|
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
|
fill_in('age', with: '18')
|
||||||
|
expect(page).to have_css('label', text: 'permis de conduire', visible: true)
|
||||||
|
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
choose('Oui')
|
choose('Oui')
|
||||||
expect(page).to have_field(type_de_champ.libelle, with: '', visible: true)
|
expect(page).to have_css('label', text: 'permis de conduire', visible: true)
|
||||||
|
expect(page).to have_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
|
fill_in('age', with: '2')
|
||||||
|
expect(page).to have_no_css('label', text: 'permis de conduire', visible: true)
|
||||||
|
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
click_on 'Déposer le dossier'
|
click_on 'Déposer le dossier'
|
||||||
click_on 'Accéder à votre dossier'
|
click_on 'Accéder à votre dossier'
|
||||||
click_on 'Modifier mon dossier'
|
click_on 'Modifier mon dossier'
|
||||||
|
|
||||||
expect(page).to have_field(type_de_champ.libelle, with: '', visible: true)
|
expect(page).to have_css('label', text: 'age', visible: true)
|
||||||
choose('Non')
|
expect(page).to have_no_css('label', text: 'permis de conduire', visible: true)
|
||||||
expect(page).to have_field(type_de_champ.libelle, with: '', visible: false)
|
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
|
fill_in('age', with: '18')
|
||||||
|
# the champ keeps their previous value so they are all displayed
|
||||||
|
expect(page).to have_css('label', text: 'permis de conduire', visible: true)
|
||||||
|
expect(page).to have_css('label', text: 'tonnage', visible: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue