wrap existing spec in specific context
This commit is contained in:
parent
f77a6cfc14
commit
0b90c81c3a
1 changed files with 49 additions and 47 deletions
|
@ -269,65 +269,67 @@ describe 'The user' do
|
||||||
context 'with condition' do
|
context 'with condition' do
|
||||||
include Logic
|
include Logic
|
||||||
|
|
||||||
let(:procedure) do
|
context 'with a visibilite in cascade' do
|
||||||
procedure = create(:procedure, :for_individual).tap do |p|
|
let(:procedure) do
|
||||||
p.draft_revision.add_type_de_champ(type_champ: :integer_number, libelle: 'age')
|
procedure = create(:procedure, :for_individual).tap do |p|
|
||||||
p.draft_revision.add_type_de_champ(type_champ: :yes_no, libelle: 'permis de conduire')
|
p.draft_revision.add_type_de_champ(type_champ: :integer_number, libelle: 'age')
|
||||||
p.draft_revision.add_type_de_champ(type_champ: :integer_number, libelle: 'tonnage')
|
p.draft_revision.add_type_de_champ(type_champ: :yes_no, libelle: 'permis de conduire')
|
||||||
p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'parking')
|
p.draft_revision.add_type_de_champ(type_champ: :integer_number, libelle: 'tonnage')
|
||||||
|
p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'parking')
|
||||||
|
end
|
||||||
|
|
||||||
|
age, permis, tonnage, parking = 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)))
|
||||||
|
parking.update(condition: less_than_eq(champ_value(tonnage.stable_id), constant(20)))
|
||||||
|
|
||||||
|
procedure.publish!
|
||||||
|
|
||||||
|
procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
age, permis, tonnage, parking = procedure.draft_revision.types_de_champ.all
|
scenario 'fill a dossier', js: true do
|
||||||
|
log_in(user, procedure)
|
||||||
|
|
||||||
permis.update(condition: greater_than_eq(champ_value(age.stable_id), constant(18)))
|
fill_individual
|
||||||
tonnage.update(condition: ds_eq(champ_value(permis.stable_id), constant(true)))
|
|
||||||
parking.update(condition: less_than_eq(champ_value(tonnage.stable_id), constant(20)))
|
|
||||||
|
|
||||||
procedure.publish!
|
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)
|
||||||
|
|
||||||
procedure
|
fill_in('age', with: '18')
|
||||||
end
|
expect(page).to have_css('label', text: 'permis de conduire', visible: true)
|
||||||
|
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
scenario 'fill a dossier', js: true do
|
choose('Oui')
|
||||||
log_in(user, procedure)
|
expect(page).to have_css('label', text: 'permis de conduire', visible: true)
|
||||||
|
expect(page).to have_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
fill_individual
|
fill_in('tonnage', with: '1')
|
||||||
|
expect(page).to have_css('label', text: 'parking', visible: true)
|
||||||
|
|
||||||
expect(page).to have_css('label', text: 'age', visible: true)
|
# try to fill with invalid data
|
||||||
expect(page).to have_no_css('label', text: 'permis de conduire', visible: true)
|
fill_in('tonnage', with: 'a')
|
||||||
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
expect(page).to have_no_css('label', text: 'parking', visible: true)
|
||||||
|
|
||||||
fill_in('age', with: '18')
|
fill_in('age', with: '2')
|
||||||
expect(page).to have_css('label', text: 'permis de conduire', 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)
|
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
choose('Oui')
|
click_on 'Déposer le dossier'
|
||||||
expect(page).to have_css('label', text: 'permis de conduire', visible: true)
|
click_on 'Accéder à votre dossier'
|
||||||
expect(page).to have_css('label', text: 'tonnage', visible: true)
|
click_on 'Modifier mon dossier'
|
||||||
|
|
||||||
fill_in('tonnage', with: '1')
|
expect(page).to have_css('label', text: 'age', visible: true)
|
||||||
expect(page).to have_css('label', text: 'parking', 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)
|
||||||
|
|
||||||
# try to fill with invalid data
|
fill_in('age', with: '18')
|
||||||
fill_in('tonnage', with: 'a')
|
# the champ keeps their previous value so they are all displayed
|
||||||
expect(page).to have_no_css('label', text: 'parking', 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')
|
end
|
||||||
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 'Accéder à votre dossier'
|
|
||||||
click_on 'Modifier mon dossier'
|
|
||||||
|
|
||||||
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')
|
|
||||||
# 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…
Add table
Reference in a new issue