diff --git a/.rubocop.yml b/.rubocop.yml index f89a9d1..aec2656 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,3 +23,6 @@ Style/ConditionalAssignment: Style/NumericPredicate: Enabled: false + +Style/ZeroLengthPredicate: + Enabled: false diff --git a/helpers/helpers.rb b/helpers/helpers.rb index 8aec9b8..7b4d5f3 100644 --- a/helpers/helpers.rb +++ b/helpers/helpers.rb @@ -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) diff --git a/staff_features/resources/resource_edit_default_values.feature b/staff_features/resources/resource_edit_default_values.feature index e99cc58..352c44f 100644 --- a/staff_features/resources/resource_edit_default_values.feature +++ b/staff_features/resources/resource_edit_default_values.feature @@ -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 | diff --git a/staff_features/resources/step_definitions/resource_edit_default_values.rb b/staff_features/resources/step_definitions/resource_edit_default_values.rb new file mode 100644 index 0000000..0632ec4 --- /dev/null +++ b/staff_features/resources/step_definitions/resource_edit_default_values.rb @@ -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