Skip to content

Commit

Permalink
Accession spawn Archival Object
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Nov 27, 2024
1 parent 4169f6c commit cadbb5f
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 52 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ Layout/LineLength:
Layout/ElseAlignment:
Enabled: false

Layout/LineLength:
Max: 174

Style/ConditionalAssignment:
Enabled: false

Expand Down
19 changes: 19 additions & 0 deletions helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,25 @@ def create_resource(uuid)
find('button', text: 'Save Resource', match: :first).click

expect(page).to have_text "Resource Resource #{uuid} created"

uri_parts = current_url.split('/')
uri_parts.pop
@resource_id = uri_parts.pop

create_resource_archival_object(uuid)
end

def create_resource_archival_object(uuid)
click_on 'Add Child'

expect(page).to have_css '#archival_object_title_'

fill_in 'Title', with: "Archival Object #{uuid}"
fill_in 'Component Unique Identifier', with: uuid
select 'Class', from: 'Level of Description'

find('button', text: 'Save Archival Object', match: :first).click
expect(page).to have_text "Archival Object Archival Object #{uuid} on Resource Resource #{uuid} created"
end

def create_accession(uuid)
Expand Down
26 changes: 26 additions & 0 deletions staff_features/accessions/accession_spawn_archival_object.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Feature: Accession spawn Archival Object
Background:
Given an administrator user is logged in
And an Accession has been created
And a Resource has been created
And the Accession is opened in edit mode
Scenario: Archival Object form is prefilled with Accession data
When the user clicks on 'Spawn'
And the user clicks on 'Archival Object' in the spawn dropdown menu
And the user selects Resource in the modal
And the user clicks on an Archival Object in the Component Position modal
And the user clicks on 'Insert spawned component before'
And the user clicks on 'Select Component Position'
Then the New Archival Object page is displayed
And the Archival Object has been spawned from Accession info message is displayed
And the Archival Object title is filled in with the Accession Title
And the Archival Object publish is set from the Accession publish
And the Archival Object notes are set from the Accession Content Description and Condition Description
And the following Archival Object forms have the same values as the Accession
| Agent Links |
| Accession Links |
| Subjects |
| Languages |
| Dates |
| Extents |
| Rights Statements |
40 changes: 0 additions & 40 deletions staff_features/accessions/accessions_archival_object_spawn.feature

This file was deleted.

4 changes: 2 additions & 2 deletions staff_features/accessions/step_definitions/accession_edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
end

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

Then 'the Accession Title field has the original value' do
Expand All @@ -67,7 +67,7 @@
Then 'the Accession Date field has the original value' do
visit "#{STAFF_URL}/accessions/#{@accession_id}/edit"

expect(page).to have_field('Accession Date', with: ORIGINAL_ACCESSION_DATE)
expect(find('#accession_accession_date_').value).to eq ORIGINAL_ACCESSION_DATE
end

When 'the Accession Identifier field has the original value' do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# frozen_string_literal: true

When 'the user selects Resource in the modal' do
within '#linkResourceModal' do
fill_in 'filter-text', with: @uuid
within '.search-listing-filter' do
find('button').click
end

rows = all('#tabledSearchResults tbody tr')
expect(rows.length).to eq 1
rows[0].click

click_on 'Select Resource'
end
end

When 'the user clicks on an Archival Object in the Component Position modal' do
within '#linkResourceModal' do
click_on "Archival Object #{@uuid}"
end
end

Then 'the New Archival Object page is displayed' do
expect(current_url).to include 'archival_objects/new'
end

Then 'the Archival Object has been spawned from Accession info message is displayed' do
message = "This Archival Object has been spawned from Accession Accession Title #{@uuid}. This record is unsaved. You must click Save for the record to be created in the system."

expect(page).to have_text message
end

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

Then 'the Archival Object publish is set from the Accession publish' do
expect(find('#archival_object_publish_').checked?).to eq true
end

Then 'the following Archival 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 'Agent Links'
expect(find('#archival_object_linked_agents__0__role_').value).to eq 'creator'
expect(find('#archival_object_linked_agents__0__title_').value).to eq "Accession #{@uuid} Agent Title"
expect(find('#archival_object_linked_agents__0__relator_').value).to eq 'Annotator'
expect(find('#archival_object_linked_agents__0__ref__combobox .token-input-token').text).to include 'test_agent'
when 'Accession Links'
expect(find('#archival_object_accession_links__0_ .token-input-token').text).to include "Accession #{@uuid}: Accession Title #{@uuid}"
when 'Subjects'
expect(find('#archival_object_subjects__0_ .token-input-token').text).to include 'test_subject_term'
when 'Languages'
expect(find('#archival_object_lang_materials__0__language_and_script__language_').value).to eq 'English'
expect(find('#archival_object_lang_materials__0__language_and_script__script_').value).to eq 'Adlam'
when 'Dates'
expect(find('#archival_object_dates__0__label_').value).to eq 'creation'
expect(find('#archival_object_dates__0__date_type_').value).to eq 'single'
expect(find('#archival_object_dates__0__begin_').value).to eq ORIGINAL_ACCESSION_DATE
when 'Extents'
expect(find('#archival_object_extents__0__portion_').value).to eq 'whole'
expect(find('#archival_object_extents__0__number_').value).to eq @uuid
expect(find('#archival_object_extents__0__extent_type_').value).to eq 'cassettes'
when 'Rights Statements'
expect(find('#archival_object_rights_statements__0__rights_type_').value).to eq 'copyright'
expect(find('#archival_object_rights_statements__0__status_').value).to eq 'copyrighted'
expect(find('#archival_object_rights_statements__0__jurisdiction_').value).to eq 'Andorra'
expect(find('#archival_object_rights_statements__0__start_date_').value).to eq ORIGINAL_ACCESSION_DATE
else
raise "Invalid form provided: #{form_title}"
end
end
end

Then 'the Archival Object notes are set from the Accession Content Description and Condition Description' do
notes = all('#notes .subrecord-form-wrapper')
expect(notes.length).to eq 2

notes[0].click
expect(find('#archival_object_notes__0__label_').value).to eq 'Content Description'
expect(find('#archival_object_notes__0__type_').value).to eq 'scopecontent'
expect(find('#archival_object_notes__0__subnotes__0_ textarea', match: :first, visible: false).value).to eq "Content Description #{@uuid}"

notes[1].click
expect(find('#archival_object_notes__1__label_').value).to eq 'Condition Description'
expect(find('#archival_object_notes__1__type_').value).to eq 'physdesc'
expect(find('#archival_object_notes__1__content__0_ textarea', match: :first, visible: false).value).to eq "Condition Description #{@uuid}"
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
end

Given 'the user is on the Resource edit page' do
search(@uuid)

click_on 'Edit'
visit "#{STAFF_URL}/resources/#{@resource_id}/edit"
end

Then 'Repository Processing Note has value {string}' do |value|
Expand Down
13 changes: 9 additions & 4 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@
end

When 'the user clicks on {string} in the dropdown menu' do |string|
dropdown_menu = find('.dropdown-menu')

within dropdown_menu do
click_on_string string
within '.dropdown-menu' do |dropdown_menu|
elements = dropdown_menu.all(:xpath, ".//*[contains(text(), '#{string}')]")

elements.each do |element|
if (element.tag_name == 'button' || element.tag_name == 'a') && element.text == string
element.click
break
end
end
end
end

Expand Down

0 comments on commit cadbb5f

Please sign in to comment.