Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 2db2fb2

Browse files
Resource spawn with full subercords
1 parent 0841f0f commit 2db2fb2

File tree

5 files changed

+118
-2
lines changed

5 files changed

+118
-2
lines changed

helpers/helpers.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ def ensure_test_subject_exists
140140
end
141141
end
142142

143+
def ensure_test_classification_exists
144+
visit STAFF_URL
145+
146+
fill_in 'global-search-box', with: 'test_classification'
147+
find('#global-search-button').click
148+
149+
begin
150+
find 'tr', text: 'test_classification'
151+
rescue Capybara::ElementNotFound
152+
visit "#{STAFF_URL}/classifications/new"
153+
fill_in 'classification_identifier_', with: "test_classification"
154+
fill_in 'classification_title_', with: "test_classification"
155+
click_on 'Save'
156+
end
157+
end
158+
143159
def find_user_table_row_in_manage_user_access_page(username)
144160
loop do
145161
begin

staff_features/accessions/accession_spawn_resource.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ Feature: Resource Spawn from an Accession
1010
And the Resource has been spawned from Accession info message is displayed
1111
And the Resource is linked to the Accession in the Related Accessions form
1212
And the Resource title is filled in with the Accession Title
13+
And the Resource publish is set from the Accession publish
14+
And the Resource notes are set from the Accession Content Description and Condition Description
15+
And the following Resource forms have the same values as the Accession
16+
| Agent Links |
17+
| Related Accessions |
18+
| Subjects |
19+
| Languages |
20+
| Dates |
21+
| Extents |
22+
| Rights Statements |
23+
| Metadata Rights Declarations |
24+
| Classifications |
1325
Scenario: Backing out of creating a resource record
1426
When the user clicks on 'Spawn'
1527
And the user clicks on 'Resource' in the spawn dropdown menu

staff_features/accessions/step_definitions/accession_shared.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@
6767
dropdown_items.first.click
6868
fill_in 'accession_rights_statements__0__start_date_', with: ORIGINAL_ACCESSION_RIGHTS_STATEMENT_START_DATE
6969

70+
click_on 'Add Metadata Rights Declaration'
71+
select 'This record is made available under an Universal 1.0 Public Domain Dedication Creative Commons license.', from: 'accession_metadata_rights_declarations__0__license_'
72+
fill_in 'accession_metadata_rights_declarations__0__descriptive_note_', with: "Descriptive Note #{@uuid}"
73+
fill_in 'accession_metadata_rights_declarations__0__file_uri_', with: "file-uri-#{@uuid}"
74+
select 'onLoad', from: 'accession_metadata_rights_declarations__0__file_version_xlink_actuate_attribute_'
75+
select 'embed', from: 'accession_metadata_rights_declarations__0__file_version_xlink_show_attribute_'
76+
fill_in 'accession_metadata_rights_declarations__0__xlink_title_attribute_', with: "Xlink Title Attribute #{@uuid}"
77+
fill_in 'accession_metadata_rights_declarations__0__xlink_role_attribute_', with: "Xlink Role Attribute #{@uuid}"
78+
fill_in 'accession_metadata_rights_declarations__0__xlink_arcrole_attribute_', with: "Xlink Arcrole Attribute #{@uuid}"
79+
fill_in 'accession_metadata_rights_declarations__0__last_verified_date_', with: '2000-01-01'
80+
81+
click_on 'Add Classification'
82+
fill_in 'token-input-accession_classifications__0__ref_', with: 'test_classification'
83+
dropdown_items = all('li.token-input-dropdown-item2')
84+
dropdown_items.first.click
85+
7086
click_on 'Save'
7187
expect(page).to have_text "Accession Accession Title #{@uuid} created"
7288
end

staff_features/accessions/step_definitions/accession_spawn_resource.rb

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,81 @@
3232
expect(page).to have_text message
3333
end
3434

35+
Then 'the Accession page is displayed' do
36+
expect(current_url).to include "accessions/#{@accession_id}"
37+
end
38+
3539
Then 'the Resource title is filled in with the Accession Title' do
3640
expect(find('#resource_title_').value).to eq "Accession Title #{@uuid}"
3741
end
3842

