diff --git a/helpers/helpers.rb b/helpers/helpers.rb index 7b4d5f3..296df33 100644 --- a/helpers/helpers.rb +++ b/helpers/helpers.rb @@ -203,6 +203,8 @@ def find_user_table_row_in_manage_user_access_page(username) end def create_resource(uuid) + visit "#{STAFF_URL}/resources/new" + fill_in 'resource_title_', with: "Resource #{uuid}" fill_in 'resource_id_0_', with: "Resource #{uuid}" find('#resource_publish_').check diff --git a/staff_features/resources/resource_component_edit_default_values.feature b/staff_features/resources/resource_component_edit_default_values.feature index 54d1df6..b3ef1bc 100644 --- a/staff_features/resources/resource_component_edit_default_values.feature +++ b/staff_features/resources/resource_component_edit_default_values.feature @@ -2,14 +2,14 @@ Feature: Resource 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 Resource has been created And the user is on the Resources page Scenario: Open Resource Component Edit Default values page When the user clicks on 'Edit Default Values' And the user clicks on 'Resource Component' in the dropdown menu Then the Component Record Defaults page is displayed Scenario: Edit Default Values of Resource Component - Given the user is on the Component Record Default page + Given a Resource has been created + And the user is on the Component Record Default page When the user fills in 'Title' with 'Default Component Test' And the user selects 'File' from 'Level of Description' And the user clicks on 'Save' @@ -18,4 +18,3 @@ Feature: Resource Component Edit Default Values | form_section | form_field | form_value | | Basic Information | Title | Default Component Test | | Basic Information | Level of Description | File | - \ No newline at end of file diff --git a/staff_features/resources/step_definitions/resource_component_edit_default_values.rb b/staff_features/resources/step_definitions/resource_component_edit_default_values.rb new file mode 100644 index 0000000..3f1d32a --- /dev/null +++ b/staff_features/resources/step_definitions/resource_component_edit_default_values.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +Given 'the user is on the Component Record Default page' do + visit "#{STAFF_URL}/archival_objects/defaults" +end + +Then 'the Component Record Defaults page is displayed' do + expect(current_url).to include '/archival_objects/defaults' +end + +Then 'the new Resource Component form has the following default values' do |form_values_table| + visit "#{STAFF_URL}/resources/#{@resource_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