Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digital Object Component Create #71

Open
wants to merge 2 commits into
base: digital_object_edit
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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
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 @@ -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|
Expand Down
Loading