mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Make enterprises/index_spec a bit more resilient
This commit is contained in:
@@ -76,12 +76,20 @@ feature 'Enterprises Index' do
|
||||
visit admin_enterprises_path
|
||||
end
|
||||
|
||||
def enterprise_row_index(enterprise_name)
|
||||
enterprise_row_number = all('tr').index { |tr| tr.text.include? enterprise_name }
|
||||
enterprise_row_number - 1
|
||||
end
|
||||
|
||||
it "does not update the enterprises and displays errors" do
|
||||
d_row_index = enterprise_row_index(d.name)
|
||||
within("tr.enterprise-#{d.id}") do
|
||||
select d_manager.email, from: 'enterprise_set_collection_attributes_0_owner_id'
|
||||
select d_manager.email, from: "enterprise_set_collection_attributes_#{d_row_index}_owner_id"
|
||||
end
|
||||
|
||||
second_distributor_row_index = enterprise_row_index(second_distributor.name)
|
||||
within("tr.enterprise-#{second_distributor.id}") do
|
||||
select d_manager.email, from: 'enterprise_set_collection_attributes_1_owner_id'
|
||||
select d_manager.email, from: "enterprise_set_collection_attributes_#{second_distributor_row_index}_owner_id"
|
||||
end
|
||||
click_button "Update"
|
||||
expect(flash_message).to eq('Update failed')
|
||||
|
||||
Reference in New Issue
Block a user