From fb7945570a64048138b5ed09f5b3924650e09b45 Mon Sep 17 00:00:00 2001 From: dinadi Date: Fri, 31 Jan 2025 16:23:39 +0200 Subject: [PATCH 1/3] Agent edit default values --- .../agents/agent_edit_default_values.feature | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 staff_features/agents/agent_edit_default_values.feature 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..9e7b6028 --- /dev/null +++ b/staff_features/agents/agent_edit_default_values.feature @@ -0,0 +1,58 @@ +Feature: Agent Edit Default Values + Background: + Given an administrator user is logged in + And the Pre-populate Records option is checked in Repository Preferences + And an Agent type Person has been created + And an Agent type Family has been created + And an Agent type Corporate Entity has been created + And an Agent type Software has been created + And the user is on the Agents page + Scenario: Edit Default Values of Agent type Person + When the user clicks on 'Edit Default Values' + And the user clicks on 'Person' in the dropdown menu + And the user clicks on 'Name Forms' + And the user clicks on 'Add Name Form' + And the user fills in 'Primary Part of Name' with 'Test name' + And the user fills in 'Rest of Name' with 'Rest name' + And the user clicks on 'Save Person' + Then the 'Defaults' updated message is displayed + And the new Agent type Person form has the following default values + | form_section | form_field | form_value | + | Name Forms | Primary Part of Name | Test name | + | Name Forms | Rest of Name | Rest name | + Scenario: Edit Default Values of Agent type Family + When the user clicks on 'Edit Default Values' + And the user clicks on 'Family' in the dropdown menu + And the user clicks on 'Notes' + And the user clicks on 'Add Note' + And the user selects 'General Context' from 'Note Type' + And the user fills in 'Content' with 'Test note' + And the user clicks on 'Save Family' + Then the 'Defaults' updated message is displayed + And the new Agent type Family form has the following default values + | form_section | form_field | form_value | + | Notes | Note Type | General Context | + | Notes | Content | Test note | + Scenario: Edit Default Values of Agent type Corporate Entity + 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 type 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 type Software + 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 type Corporate Entity form has the following default values + | form_section | form_field | form_value | + | Contact Details | Contact Name | Test Contact | + \ No newline at end of file From 1feb4dedef5ca91207346a26817f82a19b24b70b Mon Sep 17 00:00:00 2001 From: blacksmith-welder Date: Mon, 10 Feb 2025 09:31:42 +0200 Subject: [PATCH 2/3] Fix formatting --- .../agents/agent_edit_default_values.feature | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/staff_features/agents/agent_edit_default_values.feature b/staff_features/agents/agent_edit_default_values.feature index 9e7b6028..50c81ac2 100644 --- a/staff_features/agents/agent_edit_default_values.feature +++ b/staff_features/agents/agent_edit_default_values.feature @@ -2,12 +2,9 @@ Feature: Agent Edit Default Values Background: Given an administrator user is logged in And the Pre-populate Records option is checked in Repository Preferences - And an Agent type Person has been created - And an Agent type Family has been created - And an Agent type Corporate Entity has been created - And an Agent type Software has been created + Scenario: Edit Default Values of Agent Person + Given an Agent Person has been created And the user is on the Agents page - Scenario: Edit Default Values of Agent type Person When the user clicks on 'Edit Default Values' And the user clicks on 'Person' in the dropdown menu And the user clicks on 'Name Forms' @@ -16,11 +13,13 @@ Feature: Agent Edit Default Values And the user fills in 'Rest of Name' with 'Rest name' And the user clicks on 'Save Person' Then the 'Defaults' updated message is displayed - And the new Agent type Person form has the following default values - | form_section | form_field | form_value | - | Name Forms | Primary Part of Name | Test name | - | Name Forms | Rest of Name | Rest name | - Scenario: Edit Default Values of Agent type Family + And the new Agent Person form has the following default values + | form_section | form_field | form_value | + | Name Forms | Primary Part of Name | Test name | + | Name Forms | Rest of Name | Rest name | + 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 'Notes' @@ -29,11 +28,13 @@ Feature: Agent Edit Default Values And the user fills in 'Content' with 'Test note' And the user clicks on 'Save Family' Then the 'Defaults' updated message is displayed - And the new Agent type Family form has the following default values - | form_section | form_field | form_value | - | Notes | Note Type | General Context | - | Notes | Content | Test note | - Scenario: Edit Default Values of Agent type Corporate Entity + And the new Agent Family form has the following default values + | form_section | form_field | form_value | + | Notes | Note Type | General Context | + | Notes | Content | Test note | + 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' @@ -41,10 +42,12 @@ Feature: Agent Edit Default Values 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 type 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 type Software + 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' @@ -52,7 +55,6 @@ Feature: Agent Edit Default Values 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 type Corporate Entity form has the following default values - | form_section | form_field | form_value | - | Contact Details | Contact Name | Test Contact | - \ No newline at end of file + And the new Agent Corporate Entity form has the following default values + | form_section | form_field | form_value | + | Contact Details | Contact Name | Test Contact | From eebd9667bda58c9626ac5f0de784cd52330a4fe5 Mon Sep 17 00:00:00 2001 From: blacksmith-welder Date: Mon, 10 Feb 2025 13:40:49 +0200 Subject: [PATCH 3/3] Agent edit default values --- helpers/helpers.rb | 16 ++++ .../agents/agent_edit_default_values.feature | 26 +++---- .../agent_edit_default_values.rb | 78 +++++++++++++++++++ staff_features/shared/step_definitions.rb | 16 ++-- 4 files changed, 111 insertions(+), 25 deletions(-) create mode 100644 staff_features/agents/step_definitions/agent_edit_default_values.rb 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 index 50c81ac2..b249c62b 100644 --- a/staff_features/agents/agent_edit_default_values.feature +++ b/staff_features/agents/agent_edit_default_values.feature @@ -7,31 +7,27 @@ Feature: Agent Edit Default Values 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 'Name Forms' - And the user clicks on 'Add Name Form' - And the user fills in 'Primary Part of Name' with 'Test name' - And the user fills in 'Rest of Name' with 'Rest name' + 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 | - | Name Forms | Primary Part of Name | Test name | - | Name Forms | Rest of Name | Rest name | + | 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 'Notes' - And the user clicks on 'Add Note' - And the user selects 'General Context' from 'Note Type' - And the user fills in 'Content' with 'Test note' + 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 | - | Notes | Note Type | General Context | - | Notes | Content | Test note | + | 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 @@ -55,6 +51,6 @@ Feature: Agent Edit Default Values 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 Corporate Entity form has the following default values + 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 f3e58c3c..aa21e73f 100644 --- a/staff_features/shared/step_definitions.rb +++ b/staff_features/shared/step_definitions.rb @@ -81,7 +81,7 @@ When 'the user clicks on {string} in the dropdown menu' do |string| dropdown_menus = all('.dropdown-menu') - within dropdown_menus.first do + within dropdown_menus.first do |dropdown_menu| elements = dropdown_menu.all(:xpath, ".//*[contains(text(), '#{string}')]") elements.each do |element| @@ -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