Skip to content

Commit

Permalink
Accession Spawn Digital Object step definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Nov 13, 2024
1 parent 814b1bc commit 4a58f9b
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 56 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ AllCops:
Metrics/AbcSize:
Max: 50

Metrics/BlockLength:
Max: 80

Layout/LineLength:
Max: 200

Metrics/MethodLength:
Max: 50

Expand Down
1 change: 1 addition & 0 deletions helpers/original_values.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

ORIGINAL_ACCESSION_DATE = '2000-01-01'
ORIGINAL_ACCESSION_RIGHTS_STATEMENT_START_DATE = '2000-01-01'
41 changes: 10 additions & 31 deletions staff_features/accessions/accession_spawn_digital_object.feature
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
Feature: Digital Object Spawn from an Accession
Feature: Accession spawn Digital Object
Background:
Given an administrator user is logged in
And the "Spawn description for Digital Object instances from linked record" setting is enabled in the Preferences
And the "Spawn description for Digital Object instances from linked record" setting is enabled in the Repository Preferences
And an Accession has been created
And the Accession is opened in edit mode
Scenario: Accession is linked to the spawned Digital Object
When the user scrolls to the "Instances" section
And the user clicks on "Add Digital Object"
And the user selects "Create"
Scenario: Digital Object form is prefilled with Accession data
When the user clicks on "Add Digital Object" in the "Instances" form
And the user clicks on the dropdown in the "Instances" form
And the user clicks on "Create" in the dropdown menu in the "Instances" form
Then the Create Digital Object modal is displayed
And the following Digital Object forms have the same values as the Accession:
| Title |
| Date expression |
| Date Begin |
| Date End |
| Languages |
| Digital Object Note Type |
| Summary |
| Bibliography |
| Biographical/Historical |
| Conditions Governing Access |
| Conditions Governing Use |
| Custodial History |
| Dimensions |
| Existence and Location of Copies |
| Existence and Location of Originals |
| General Note |
| Physical Description |
| Immediate Source of Acquisition |
| Language of Materials |
| Legal Status |
| Preferred Citation |
| Processing Information |
| Related Materials |
| Summary |
And the Digital Object title is filled in with the Accession Title
And the following Digital Object forms have the same values as the Accession
| Languages |
| Dates |
21 changes: 0 additions & 21 deletions staff_features/accessions/step_definitions/accession_edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,6 @@
click_on 'View'
end

Given 'the Accession is opened in edit mode' do
visit "#{STAFF_URL}/accessions"

fill_in 'filter-text', with: @uuid

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

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

within search_result_rows[0] do
element = find('a', text: 'Edit')

@accession_id = URI.decode_www_form_component(element[:href]).split('/').pop
end

click_on 'Edit'
end

Then 'the Accession is updated with the new {string} as {string}' do |field, value|
fill_in field, with: value
end
Expand Down
110 changes: 110 additions & 0 deletions staff_features/accessions/step_definitions/accession_shared.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# frozen_string_literal: true

Given 'an Accession has been created' do
visit "#{STAFF_URL}/accessions/new"

fill_in 'accession_id_0_', with: "Accession #{@uuid}"
fill_in 'Title', with: "Accession Title #{@uuid}"
check 'Publish?'

fill_in 'accession_content_description_', with: "Content Description #{@uuid}"
fill_in 'accession_condition_description_', with: "Condition Description #{@uuid}"
fill_in 'accession_disposition_', with: "Disposition #{@uuid}"
fill_in 'accession_inventory_', with: "Inventory #{@uuid}"
fill_in 'accession_provenance_', with: "Provenance #{@uuid}"
fill_in 'accession_retention_rule_', with: "Retention Rule #{@uuid}"
fill_in 'accession_general_note_', with: "General Note #{@uuid}"
select 'Deposit', from: 'accession_acquisition_type_'
select 'Collection', from: 'accession_resource_type_'

fill_in 'accession_language_', with: 'english'
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
dropdown_items.first.click
fill_in 'accession_script_', with: 'adlam'
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
dropdown_items.first.click
find('#accession_restrictions_apply_').check
find('#accession_access_restrictions_').check
fill_in 'accession_access_restrictions_note_', with: "Access Restrictions Note #{@uuid}"
find('#accession_use_restrictions_').check
fill_in 'accession_use_restrictions_note_', with: "Use Restrictions Note #{@uuid}"

click_on 'Add Language'
fill_in 'Language', with: 'English'
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
dropdown_items.first.click
fill_in 'Script', with: 'adlam'
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
dropdown_items.first.click

click_on 'Add Date'
select 'Single', from: 'accession_dates__0__date_type_'
fill_in 'accession_dates__0__begin_', with: ORIGINAL_ACCESSION_DATE

click_on 'Add Extent'
fill_in 'Number', with: @uuid
select 'Cassettes', from: 'accession_extents__0__extent_type_'

click_on 'Add Agent Link'
select 'Creator', from: 'accession_linked_agents__0__role_'
fill_in 'accession_linked_agents__0__title_', with: "Accession #{@uuid} Agent Title"
fill_in 'accession_linked_agents__0__relator_', with: 'annotator'
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
dropdown_items.first.click
fill_in 'token-input-accession_linked_agents__0__ref_', with: 'test_agent'
dropdown_items = all('li.token-input-dropdown-item2')
dropdown_items.first.click

