Skip to content

Commit

Permalink
Resource edit default values
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Jan 3, 2025
1 parent 422309f commit 19b2cf9
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ Style/ConditionalAssignment:

Style/NumericPredicate:
Enabled: false

Style/ZeroLengthPredicate:
Enabled: false
3 changes: 3 additions & 0 deletions helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ def create_resource(uuid)
fill_in 'resource_id_0_', with: "Resource #{uuid}"
find('#resource_publish_').check
select 'Class', from: 'resource_level_'

languages = all('#resource_lang_materials_ .subrecord-form-list li')
click_on 'Add Language' if languages.length == 0
element = find('#resource_lang_materials__0__language_and_script__language_')
element.send_keys(ORIGINAL_LANGUAGE)
element.send_keys(:tab)
Expand Down
15 changes: 8 additions & 7 deletions staff_features/resources/resource_edit_default_values.feature
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
Feature: Resource Edit Default Values
Background:
Given an administrator user is logged in
And the Pre-populate Records option is activated to My Repository Preferences
And the Pre-populate Records option is checked in Repository Preferences
And a Resource has been created
And the user is on the Resources page
Scenario: Open Resource Edit Default values page
When the user clicks on 'Edit Default Values'
And the user clicks on 'Resources' in the dropdown
Then the 'Resource Record Defaults' page is displayed
And the user clicks on 'Resource' in the dropdown menu
Then the Resource Record Defaults page is displayed
Scenario: Edit Default Values
Given the user is on the Resource Record Default page
When the user fills in 'Title' with 'Test Title'
When the user fills in 'Title' with 'Default Test Title'
And the user selects 'File' from 'Level of Description'
And the user clicks on 'Save'
Then the 'Defaults' updated message is displayed
And the new Resource form has the following values
| Title | Test Title |
| Level of Description | File |
And the new Resource form has the following default values
| form_section | form_field | form_value |
| Basic Information | Title | Default Test Title |
| Basic Information | Level of Description | File |
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: true

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_resource_edit_default_values'
fill_in 'repository_repository__name_', with: 'Repository Test Resource Edit Default Values'
find('#repository_repository__publish_').check
click_on 'Save'

message = find('.alert')

# Attempting to create a repository with the values above,
# may result in a success message or one of the following errors.
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

visit STAFF_URL

click_on 'Select Repository'
within '.dropdown-menu' do
find('select').select 'repository_test_resource_edit_default_values'

click_on 'Select Repository'
end

expect(page).to have_text 'The Repository repository_test_resource_edit_default_values is now active'

find('#user-menu-dropdown').click
within '.dropdown-menu' do
click_on 'Repository Preferences (admin)'
end

find('#preference_defaults__default_values_').check

click_on 'Save'
end

Given 'the user is on the Resources page' do
visit "#{STAFF_URL}/resources"
end

Then 'the Resource Record Defaults page is displayed' do
expect(current_url).to include 'resources/defaults'
end

Given 'the user is on the Resource Record Default page' do
visit "#{STAFF_URL}/resources/defaults"
end

Then 'the new Resource form has the following default values' do |form_values_table|
visit "#{STAFF_URL}/resources/new"

form_values = form_values_table.hashes

form_values.each do |row|
section_title = find('h3', text: row['form_section'])
section = section_title.ancestor('section')
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

0 comments on commit 19b2cf9

Please sign in to comment.