39-
Then 'the Accession page is displayed' do
40-
expect(current_url).to include "accessions/#{@accession_id}"
43+
Then 'the Resource publish is set from the Accession publish' do
44+
expect(find('#resource_publish_').checked?).to eq true
45+
end
46+
47+
Then 'the Resource notes are set from the Accession Content Description and Condition Description' do
48+
notes = all('#resource_notes_ .subrecord-form-wrapper')
49+
expect(notes.length).to eq 2
50+
51+
notes[0].click
52+
expect(find('#resource_notes__0__label_').value).to eq 'Content Description'
53+
expect(find('#resource_notes__0__type_').value).to eq 'scopecontent'
54+
expect(find('#resource_notes__0__subnotes__0_ textarea', match: :first, visible: false).value).to eq "Content Description #{@uuid}"
55+
56+
notes[1].click
57+
expect(find('#resource_notes__1__label_').value).to eq 'Condition Description'
58+
expect(find('#resource_notes__1__type_').value).to eq 'physdesc'
59+
expect(find('#resource_notes__1__content__0_ textarea', match: :first, visible: false).value).to eq "Condition Description #{@uuid}"
60+
end
61+
62+
Then 'the following Resource forms have the same values as the Accession' do |linked_record_forms|
63+
linked_record_forms.raw.each do |form_title|
64+
form_title = form_title[0]
65+
66+
section_title = find('h3', text: form_title)
67+
section = section_title.ancestor('section')
68+
expect(section[:id]).to_not eq nil
69+
70+
case form_title
71+
when 'Agent Links'
72+
expect(find('#resource_linked_agents__0__role_').value).to eq 'creator'
73+
expect(find('#resource_linked_agents__0__title_').value).to eq "Accession #{@uuid} Agent Title"
74+
expect(find('#resource_linked_agents__0__relator_').value).to eq 'Annotator'
75+
expect(find('#resource_linked_agents__0__ref__combobox .token-input-token').text).to include 'test_agent'
76+
when 'Related Accessions'
77+
expect(find('#resource_related_accessions__0_ .token-input-token').text).to include "Accession #{@uuid}: Accession Title #{@uuid}"
78+
when 'Subjects'
79+
expect(find('#resource_subjects__0_ .token-input-token').text).to include 'test_subject_term'
80+
when 'Languages'
81+
expect(find('#resource_lang_materials__0__language_and_script__language_').value).to eq 'English'
82+
expect(find('#resource_lang_materials__0__language_and_script__script_').value).to eq 'Adlam'
83+
when 'Dates'
84+
expect(find('#resource_dates__0__label_').value).to eq 'creation'
85+
expect(find('#resource_dates__0__date_type_').value).to eq 'single'
86+
expect(find('#resource_dates__0__begin_').value).to eq ORIGINAL_ACCESSION_DATE
87+
when 'Extents'
88+
expect(find('#resource_extents__0__portion_').value).to eq 'whole'
89+
expect(find('#resource_extents__0__number_').value).to eq @uuid
90+
expect(find('#resource_extents__0__extent_type_').value).to eq 'cassettes'
91+
when 'Rights Statements'
92+
expect(find('#resource_rights_statements__0__rights_type_').value).to eq 'copyright'
93+
expect(find('#resource_rights_statements__0__status_').value).to eq 'copyrighted'
94+
expect(find('#resource_rights_statements__0__jurisdiction_').value).to eq 'Andorra'
95+
expect(find('#resource_rights_statements__0__start_date_').value).to eq ORIGINAL_ACCESSION_DATE
96+
when 'Metadata Rights Declarations'
97+
expect(find('#resource_metadata_rights_declarations__0__license_').value).to eq 'public_domain'
98+
expect(find('#resource_metadata_rights_declarations__0__descriptive_note_').value).to eq "Descriptive Note #{@uuid}"
99+
expect(find('#resource_metadata_rights_declarations__0__descriptive_note_').value).to eq "Descriptive Note #{@uuid}"
100+
expect(find('#resource_metadata_rights_declarations__0__file_uri_').value).to eq "file-uri-#{@uuid}"
101+
expect(find('#resource_metadata_rights_declarations__0__file_version_xlink_actuate_attribute_').value).to eq 'onLoad'
102+
expect(find('#resource_metadata_rights_declarations__0__file_version_xlink_show_attribute_').value).to eq 'embed'
103+
expect(find('#resource_metadata_rights_declarations__0__xlink_role_attribute_').value).to eq "Xlink Role Attribute #{@uuid}"
104+
expect(find('#resource_metadata_rights_declarations__0__xlink_arcrole_attribute_').value).to eq "Xlink Arcrole Attribute #{@uuid}"
105+
expect(find('#resource_metadata_rights_declarations__0__last_verified_date_').value).to eq '2000-01-01 00:00:00 UTC'
106+
when 'Classifications'
107+
expect(find('#resource_classifications__0__ref__combobox .token-input-token').text).to include 'test_classification'
108+
else
109+
raise "Invalid form provided: #{form_title}"
110+
end
111+
end
41112
end

staff_features/shared/step_definitions.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ensure_test_user_exists
1212
ensure_test_agent_exists
1313
ensure_test_subject_exists
14+
ensure_test_classification_exists
1415
end
1516

1617
Given 'an archivist user is logged in' do

0 commit comments

Comments
 (0)