Skip to content

Commit

Permalink
Refactors multi_value spec to test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Scherz committed Jul 23, 2024
1 parent ce805b1 commit 4de9330
Showing 1 changed file with 68 additions and 12 deletions.
80 changes: 68 additions & 12 deletions spec/features/software_records/multi_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,109 @@
within('#multiple_developers') do
expect(page).to have_selector('.input-group', count: 1)
find('a', text: '+ add more').click
find('a', text: '+ add more').click

# Fill in fields with identifiable values
all('.input-group input').each_with_index do |input, index|
input.set("Developer #{index + 1}")
end

expect(page).to have_selector('.input-group', count: 3)

# Delete 'Developer 2'
all('.input-group-append')[1].click
expect(page).to have_selector('.input-group', count: 2)
all('.input-group-append').last.click
expect(page).to have_selector('.input-group', count: 1)
expect(page).not_to have_field(with: 'Developer 2')
expect(page).to have_field(with: 'Developer 1')
expect(page).to have_field(with: 'Developer 3')
end
end

scenario 'User can add and remove multiple tech leads' do
within('#multiple_tech_leads') do
expect(page).to have_selector('.input-group', count: 1)
find('a', text: '+ add more').click
find('a', text: '+ add more').click

# Fill in fields with identifiable values
all('.input-group input').each_with_index do |input, index|
input.set("Tech Lead #{index + 1}")
end

expect(page).to have_selector('.input-group', count: 3)

# Delete 'Tech Lead 2'
all('.input-group-append')[1].click
expect(page).to have_selector('.input-group', count: 2)
all('.input-group-append').last.click
expect(page).to have_selector('.input-group', count: 1)
expect(page).not_to have_field(with: 'Tech Lead 2')
expect(page).to have_field(with: 'Tech Lead 1')
expect(page).to have_field(with: 'Tech Lead 3')
end
end

scenario 'User can add and remove multiple departments' do
within('#multiple_departments') do
expect(page).to have_selector('.input-group', count: 1)
find('a', text: '+ add more').click
find('a', text: '+ add more').click

# Fill in fields with identifiable values
all('.input-group input').each_with_index do |input, index|
input.set("Department #{index + 1}")
end

expect(page).to have_selector('.input-group', count: 3)

# Delete 'Department 2'
all('.input-group-append')[1].click
expect(page).to have_selector('.input-group', count: 2)
all('.input-group-append').last.click
expect(page).to have_selector('.input-group', count: 1)
expect(page).not_to have_field(with: 'Department 2')
expect(page).to have_field(with: 'Department 1')
expect(page).to have_field(with: 'Department 3')
end
end

scenario 'User can add and remove multiple product owners' do
within('#multiple_product_owners') do
expect(page).to have_selector('.input-group', count: 1)
find('a', text: '+ add more').click
find('a', text: '+ add more').click

expect(page).to have_selector('.input-group', count: 2)
# Fill in fields with identifiable values
all('.input-group input').each_with_index do |input, index|
input.set("Product Owner #{index + 1}")
end

all('.input-group-append').last.click
expect(page).to have_selector('.input-group', count: 1)
expect(page).to have_selector('.input-group', count: 3)

# Delete 'Product Owner 2'
all('.input-group-append')[1].click
expect(page).to have_selector('.input-group', count: 2)
expect(page).not_to have_field(with: 'Product Owner 2')
expect(page).to have_field(with: 'Product Owner 1')
expect(page).to have_field(with: 'Product Owner 3')
end
end

scenario 'User can add and remove multiple admin users' do
within('#multiple_admin_users') do
expect(page).to have_selector('.input-group', count: 1)
find('a', text: '+ add more').click
find('a', text: '+ add more').click

expect(page).to have_selector('.input-group', count: 2)
# Fill in fields with identifiable values
all('.input-group input').each_with_index do |input, index|
input.set("Admin User #{index + 1}")
end

all('.input-group-append').last.click
expect(page).to have_selector('.input-group', count: 1)
expect(page).to have_selector('.input-group', count: 3)

# Delete 'Admin User 2'
all('.input-group-append')[1].click
expect(page).to have_selector('.input-group', count: 2)
expect(page).not_to have_field(with: 'Admin User 2')
expect(page).to have_field(with: 'Admin User 1')
expect(page).to have_field(with: 'Admin User 3')
end
end
end

0 comments on commit 4de9330

Please sign in to comment.