-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
21 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
spec/components/conditions/routing_rules_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
describe Conditions::RoutingRulesComponent, type: :component do | ||
include Logic | ||
|
||
describe 'render' do | ||
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :drop_down_list, libelle: 'Votre ville', options: ['Paris', 'Lyon', 'Marseille'] }, { type: :integer_number, libelle: 'Un champ nombre entier' }]) } | ||
let(:groupe_instructeur) { procedure.groupe_instructeurs.first } | ||
let(:drop_down_tdc) { procedure.draft_revision.types_de_champ.first } | ||
let(:integer_number_tdc) { procedure.draft_revision.types_de_champ.last } | ||
let(:routing_rule) { ds_eq(champ_value(drop_down_tdc.stable_id), constant('Lyon')) } | ||
|
||
before do | ||
groupe_instructeur.update(routing_rule: routing_rule) | ||
render_inline(described_class.new(groupe_instructeur: groupe_instructeur)) | ||
end | ||
|
||
context 'with one row' do | ||
context 'when routing rule is valid' do | ||
it do | ||
expect(page).to have_text('Champ Cible') | ||
expect(page).not_to have_text('règle invalide') | ||
expect(page).to have_select('groupe_instructeur[condition_form][rows][][operator_name]', options: ["Est", "N’est pas"]) | ||
end | ||
end | ||
|
||
context 'when routing rule is invalid' do | ||
let(:routing_rule) { ds_eq(champ_value(drop_down_tdc.stable_id), empty) } | ||
it { expect(page).to have_text('règle invalide') } | ||
end | ||
end | ||
|
||
context 'with two rows' do | ||
context 'when routing rule is valid' do | ||
let(:routing_rule) { ds_and([ds_eq(champ_value(drop_down_tdc.stable_id), constant('Lyon')), ds_not_eq(champ_value(integer_number_tdc.stable_id), constant(33))]) } | ||
|
||
it do | ||
expect(page).not_to have_text('règle invalide') | ||
expect(page).to have_selector('tbody > tr', count: 2) | ||
expect(page).to have_select("groupe_instructeur_condition_form_top_operator_name", selected: "Et", options: ['Et', 'Ou']) | ||
end | ||
end | ||
|
||
context 'when routing rule is invalid' do | ||
let(:routing_rule) { ds_or([ds_eq(champ_value(drop_down_tdc.stable_id), constant('Lyon')), ds_not_eq(champ_value(integer_number_tdc.stable_id), empty)]) } | ||
it do | ||
expect(page).to have_text('règle invalide') | ||
expect(page).to have_selector('tbody > tr', count: 2) | ||
expect(page).to have_select("groupe_instructeur_condition_form_top_operator_name", selected: "Ou", options: ['Et', 'Ou']) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,14 +39,14 @@ | |
expect(page).not_to have_text('à configurer') | ||
|
||
click_on 'littéraire' | ||
expect(page).to have_select("targeted_champ", selected: "Spécialité") | ||
expect(page).to have_select("value", selected: "littéraire") | ||
expect(page).to have_select("groupe_instructeur[condition_form][rows][][targeted_champ]", selected: "Spécialité") | ||
expect(page).to have_select("groupe_instructeur[condition_form][rows][][value]", selected: "littéraire") | ||
|
||
click_on '3 groupes' | ||
click_on 'scientifique' | ||
|
||
expect(page).to have_select("targeted_champ", selected: "Spécialité") | ||
expect(page).to have_select("value", selected: "scientifique") | ||
expect(page).to have_select("groupe_instructeur[condition_form][rows][][targeted_champ]", selected: "Spécialité") | ||
expect(page).to have_select("groupe_instructeur[condition_form][rows][][value]", selected: "scientifique") | ||
end | ||
|
||
scenario 'Routage avancé' do | ||
|
@@ -106,20 +106,20 @@ | |
expect(page).to have_text("L’instructeur [email protected] a été affecté") | ||
|
||
# add routing rules | ||
within('.target') { select('Spécialité') } | ||
within('.value') { select('scientifique') } | ||
within('.target select') { select('Spécialité') } | ||
within('.value select') { select('scientifique') } | ||
|
||
click_on '3 groupes' | ||
|
||
click_on 'littéraire' | ||
|
||
within('.target') { select('Spécialité') } | ||
within('.value') { select('scientifique') } | ||
within('.target select') { select('Spécialité') } | ||
within('.value select') { select('scientifique') } | ||
|
||
expect(page).to have_text('règle déjà attribuée à scientifique') | ||
|
||
within('.target') { select('Spécialité') } | ||
within('.value') { select('littéraire') } | ||
within('.target select') { select('Spécialité') } | ||
within('.value select') { select('littéraire') } | ||
|
||
expect(page).not_to have_text('règle déjà attribuée à scientifique') | ||
|
||
|