bug(linked_dropdown/dropdown): dropdown_list : when mandatory, add an extra blank option. linked_dropdown_list : when mandatory and not filled, add an extra blank option to first list, then when select an element from the first list, another extra blank.
This commit is contained in:
parent
86212a7320
commit
7ad47f3eae
1 changed files with 38 additions and 13 deletions
|
@ -13,32 +13,57 @@ describe 'linked dropdown lists' do
|
|||
Secondary 2.3
|
||||
END_OF_LIST
|
||||
end
|
||||
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, libelle: 'linked dropdown', drop_down_list_value: list_items) }
|
||||
|
||||
let!(:procedure) do
|
||||
create(:procedure, :published, :for_individual, types_de_champ: [type_de_champ])
|
||||
end
|
||||
let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, libelle: 'linked dropdown', drop_down_list_value: list_items, mandatory: mandatory) }
|
||||
|
||||
let(:user_dossier) { user.dossiers.first }
|
||||
context 'not mandatory' do
|
||||
let(:mandatory) { false }
|
||||
scenario 'change primary value, secondary options are updated', js: true do
|
||||
log_in(user.email, password, procedure)
|
||||
|
||||
scenario 'change primary value, secondary options are updated', js: true do
|
||||
log_in(user.email, password, procedure)
|
||||
fill_individual
|
||||
expect(page).to have_select("linked dropdown", options: ['', 'Primary 1', 'Primary 2'])
|
||||
|
||||
fill_individual
|
||||
# Select a primary value
|
||||
select('Primary 2', from: 'linked dropdown')
|
||||
|
||||
# Select a primary value
|
||||
select('Primary 2', from: 'linked dropdown')
|
||||
# Secondary menu reflects chosen primary value
|
||||
expect(page).to have_select("Valeur secondaire dépendant de la première", options: ['', 'Secondary 2.1', 'Secondary 2.2', 'Secondary 2.3'])
|
||||
|
||||
# Secondary menu reflects chosen primary value
|
||||
expect(page).to have_select("Valeur secondaire dépendant de la première", options: ['', 'Secondary 2.1', 'Secondary 2.2', 'Secondary 2.3'])
|
||||
# Select another primary value
|
||||
select('Primary 1', from: 'linked dropdown')
|
||||
|
||||
# Select another primary value
|
||||
select('Primary 1', from: 'linked dropdown')
|
||||
|
||||
# Secondary menu gets updated
|
||||
expect(page).to have_select("Valeur secondaire dépendant de la première", options: ['', 'Secondary 1.1', 'Secondary 1.2'])
|
||||
# Secondary menu gets updated
|
||||
expect(page).to have_select("Valeur secondaire dépendant de la première", options: ['', 'Secondary 1.1', 'Secondary 1.2'])
|
||||
end
|
||||
end
|
||||
|
||||
context 'mandatory' do
|
||||
let(:mandatory) { true }
|
||||
|
||||
scenario 'change primary value, secondary options are updated', js: true do
|
||||
log_in(user.email, password, procedure)
|
||||
|
||||
fill_individual
|
||||
expect(page).to have_select("linked dropdown", options: ['', 'Primary 1', 'Primary 2'])
|
||||
|
||||
# Select a primary value
|
||||
select('Primary 2', from: 'linked dropdown')
|
||||
|
||||
# Secondary menu reflects chosen primary value
|
||||
expect(page).to have_select("Valeur secondaire dépendant de la première", options: ['', 'Secondary 2.1', 'Secondary 2.2', 'Secondary 2.3'])
|
||||
|
||||
# Select another primary value
|
||||
select('Primary 1', from: 'linked dropdown')
|
||||
|
||||
# Secondary menu gets updated
|
||||
expect(page).to have_select("Valeur secondaire dépendant de la première", options: ['', 'Secondary 1.1', 'Secondary 1.2'])
|
||||
end
|
||||
end
|
||||
private
|
||||
|
||||
def log_in(email, password, procedure)
|
||||
|
|
Loading…
Add table
Reference in a new issue