Skip to content

Commit

Permalink
Digital object component default values
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Feb 5, 2025
1 parent 4479460 commit 987f649
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ Feature: Digital Object Component Edit Default Values
Background:
Given an administrator user is logged in
And the Pre-populate Records option is checked in Repository Preferences
And a Digital Object has been created
And the user is on the Digital Objects page
Scenario: Open Digital Object Component Edit Default values page
Scenario: Edit Default Values of Digital Object Component
When the user clicks on 'Edit Default Values'
And the user clicks on 'Digital Object Component' in the dropdown menu
Then the Digital Object Component Defaults page is displayed
Scenario: Edit Default Values of Digital Object Component
Given a Digital Object has been created
And the user is on the Digital Object Component Defaults page
When the user fills in 'Label' with 'Test label'
And the user fills in 'Title' with 'Test title'
And the user clicks on 'Save Digital Object Component'
Then the 'Defaults' updated message is displayed
And the new Digital Object Component form has the following default values
| form_section | form_field | form_value |
| Basic Information | Label | Test label |
| Basic Information | Title | Test title |
| form_section | form_field | form_value |
| Basic Information | Label | Test label |
| Basic Information | Title | Test title |
38 changes: 0 additions & 38 deletions staff_features/digital_objects/digital_object_view.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# frozen_string_literal: true

Given 'a Digital Object has been created' do
visit "#{STAFF_URL}/digital_objects/new"

fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}"
fill_in 'digital_object_digital_object_id_', with: "Digital Object Title #{@uuid}"

click_on 'Save'
wait_for_ajax

expect(page).to have_text "Digital Object Digital Object Title #{@uuid} Created"
end

Given 'two Digital Objects have been created with a common keyword in their title' do
@shared_digital_object_uuid = SecureRandom.uuid
@digital_object_a_uuid = SecureRandom.uuid
Expand Down Expand Up @@ -52,27 +40,6 @@
expect(search_result_rows[0]).to have_text @digital_object_b_uuid
end

When 'the user filters by text with the Digital Object title' do
fill_in 'Filter by text', with: @uuid

find('#filter-text').send_keys(:enter)

rows = []
checks = 0

while checks < 5
checks += 1

begin
rows = all('tr', text: @uuid)
rescue Selenium::WebDriver::Error::JavascriptError
sleep 1
end

break if rows.length == 1
end
end

Then 'the Digital Object is in the search results' do
expect(page).to have_css('tr', text: @uuid)
end
Expand Down Expand Up @@ -103,11 +70,6 @@
expect(search_result_rows.length).to eq 2
expect(search_result_rows[0]).to have_text @digital_object_a_uuid
expect(search_result_rows[1]).to have_text @digital_object_b_uuid

files = Dir.glob(File.join(Dir.tmpdir, '*.csv'))
files.each do |file|
downloaded_file.delete = file if file.include?('digital objects')
end
end

Then 'a CSV file is downloaded with the the two Digital Objects' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,24 @@
end
end
end

Then 'the new Digital Object Component form has the following default values' do |form_values_table|
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
wait_for_ajax
click_on 'Add Child'
wait_for_ajax

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
Original file line number Diff line number Diff line change
@@ -1,43 +1,5 @@
# 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
Expand Down

0 comments on commit 987f649

Please sign in to comment.