Skip to content

Commit 8b0360c

Browse files
Digital object component create
1 parent c3ebbb7 commit 8b0360c

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

helpers/helpers.rb

+2
Original file line numberDiff line numberDiff line change
@@ -325,4 +325,6 @@ def wait_for_ajax
325325

326326
def extract_created_record_id(string)
327327
current_url.split(':archival_object_').pop if string.include?('Archival Object')
328+
current_url.split(':digital_object_').pop if string.include?('Digital Object')
329+
current_url.split(':digital_object_component_').pop if string.include?('Digital Object Component')
328330
end

staff_features/digital_objects/step_definitions/digital_object_shared.rb

+47
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,50 @@
5757

5858
expect(page).to have_field('Identifier', with: "Digital Object Identifier #{@uuid}")
5959
end
60+
61+
Then 'the Digital Object Component with Label {string} is saved as a child of the Digital Object' do |text|
62+
records = all('#tree-container .table-row', text:)
63+
64+
expect(records.length).to eq 1
65+
expect(records[0][:class]).to include 'indent-level-1 current'
66+
67+
expect(page).to have_css "#tree-container #digital_object_#{@digital_object_id} + .table-row-group #digital_object_component_#{@created_record_id}"
68+
end
69+
70+
Then 'the Digital Object Component with Title {string} is saved as a sibling of the selected Digital Object Component' do |title|
71+
records = all('#tree-container .table-row', text: title)
72+
73+
expect(records.length).to eq 1
74+
expect(records[0][:class]).to include 'indent-level-1 current'
75+
expect(page).to have_css "#tree-container #digital_object_#{@digital_object_id} + .table-row-group #digital_object_component_#{@created_record_id}"
76+
end
77+
78+
Given 'a Digital Object with a Digital Object Component has been created' do
79+
visit "#{STAFF_URL}/digital_objects/new"
80+
81+
fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}"
82+
fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}"
83+
84+
click_on 'Add Date'
85+
select 'Single', from: 'digital_object_dates__0__date_type_'
86+
fill_in 'digital_object_dates__0__begin_', with: '2000-01-01'
87+
88+
click_on 'Save'
89+
90+
wait_for_ajax
91+
expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created"
92+
@digital_object_id = current_url.split('::digital_object_').pop
93+
94+
click_on 'Add Child'
95+
wait_for_ajax
96+
97+
fill_in 'Label', with: "Digital Object Component Label #{@uuid}"
98+
click_on 'Save'
99+
wait_for_ajax
100+
101+
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Component created on Digital Object Digital Object Title #{@uuid}"
102+
end
103+
104+
And 'the user selects the Digital Object Component' do
105+
click_on "Digital Object Component Label #{@uuid}"
106+
end

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|
@@ -238,11 +239,11 @@
238239
end
239240

240241
Then('the {string} created message is displayed') do |string|
241-
wait_for_ajax if current_url.include?('resources' || 'digital_objects')
242+
wait_for_ajax if current_url.include?('resources') || current_url.include?('digital_objects')
242243

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

245-
@created_archival_object_id = extract_created_record_id(string)
246+
@created_record_id = extract_created_record_id(string)
246247
end
247248

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

0 commit comments

Comments
 (0)