diff --git a/staff_features/digital_objects/digital_object_edit_default_values.feature b/staff_features/digital_objects/digital_object_edit_default_values.feature index df358e9..ba4600f 100644 --- a/staff_features/digital_objects/digital_object_edit_default_values.feature +++ b/staff_features/digital_objects/digital_object_edit_default_values.feature @@ -4,18 +4,14 @@ Feature: Digital Object Edit Default Values 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 Edit Default values page + Scenario: Edit Default Values When the user clicks on 'Edit Default Values' And the user clicks on 'Digital Object' in the dropdown menu - Then the Digital Object Defaults page is displayed - Scenario: Edit Default Values - Given the user is on the Digital Object Defaults page - When the user fills in 'Title' with 'Test Digital Object' + And the user fills in 'Title' with 'Test Digital Object' And the user selects 'Text' from 'Digital Object Type' And the user clicks on 'Save' Then the 'Defaults' updated message is displayed And the new Digital Object form has the following default values - | form_section | form_field | form_value | - | Basic Information | Title | Test Digital Object | - | Basic Information | Digital Object Type | Text | - \ No newline at end of file + | form_section | form_field | form_value | + | Basic Information | Title | Test Digital Object | + | Basic Information | Digital Object Type | Text | diff --git a/staff_features/digital_objects/step_definitions/digital_object_default_values.rb b/staff_features/digital_objects/step_definitions/digital_object_default_values.rb new file mode 100644 index 0000000..6db119e --- /dev/null +++ b/staff_features/digital_objects/step_definitions/digital_object_default_values.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +Then 'the new Digital Object form has the following default values' do |form_values_table| + visit "#{STAFF_URL}/digital_objects/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 diff --git a/staff_features/digital_objects/step_definitions/digital_object_shared.rb b/staff_features/digital_objects/step_definitions/digital_object_shared.rb new file mode 100644 index 0000000..f259b92 --- /dev/null +++ b/staff_features/digital_objects/step_definitions/digital_object_shared.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +Given 'a Digital Object has been created' do + visit "#{STAFF_URL}/digital_objects/new" + + fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}" + fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}" + + click_on 'Add Date' + select 'Single', from: 'digital_object_dates__0__date_type_' + fill_in 'digital_object_dates__0__begin_', with: '2000-01-01' + + click_on 'Save' + + wait_for_ajax + expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created" + @digital_object_id = current_url.split('::digital_object_').pop +end + +Given 'the user is on the Digital Objects page' do + visit "#{STAFF_URL}/digital_objects" +end diff --git a/staff_features/shared/step_definitions.rb b/staff_features/shared/step_definitions.rb index b00d9ea..2ee678e 100644 --- a/staff_features/shared/step_definitions.rb +++ b/staff_features/shared/step_definitions.rb @@ -277,3 +277,40 @@ Then 'the {string} section is displayed' do |section_heading| expect(all('section > h3').map(&:text)).to include(section_heading) end + +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' + 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 + + visit STAFF_URL + + click_on 'Select Repository' + within '.dropdown-menu' do + find('select').select 'repository_test_default_values' + + click_on 'Select Repository' + end + + expect(page).to have_text 'The Repository repository_test_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