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 edit #58

Open
wants to merge 2 commits into
base: master
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
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
40 changes: 40 additions & 0 deletions staff_features/digital_objects/digital_object_edit.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Feature: Digital Object Edit
Background:
Given an administrator user is logged in
And a Digital Object has been created
Scenario: Digital Object is opened in the edit mode from the browse menu
Given the Digital Object appears in the search results list
When the user clicks on 'Edit'
Then the Digital Object is opened in the edit mode
Scenario: Digital Object is opened in the edit mode from the view mode
Given the Digital Object is opened in the view mode
When the user clicks on 'Edit'
Then the Digital Object is opened in the edit mode
Scenario Outline: Digital Object is successfully updated
Given the Digital Object is opened in edit mode
When the user changes the '<Field>' field to '<NewValue>'
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 |
Scenario: Digital Object is not updated after changes are reverted
Given the Digital Object is opened in 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 edit mode
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 |
Scenario: Digital Object update fails due to missing required field
Given the Digital Object is opened in edit mode
When the user clears the 'Identifier' field
And the user clicks on 'Save'
Then the following error message is displayed
| Identifier - Property is required but was missing |
And the Digital Object Identifier field has the original value
12 changes: 0 additions & 12 deletions staff_features/digital_objects/digital_object_shared.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #55 - necessary?

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

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

wait_for_ajax
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
10 changes: 8 additions & 2 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,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 All @@ -240,7 +246,7 @@
end

Then('the {string} updated message is displayed') do |string|
wait_for_ajax if current_url.include? 'resources'
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}.*updated$/i)
end
Expand Down
Loading