click_on 'Add Subject'
fill_in 'token-input-accession_subjects__0__ref_', with: 'test_subject'
dropdown_items = all('li.token-input-dropdown-item2')
dropdown_items.first.click

click_on 'Add Rights Statement'
select 'Copyright', from: 'accession_rights_statements__0__rights_type_'
fill_in 'accession_rights_statements__0__jurisdiction_', with: 'andorra'
dropdown_items = all('.typeahead.typeahead-long.dropdown-menu')
dropdown_items.first.click
fill_in 'accession_rights_statements__0__start_date_', with: ORIGINAL_ACCESSION_RIGHTS_STATEMENT_START_DATE

click_on 'Add Metadata Rights Declaration'
select 'This record is made available under an Universal 1.0 Public Domain Dedication Creative Commons license.',
from: 'accession_metadata_rights_declarations__0__license_'
fill_in 'accession_metadata_rights_declarations__0__descriptive_note_', with: "Descriptive Note #{@uuid}"
fill_in 'accession_metadata_rights_declarations__0__file_uri_', with: "file-uri-#{@uuid}"
select 'onLoad', from: 'accession_metadata_rights_declarations__0__file_version_xlink_actuate_attribute_'
select 'embed', from: 'accession_metadata_rights_declarations__0__file_version_xlink_show_attribute_'
fill_in 'accession_metadata_rights_declarations__0__xlink_title_attribute_', with: "Xlink Title Attribute #{@uuid}"
fill_in 'accession_metadata_rights_declarations__0__xlink_role_attribute_', with: "Xlink Role Attribute #{@uuid}"
fill_in 'accession_metadata_rights_declarations__0__xlink_arcrole_attribute_', with: "Xlink Arcrole Attribute #{@uuid}"
fill_in 'accession_metadata_rights_declarations__0__last_verified_date_', with: '2000-01-01'

click_on 'Add Classification'
fill_in 'token-input-accession_classifications__0__ref_', with: 'test_classification'
dropdown_items = all('li.token-input-dropdown-item2')
dropdown_items.first.click

click_on 'Save'
expect(page).to have_text "Accession Accession Title #{@uuid} created"
end

Given 'the Accession is opened in edit mode' do
visit "#{STAFF_URL}/accessions"

fill_in 'filter-text', with: @uuid

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

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

within search_result_rows[0] do
element = find('a', text: 'Edit')

@accession_id = URI.decode_www_form_component(element[:href]).split('/').pop
end

click_on 'Edit'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

When 'the {string} setting is enabled in the Repository Preferences' do |repository_setting_checkbox_label|
find('#user-menu-dropdown').click
click_on 'Repository Preferences (admin)'

check repository_setting_checkbox_label

click_on 'Save'
end

Then 'the Create Digital Object modal is displayed' do
expect(page).to have_css '#accession_instances__0__digital_object__ref__modal'
end

Then 'the Digital Object title is filled in with the Accession Title' do
expect(find('#digital_object_title_').value).to eq "Accession Title #{@uuid}"
end

Then 'the following Digital Object forms have the same values as the Accession' do |linked_record_forms|
linked_record_forms.raw.each do |form_title|
form_title = form_title[0]

section_title = find('h3', text: form_title)
section = section_title.ancestor('section')
expect(section[:id]).to_not eq nil

case form_title
when 'Languages'
expect(find('#digital_object_lang_materials__0__language_and_script__language_').value).to eq 'English, Middle (1100-1500)'
expect(find('#digital_object_lang_materials__0__language_and_script__script_').value).to eq 'Adlam'
when 'Dates'
expect(find('#digital_object_dates__0__label_').value).to eq 'creation'
expect(find('#digital_object_dates__0__date_type_').value).to eq 'single'
expect(find('#digital_object_dates__0__begin_').value).to eq ORIGINAL_ACCESSION_DATE
else
raise "Invalid form provided: #{form_title}"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

Given 'an Accession has been created' do
create_accession(@uuid)
end

Then 'the Accession is in the search results' do
expect(page).to have_css('tr', text: @uuid)
end
Expand Down
34 changes: 34 additions & 0 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,40 @@
click_on_string string
end

When 'the user clicks on the dropdown in the {string} form' do |form_title|
section_title = find('h3', text: form_title)
section = section_title.ancestor('section')
expect(section[:id]).to_not eq nil

within section do
find('.dropdown-toggle', match: :first).click
end
end

When 'the user clicks on {string} in the {string} form' do |string, form_title|
section_title = find('h3', text: form_title)
section = section_title.ancestor('section')
expect(section[:id]).to_not eq nil

within section do
click_on string
end
end

When 'the user clicks on {string} in the dropdown menu in the {string} form' do |string, form_title|
section_title = find('h3', text: form_title)
section = section_title.ancestor('section')
expect(section[:id]).to_not eq nil

within section do
dropdown_menu = find('.dropdown-menu')

within dropdown_menu do
click_on string
end
end
end

When 'the user clicks on {string} in the confirm popup' do |string|
within '#confirmChangesModal' do
click_on_string string
Expand Down

0 comments on commit 4a58f9b

Please sign in to comment.