Skip to content

Commit 812bb43

Browse files
Digital object edit
1 parent 9e61415 commit 812bb43

File tree

5 files changed

+79
-24
lines changed

5 files changed

+79
-24
lines changed

staff_features/accessions/step_definitions/accession_edit.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
end
5656

5757
Then 'the field {string} has value {string}' do |field, value|
58-
expect(page).to have_field(field, with: value, match: :first)
58+
element = find_field(field, match: :first)
59+
60+
expect(element.value.downcase.gsub(' ', '_')).to eq value.downcase.gsub(' ', '_')
5961
end
6062

6163
Then 'the Accession Title field has the original value' do

staff_features/digital_objects/digital_object_edit.feature

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ Feature: Digital Object Edit
1111
When the user clicks on 'Edit'
1212
Then the Digital Object is opened in the edit mode
1313
Scenario Outline: Digital Object is successfully updated
14-
Given the Digital Object is opened in the edit mode
14+
Given the Digital Object is opened in edit mode
1515
When the user changes the '<Field>' field to '<NewValue>'
1616
And the user clicks on 'Save'
1717
Then the 'Digital Object' updated message is displayed
1818
And the field '<Field>' has value '<NewValue>'
19-
Examples:
20-
| Field | NewValue |
21-
| Title | Updated Test Digital Object |
22-
| Digital Object Type | Mixed Materials |
19+
Examples:
20+
| Field | NewValue |
21+
| Title | Updated Test Digital Object |
22+
| Digital Object Type | Mixed Materials |
2323
Scenario: Digital Object is not updated after changes are reverted
24-
Given the Digital Object is opened in the edit mode
24+
Given the Digital Object is opened in edit mode
2525
When the user changes the 'Title' field
2626
And the user clicks on 'Revert Changes'
2727
Then the Digital Object Title field has the original value
2828
Scenario: Digital Object update fails due to invalid date input
29-
Given the Digital Object is opened in the edit mode
30-
When the user fills in 'Begin' at 'Dates' form with '2024-13-15'
29+
Given the Digital Object is opened in edit mode
30+
When the user fills in 'Begin' with '2024-13-15' in the 'Dates' form
3131
And the user clicks on 'Save'
3232
Then the following error message is displayed
3333
| Begin - Not a valid date |
3434
Scenario: Digital Object update fails due to missing required field
35-
Given the Digital Object is opened in the edit mode
35+
Given the Digital Object is opened in edit mode
3636
When the user clears the 'Identifier' field
3737
And the user clicks on 'Save'
3838
Then the following error message is displayed

staff_features/digital_objects/digital_object_shared.rb

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# frozen_string_literal: true
2+
3+
Given 'a Digital Object has been created' do
4+
visit "#{STAFF_URL}/digital_objects/new"
5+
6+
fill_in 'digital_object_digital_object_id_', with: "Digital Object Identifier #{@uuid}"
7+
fill_in 'digital_object_title_', with: "Digital Object Title #{@uuid}"
8+
9+
click_on 'Add Date'
10+
select 'Single', from: 'digital_object_dates__0__date_type_'
11+
fill_in 'digital_object_dates__0__begin_', with: '2000-01-01'
12+
13+
click_on 'Save'
14+
15+
wait_for_ajax
16+
expect(find('.alert.alert-success.with-hide-alert').text).to have_text "Digital Object Digital Object Title #{@uuid} Created"
17+
@digital_object_id = current_url.split('::digital_object_').pop
18+
end
19+
20+
Given 'the Digital Object appears in the search results list' do
21+
visit "#{STAFF_URL}/digital_objects"
22+
23+
fill_in 'filter-text', with: "Digital Object Identifier #{@uuid}"
24+
25+
within '.search-filter' do
26+
find('button').click
27+
end
28+
29+
search_result_rows = all('#tabledSearchResults tbody tr')
30+
expect(search_result_rows.length).to eq 1
31+
end
32+
33+
Then 'the Digital Object is opened in the edit mode' do
34+
wait_for_ajax
35+
expect(current_url).to include 'edit'
36+
expect(@digital_object_id).to eq current_url.split('::digital_object_').pop
37+
end
38+
39+
Given 'the Digital Object is opened in the view mode' do
40+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}"
41+
end
42+
43+
Given 'the Digital Object is opened in edit mode' do
44+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
45+
46+
wait_for_ajax
47+
end
48+
49+
Then 'the Digital Object Title field has the original value' do
50+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
51+
52+
expect(page).to have_field('Title', with: "Digital Object Title #{@uuid}")
53+
end
54+
55+
Then 'the Digital Object Identifier field has the original value' do
56+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
57+
58+
expect(page).to have_field('Identifier', with: "Digital Object Identifier #{@uuid}")
59+
end

staff_features/shared/step_definitions.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,13 @@
224224
end
225225

226226
When 'the user changes the {string} field to {string}' do |field, value|
227-
fill_in field, with: value, match: :first
227+
element = find_field(field, match: :first)
228+
229+
if element.tag_name == 'select'
230+
element.select value
231+
else
232+
element.fill_in with: value
233+
end
228234
end
229235

230236
When 'the user changes the {string} field' do |field|
@@ -240,7 +246,7 @@
240246
end
241247

242248
Then('the {string} updated message is displayed') do |string|
243-
wait_for_ajax if current_url.include? 'resources'
249+
wait_for_ajax if current_url.include?('resources') || current_url.include?('digital_objects')
244250

245251
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*updated$/i)
246252
end

0 commit comments

Comments
 (0)