diff --git a/helpers/helpers.rb b/helpers/helpers.rb index 8aec9b8..70b5a25 100644 --- a/helpers/helpers.rb +++ b/helpers/helpers.rb @@ -324,5 +324,9 @@ def wait_for_ajax end def extract_created_record_id(string) - current_url.split(':archival_object_').pop if string.include?('Archival Object') + return current_url.split(':archival_object_').pop if string.include?('Archival Object') + + return current_url.split(':digital_object_component_').pop if string.include?('Digital Object Component') + + current_url.split(':digital_object_').pop if string.include?('Digital Object') end diff --git a/staff_features/digital_objects/digital_object_component_create.feature b/staff_features/digital_objects/digital_object_component_create.feature new file mode 100644 index 0000000..06dcde1 --- /dev/null +++ b/staff_features/digital_objects/digital_object_component_create.feature @@ -0,0 +1,20 @@ +Feature: Digital Object Component Create + Background: + Given an administrator user is logged in + Scenario: Create a Child Digital Object + Given a Digital Object has been created + And the Digital Object is opened in edit mode + When the user clicks on 'Add Child' + And the user fills in 'Label' with 'Digital Object Component Label Child' + And the user clicks on 'Save' + Then the 'Digital Object Component' created message is displayed + And the Digital Object Component with Label 'Digital Object Component Label Child' is saved as a child of the Digital Object + Scenario: Create a Sibling Digital Object + Given a Digital Object with a Digital Object Component has been created + And the Digital Object is opened in edit mode + When the user selects the Digital Object Component + And the user clicks on 'Add Sibling' + And the user fills in 'Label' with 'Digital Object Component Label Sibling' + And the user clicks on 'Save' + Then the 'Digital Object Component' created message is displayed + And the Digital Object Component with Title 'Digital Object Component Label Sibling' is saved as a sibling of the selected Digital Object Component diff --git a/staff_features/digital_objects/step_definitions/digital_object_shared.rb b/staff_features/digital_objects/step_definitions/digital_object_shared.rb index 18dbfac..1df27e0 100644 --- a/staff_features/digital_objects/step_definitions/digital_object_shared.rb +++ b/staff_features/digital_objects/step_definitions/digital_object_shared.rb @@ -57,3 +57,50 @@ expect(page).to have_field('Identifier', with: "Digital Object Identifier #{@uuid}") end + +Then 'the Digital Object Component with Label {string} is saved as a child of the Digital Object' do |text| + records = all('#tree-container .table-row', text:) + + expect(records.length).to eq 1 + expect(records[0][:class]).to include 'indent-level-1 current' + + expect(page).to have_css "#tree-container #digital_object_#{@digital_object_id} + .table-row-group #digital_object_component_#{@created_record_id}" +end + +Then 'the Digital Object Component with Title {string} is saved as a sibling of the selected Digital Object Component' do |title| + records = all('#tree-container .table-row', text: title) + + expect(records.length).to eq 1 + expect(records[0][:class]).to include 'indent-level-1 current' + expect(page).to have_css "#tree-container #digital_object_#{@digital_object_id} + .table-row-group #digital_object_component_#{@created_record_id}" +end + +Given 'a Digital Object with a Digital Object Component 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 + + click_on 'Add Child' + wait_for_ajax + + fill_in 'Label', with: "Digital Object Component Label #{@uuid}" + click_on 'Save' + wait_for_ajax + + expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}" +end + +And 'the user selects the Digital Object Component' do + click_on "Digital Object Component Label #{@uuid}" +end diff --git a/staff_features/resources/step_definitions/resource_archival_object_create.rb b/staff_features/resources/step_definitions/resource_archival_object_create.rb index 675215a..d8cbed0 100644 --- a/staff_features/resources/step_definitions/resource_archival_object_create.rb +++ b/staff_features/resources/step_definitions/resource_archival_object_create.rb @@ -112,7 +112,7 @@ expect(archival_objects.length).to eq 1 expect(archival_objects[0][:class]).to include 'indent-level-1 current' - expect(page).to have_css "#tree-container #resource_#{@resource_id} + .table-row-group #archival_object_#{@created_archival_object_id}" + expect(page).to have_css "#tree-container #resource_#{@resource_id} + .table-row-group #archival_object_#{@created_record_id}" end Then 'the Archival Object with Title {string} is saved as a sibling of the selected Archival Object' do |title| @@ -120,7 +120,7 @@ expect(archival_objects.length).to eq 1 expect(archival_objects[0][:class]).to include 'indent-level-1 current' - expect(page).to have_css "#tree-container #resource_#{@resource_id} + .table-row-group #archival_object_#{@created_archival_object_id}" + expect(page).to have_css "#tree-container #resource_#{@resource_id} + .table-row-group #archival_object_#{@created_record_id}" end Then 'the New Archival Object page is displayed' do diff --git a/staff_features/shared/step_definitions.rb b/staff_features/shared/step_definitions.rb index e1fa09e..9305e24 100644 --- a/staff_features/shared/step_definitions.rb +++ b/staff_features/shared/step_definitions.rb @@ -44,7 +44,8 @@ When 'the user clicks on {string}' do |string| click_on_string string - wait_for_ajax if current_url.include? "resources/#{@resource_id}/edit" + wait_for_ajax if current_url.include?("resources/#{@resource_id}/edit") || + current_url.include?("digital_objects/#{@digital_object_id}/edit") end When 'the user clicks on {string} in the record toolbar' do |string| @@ -238,11 +239,11 @@ end Then('the {string} created message is displayed') do |string| - wait_for_ajax if current_url.include?('resources' || 'digital_objects') + wait_for_ajax if current_url.include?('resources') || current_url.include?('digital_objects') expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*created.*$/i) - @created_archival_object_id = extract_created_record_id(string) + @created_record_id = extract_created_record_id(string) end Then('the {string} updated message is displayed') do |string|