Skip to content

Commit

Permalink
Digital Object Component Create (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdimopulu authored Feb 5, 2025
1 parent b605144 commit 8b6f1d5
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 14 deletions.
6 changes: 5 additions & 1 deletion helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,49 @@
expect(page).to have_text "Digital Object Title #{@uuid}"
end

Then 'the Assessment is linked to the Digital Object in the {string} form' do |form_title|
section_title = find('h3', text: form_title)
section = section_title.ancestor('section')
expect(section[:id]).to_not eq nil
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:)

related_accessions_elements = section.all('li.token-input-token')
expect(records.length).to eq 1
expect(records[0][:class]).to include 'indent-level-1 current'

expect(related_accessions_elements.length).to eq 1
related_accession = related_accessions_elements[0].find('.digital_object')
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

expect(related_accession[:'data-content']).to include "digital_objects/#{@digital_object_id}"
And 'the user selects the Digital Object Component' do
click_on "Digital Object Component Label #{@uuid}"
end
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@

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|
archival_objects = all('#tree-container .table-row', text: title)

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
Expand Down
7 changes: 4 additions & 3 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -248,11 +249,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|
Expand Down

0 comments on commit 8b6f1d5

Please sign in to comment.