Skip to content

Commit

Permalink
Agent edit default values
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Feb 13, 2025
1 parent 1199f9d commit 542085c
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 24 deletions.
16 changes: 16 additions & 0 deletions helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 11 additions & 15 deletions staff_features/agents/agent_edit_default_values.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 |
Original file line number Diff line number Diff line change
@@ -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
14 changes: 5 additions & 9 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 542085c

Please sign in to comment.