Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent edit default values #86

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
56 changes: 56 additions & 0 deletions staff_features/agents/agent_edit_default_values.feature
Original file line number Diff line number Diff line change
@@ -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 |
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
Loading