From 75d4d2f9cb8cce29f96ae9e37e645ae795cb5dc7 Mon Sep 17 00:00:00 2001 From: Thomas Scherz Date: Mon, 15 Jul 2024 16:16:11 -0400 Subject: [PATCH] Adds spec test for mutli-value --- .../software_records/multi_value_spec.rb | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 spec/features/software_records/multi_value_spec.rb diff --git a/spec/features/software_records/multi_value_spec.rb b/spec/features/software_records/multi_value_spec.rb new file mode 100644 index 0000000..ba0bbf5 --- /dev/null +++ b/spec/features/software_records/multi_value_spec.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.feature 'MultiValueFields', type: :feature, js: true do + let(:user) { FactoryBot.create(:admin) } + let(:software_record) { FactoryBot.create(:software_record) } + + before do + visit new_user_session_path + fill_in 'Email', with: user.email + fill_in 'Password', with: 'random1234' + click_button 'Login' + visit edit_software_record_path(software_record) + end + + scenario 'User can add and remove multiple developers' do + within('#multiple_developers') do + expect(page).to have_selector('.input-group', count: 1) + find('a', text: '+ add more').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) + 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 + expect(page).to have_selector('.input-group', count: 2) + all('.input-group-append').last.click + expect(page).to have_selector('.input-group', count: 1) + 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 + expect(page).to have_selector('.input-group', count: 2) + all('.input-group-append').last.click + expect(page).to have_selector('.input-group', count: 1) + 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 + + expect(page).to have_selector('.input-group', count: 2) + + all('.input-group-append').last.click + expect(page).to have_selector('.input-group', count: 1) + 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 + + expect(page).to have_selector('.input-group', count: 2) + + all('.input-group-append').last.click + expect(page).to have_selector('.input-group', count: 1) + end + end +end