diff --git a/staff_features/subjects/step_definitions/subject_edit.rb b/staff_features/subjects/step_definitions/subject_edit.rb index 0d83f25a..b7a7c4a6 100644 --- a/staff_features/subjects/step_definitions/subject_edit.rb +++ b/staff_features/subjects/step_definitions/subject_edit.rb @@ -52,3 +52,16 @@ expect(elements.length).to eq 0 end + +Then 'a new External Document is added to the Subject with the following values' do |form_values_table| + records = all('#subject_external_documents_ .subrecord-form-list li') + + expect(records.length).to eq @subject_number_of_external_documents + 1 + + created_record = records.last + + form_values_hash = form_values_table.rows_hash + form_values_hash.each do |field, value| + expect(created_record.find_field(field).value.downcase.gsub(' ', '_')).to eq value.downcase.gsub(' ', '_') + end +end diff --git a/staff_features/subjects/step_definitions/subject_view.rb b/staff_features/subjects/step_definitions/subject_view.rb index f7c43dd4..9ae967c4 100644 --- a/staff_features/subjects/step_definitions/subject_view.rb +++ b/staff_features/subjects/step_definitions/subject_view.rb @@ -7,6 +7,8 @@ select 'Art & Architecture Thesaurus', from: 'subject_source_' select 'Cultural context', from: 'subject_terms__0__term_type_' + @subject_number_of_external_documents = 0 + click_on 'Save' expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Created' diff --git a/staff_features/subjects/subject_add_external_document.feature b/staff_features/subjects/subject_add_external_document.feature new file mode 100644 index 00000000..52c8fb18 --- /dev/null +++ b/staff_features/subjects/subject_add_external_document.feature @@ -0,0 +1,22 @@ +Feature: Subject External Documemt + Background: + Given an administrator user is logged in + And a Subject has been created + And the Subject is opened in edit mode + Scenario: Add External Document + When the user clicks on 'External Documents' + And the user clicks on 'Add External Document' + And the user fills in 'Title' with 'Test title' + And the user fills in 'Location' with 'Test location' + And the user clicks on 'Save Subject' + Then the 'Subject' saved message is displayed + And a new External Document is added to the Subject with the following values + | Title | Test title | + | Location | Test location | + Scenario: External Document is not added because required fields are missing + When the user clicks on 'External Documents' + And the user clicks on 'Add External Document' + And the user clicks on 'Save Subject' + Then the following error messages are displayed + | Title - Property is required but was missing | + | Location - Property is required but was missing |