Skip to content

Commit

Permalink
Digital object edit
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Dec 24, 2024
1 parent 40d2e37 commit 548d401
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
4 changes: 3 additions & 1 deletion staff_features/accessions/step_definitions/accession_edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
end

Then 'the field {string} has value {string}' do |field, value|
expect(page).to have_field(field, with: value, match: :first)
element = find_field(field, match: :first)

expect(element.value.downcase.gsub(' ', '_')).to eq value.downcase.gsub(' ', '_')
end

Then 'the Accession Title field has the original value' do
Expand Down
10 changes: 5 additions & 5 deletions staff_features/digital_objects/digital_object_edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ Feature: Digital Object Edit
And the user clicks on 'Save'
Then the 'Digital Object' updated message is displayed
And the field '<Field>' has value '<NewValue>'
Examples:
| Field | NewValue |
| Title | Updated Test Digital Object |
| Digital Object Type | Mixed Materials |
Examples:
| Field | NewValue |
| Title | Updated Test Digital Object |
| Digital Object Type | Mixed Materials |
Scenario: Digital Object is not updated after changes are reverted
Given the Digital Object is opened in the edit mode
When the user changes the 'Title' field
And the user clicks on 'Revert Changes'
Then the Digital Object Title field has the original value
Scenario: Digital Object update fails due to invalid date input
Given the Digital Object is opened in the edit mode
When the user fills in 'Begin' at 'Dates' form with '2024-13-15'
When the user fills in 'Begin' with '2024-13-15' in the 'Dates' form
And the user clicks on 'Save'
Then the following error message is displayed
| Begin - Not a valid date |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# frozen_string_literal: true

Given 'a Digital Object 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
end

Given 'the Digital Object appears in the search results list' do
visit "#{STAFF_URL}/digital_objects"

fill_in 'filter-text', with: "Digital Object Identifier #{@uuid}"

within '.search-filter' do
find('button').click
end

search_result_rows = all('#tabledSearchResults tbody tr')
expect(search_result_rows.length).to eq 1
end

Then 'the Digital Object is opened in the edit mode' do
wait_for_ajax
expect(current_url).to include 'edit'
expect(@digital_object_id).to eq current_url.split('::digital_object_').pop
end

Given 'the Digital Object is opened in the view mode' do
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}"
end

Then 'the Digital Object Title field has the original value' do
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"

expect(page).to have_field('Title', with: "Digital Object Title #{@uuid}")
end

Then 'the Digital Object Identifier field has the original value' do
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"

expect(page).to have_field('Identifier', with: "Digital Object Identifier #{@uuid}")
end
8 changes: 7 additions & 1 deletion staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,13 @@
end

When 'the user changes the {string} field to {string}' do |field, value|
fill_in field, with: value, match: :first
element = find_field(field, match: :first)

if element.tag_name == 'select'
element.select value
else
element.fill_in with: value
end
end

When 'the user changes the {string} field' do |field|
Expand Down

0 comments on commit 548d401

Please sign in to comment.