Skip to content

Commit 8b6f1d5

Browse files
authored
Digital Object Component Create (#71)
1 parent b605144 commit 8b6f1d5

File tree

5 files changed

+73
-14
lines changed

5 files changed

+73
-14
lines changed

helpers/helpers.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -329,5 +329,9 @@ def wait_for_ajax
329329
end
330330

331331
def extract_created_record_id(string)
332-
current_url.split(':archival_object_').pop if string.include?('Archival Object')
332+
return current_url.split(':archival_object_').pop if string.include?('Archival Object')
333+
334+
return current_url.split(':digital_object_component_').pop if string.include?('Digital Object Component')
335+
336+
current_url.split(':digital_object_').pop if string.include?('Digital Object')
333337
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Feature: Digital Object Component Create
2+
Background:
3+
Given an administrator user is logged in
4+
Scenario: Create a Child Digital Object
5+
Given a Digital Object has been created
6+
And the Digital Object is opened in edit mode
7+
When the user clicks on 'Add Child'
8+
And the user fills in 'Label' with 'Digital Object Component Label Child'
9+
And the user clicks on 'Save'
10+
Then the 'Digital Object Component' created message is displayed
11+
And the Digital Object Component with Label 'Digital Object Component Label Child' is saved as a child of the Digital Object
12+
Scenario: Create a Sibling Digital Object
13+
Given a Digital Object with a Digital Object Component has been created
14+
And the Digital Object is opened in edit mode
15+
When the user selects the Digital Object Component
16+
And the user clicks on 'Add Sibling'
17+
And the user fills in 'Label' with 'Digital Object Component Label Sibling'
18+
And the user clicks on 'Save'
19+
Then the 'Digital Object Component' created message is displayed
20+
And the Digital Object Component with Title 'Digital Object Component Label Sibling' is saved as a sibling of the selected Digital Object Component

staff_features/digital_objects/step_definitions/digital_object_shared.rb

+42-8
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,49 @@
158158
expect(page).to have_text "Digital Object Title #{@uuid}"
159159
end
160160

161-
Then 'the Assessment is linked to the Digital Object in the {string} form' do |form_title|
162-
section_title = find('h3', text: form_title)
163-
section = section_title.ancestor('section')
164-
expect(section[:id]).to_not eq nil
161+
Then 'the Digital Object Component with Label {string} is saved as a child of the Digital Object' do |text|
162+
records = all('#tree-container .table-row', text:)
165163

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

168-
expect(related_accessions_elements.length).to eq 1
169-
related_accession = related_accessions_elements[0].find('.digital_object')
167+
expect(page).to have_css "#tree-container #digital_object_#{@digital_object_id} + .table-row-group #digital_object_component_#{@created_record_id}"
168+
end
169+
170+
Then 'the Digital Object Component with Title {string} is saved as a sibling of the selected Digital Object Component' do |title|
171+
records = all('#tree-container .table-row', text: title)
172+
173+
expect(records.length).to eq 1
174+
expect(records[0][:class]).to include 'indent-level-1 current'
175+
expect(page).to have_css "#tree-container #digital_object_#{@digital_object_id} + .table-row-group #digital_object_component_#{@created_record_id}"
176+
end
177+
178+
Given 'a Digital Object with a Digital Object Component has been created' do
179+
visit "#{STAFF_URL}/digital_objects/new"
180+
181+
fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}"
182+
fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}"
183+
184+
click_on 'Add Date'
185+
select 'Single', from: 'digital_object_dates__0__date_type_'
186+
fill_in 'digital_object_dates__0__begin_', with: '2000-01-01'
187+
188+
click_on 'Save'
189+
190+
wait_for_ajax
191+
expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created"
192+
@digital_object_id = current_url.split('::digital_object_').pop
193+
194+
click_on 'Add Child'
195+
wait_for_ajax
196+
197+
fill_in 'Label', with: "Digital Object Component Label #{@uuid}"
198+
click_on 'Save'
199+
wait_for_ajax
200+
201+
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}"
202+
end
170203

171-
expect(related_accession[:'data-content']).to include "digital_objects/#{@digital_object_id}"
204+
And 'the user selects the Digital Object Component' do
205+
click_on "Digital Object Component Label #{@uuid}"
172206
end

staff_features/resources/step_definitions/resource_archival_object_create.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@
112112

113113
expect(archival_objects.length).to eq 1
114114
expect(archival_objects[0][:class]).to include 'indent-level-1 current'
115-
expect(page).to have_css "#tree-container #resource_#{@resource_id} + .table-row-group #archival_object_#{@created_archival_object_id}"
115+
expect(page).to have_css "#tree-container #resource_#{@resource_id} + .table-row-group #archival_object_#{@created_record_id}"
116116
end
117117

118118
Then 'the Archival Object with Title {string} is saved as a sibling of the selected Archival Object' do |title|
119119
archival_objects = all('#tree-container .table-row', text: title)
120120

121121
expect(archival_objects.length).to eq 1
122122
expect(archival_objects[0][:class]).to include 'indent-level-1 current'
123-
expect(page).to have_css "#tree-container #resource_#{@resource_id} + .table-row-group #archival_object_#{@created_archival_object_id}"
123+
expect(page).to have_css "#tree-container #resource_#{@resource_id} + .table-row-group #archival_object_#{@created_record_id}"
124124
end
125125

126126
Then 'the New Archival Object page is displayed' do

staff_features/shared/step_definitions.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
When 'the user clicks on {string}' do |string|
4545
click_on_string string
4646

47-
wait_for_ajax if current_url.include? "resources/#{@resource_id}/edit"
47+
wait_for_ajax if current_url.include?("resources/#{@resource_id}/edit") ||
48+
current_url.include?("digital_objects/#{@digital_object_id}/edit")
4849
end
4950

5051
When 'the user clicks on {string} in the record toolbar' do |string|
@@ -248,11 +249,11 @@
248249
end
249250

250251
Then('the {string} created message is displayed') do |string|
251-
wait_for_ajax if current_url.include?('resources' || 'digital_objects')
252+
wait_for_ajax if current_url.include?('resources') || current_url.include?('digital_objects')
252253

253254
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*created.*$/i)
254255

255-
@created_archival_object_id = extract_created_record_id(string)
256+
@created_record_id = extract_created_record_id(string)
256257
end
257258

258259
Then('the {string} updated message is displayed') do |string|

0 commit comments

Comments
 (0)