diff --git a/helpers/helpers.rb b/helpers/helpers.rb index fa959a2f..a9429b01 100644 --- a/helpers/helpers.rb +++ b/helpers/helpers.rb @@ -335,3 +335,19 @@ def extract_created_record_id(string) current_url.split(':digital_object_').pop if string.include?('Digital Object') end + +def expect_form_values(form_values_table) + form_values = form_values_table.hashes + + form_values.each do |row| + section_title = find('h3', text: row['form_section'], match: :first) + section = section_title.ancestor('section', match: :first) + expect(section[:id]).to_not eq nil + + within section do + field = find_field(row['form_field']) + + expect(field.value.downcase).to eq row['form_value'].downcase + end + end +end diff --git a/staff_features/agents/agent_edit_default_values.feature b/staff_features/agents/agent_edit_default_values.feature new file mode 100644 index 00000000..b249c62b --- /dev/null +++ b/staff_features/agents/agent_edit_default_values.feature @@ -0,0 +1,56 @@ +Feature: Agent Edit Default Values + Background: + Given an administrator user is logged in + And the Pre-populate Records option is checked in Repository Preferences + Scenario: Edit Default Values of Agent Person + Given an Agent Person has been created + And the user is on the Agents page + When the user clicks on 'Edit Default Values' + And the user clicks on 'Person' in the dropdown menu + And the user clicks on 'Add Record ID' + And the user fills in 'Record Identifier' with 'Test Record Identifier' + And the user clicks on 'Save Person' + Then the 'Defaults' updated message is displayed + And the new Agent Person form has the following default values + | form_section | form_field | form_value | + | Record IDs | Record Identifier | Test Record Identifier | + Scenario: Edit Default Values of Agent Family + Given an Agent Family has been created + And the user is on the Agents page + When the user clicks on 'Edit Default Values' + And the user clicks on 'Family' in the dropdown menu + And the user clicks on 'Add Contact' + And the user fills in 'Contact Name' with 'Test Contact Name' + And the user selects 'Ms.' from 'Salutation' + And the user clicks on 'Save Family' + Then the 'Defaults' updated message is displayed + And the new Agent Family form has the following default values + | form_section | form_field | form_value | + | Contact Details | Contact Name | Test Contact Name | + | Contact Details | Salutation | Ms | + Scenario: Edit Default Values of Agent Corporate Entity + Given an Agent Corporate Entity has been created + And the user is on the Agents page + When the user clicks on 'Edit Default Values' + And the user clicks on 'Corporate Entity' in the dropdown menu + And the user clicks on 'Other Agency Codes' + And the user clicks on 'Add Agency Code' + And the user fills in 'Maintenance Agency' with 'Test Agency' + And the user clicks on 'Save Corporate Entity' + Then the 'Defaults' updated message is displayed + And the new Agent Corporate Entity form has the following default values + | form_section | form_field | form_value | + | Other Agency Codes | Maintenance Agency | Test Agency | + Scenario: Edit Default Values of Agent Software + Given an Agent Software has been created + And the user is on the Agents page + When the user clicks on 'Edit Default Values' + And the user clicks on 'Software' in the dropdown menu + And the user clicks on 'Contact Details' + And the user clicks on 'Add Contact' + And the user fills in 'Contact Name' with 'Test Contact' + And the user clicks on 'Save Software' + Then the 'Defaults' updated message is displayed + And the new Agent Software form has the following default values + | form_section | form_field | form_value | + | Contact Details | Contact Name | Test Contact | diff --git a/staff_features/agents/step_definitions/agent_edit_default_values.rb b/staff_features/agents/step_definitions/agent_edit_default_values.rb new file mode 100644 index 00000000..09a61f89 --- /dev/null +++ b/staff_features/agents/step_definitions/agent_edit_default_values.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +Given 'the user is on the Agents page' do + visit "#{STAFF_URL}/agents" +end + +Given 'an Agent Person has been created' do + visit "#{STAFF_URL}/agents/agent_person/new" + + fill_in 'Primary Part of Name', with: "Agent #{@uuid}", match: :first + click_on 'Save' + + expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Agent Created' + url_parts = current_url.split('agents/agent_person').pop.split('/') + url_parts.pop + @agent_id = url_parts.pop +end + +Given 'an Agent Family has been created' do + visit "#{STAFF_URL}/agents/agent_family/new" + + fill_in 'Family Name', with: "Agent #{@uuid}" + + click_on 'Save' + + expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Agent Created' + url_parts = current_url.split('agents/agent_person').pop.split('/') + url_parts.pop + @agent_id = url_parts.pop +end + +Given 'an Agent Corporate Entity has been created' do + visit "#{STAFF_URL}/agents/agent_corporate_entity/new" + + fill_in 'Primary Part of Name', with: "Agent #{@uuid}", match: :first + click_on 'Save' + + expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Agent Created' + url_parts = current_url.split('agents/agent_person').pop.split('/') + url_parts.pop + @agent_id = url_parts.pop +end + +Given 'an Agent Software has been created' do + visit "#{STAFF_URL}/agents/agent_software/new" + + fill_in 'Software Name', with: "Agent #{@uuid}" + click_on 'Save' + + expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Agent Created' + url_parts = current_url.split('agents/agent_person').pop.split('/') + url_parts.pop + @agent_id = url_parts.pop +end + +Then 'the new Agent Person form has the following default values' do |form_values_table| + visit "#{STAFF_URL}/agents/agent_person/new" + + expect_form_values(form_values_table) +end + +Then 'the new Agent Family form has the following default values' do |form_values_table| + visit "#{STAFF_URL}/agents/agent_family/new" + + expect_form_values(form_values_table) +end + +Then 'the new Agent Corporate Entity form has the following default values' do |form_values_table| + visit "#{STAFF_URL}/agents/agent_corporate_entity/new" + + expect_form_values(form_values_table) +end + +Then 'the new Agent Software form has the following default values' do |form_values_table| + visit "#{STAFF_URL}/agents/agent_software/new" + + expect_form_values(form_values_table) +end diff --git a/staff_features/shared/step_definitions.rb b/staff_features/shared/step_definitions.rb index 9a6a7a35..94b8f628 100644 --- a/staff_features/shared/step_definitions.rb +++ b/staff_features/shared/step_definitions.rb @@ -355,29 +355,25 @@ Given 'the Pre-populate Records option is checked in Repository Preferences' do visit "#{STAFF_URL}/repositories/new" - fill_in 'repository_repository__repo_code_', with: 'repository_test_default_values' - fill_in 'repository_repository__name_', with: 'Repository Test Default Values' + fill_in 'repository_repository__repo_code_', with: "repository_test_default_values_#{@uuid}" + fill_in 'repository_repository__name_', with: "Repository Test Default Values #{@uuid}" find('#repository_repository__publish_').check click_on 'Save' message = find('.alert') - repository_exists = message.text == 'Repository Short Name - The repository short name must be unique within this ArchivesSpace' - repository_created = message.text == 'Repository Created' - agent_records_message = message.text == 'Agent records cannot be identical' - - expect(repository_exists || repository_created || agent_records_message).to eq true + expect(message.text).to eq 'Repository Created' visit STAFF_URL click_on 'Select Repository' within '.dropdown-menu' do - find('select').select 'repository_test_default_values' + find('select').select "repository_test_default_values_#{@uuid}" click_on 'Select Repository' end - expect(page).to have_text 'The Repository repository_test_default_values is now active' + expect(page).to have_text "The Repository repository_test_default_values_#{@uuid} is now active" find('#user-menu-dropdown').click within '.dropdown-menu' do