From 1905d94f2f2fedf4f967bbe2b1b427cb17ff7745 Mon Sep 17 00:00:00 2001 From: Konstantina Dimopoulou <13031341+kdimopulu@users.noreply.github.com> Date: Sat, 28 Dec 2024 21:02:31 +0200 Subject: [PATCH] Resource container instance (#50) --- helpers/helpers.rb | 2 ++ .../resource_container_instance.feature | 18 ++++++++++++++++++ .../step_definitions/resource_edit.rb | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 staff_features/resources/resource_container_instance.feature diff --git a/helpers/helpers.rb b/helpers/helpers.rb index 5c40d4b..292d12e 100644 --- a/helpers/helpers.rb +++ b/helpers/helpers.rb @@ -236,6 +236,8 @@ def create_resource(uuid) page.execute_script("$('#resource_notes__0__content__0_').data('CodeMirror').setValue('#{@uuid}')") end + @resource_number_of_instances = 0 + find('button', text: 'Save Resource', match: :first).click expect(page).to have_text "Resource Resource #{uuid} created" diff --git a/staff_features/resources/resource_container_instance.feature b/staff_features/resources/resource_container_instance.feature new file mode 100644 index 0000000..002da7b --- /dev/null +++ b/staff_features/resources/resource_container_instance.feature @@ -0,0 +1,18 @@ +Feature: Resource Container Instance + Background: + Given an administrator user is logged in + And a Resource has been created + And the Resource is opened in edit mode + Scenario: Add container instance + When the user clicks on 'Instances' + And the user clicks on 'Add Container Instance' + And the user selects 'Accession' from 'Type' in the 'Instances' form + And the user clicks on the first dropdown in the "Instances" form + And the user clicks on "Create" in the dropdown menu in the "Instances" form + And the user fills in 'Indicator' with 'Top Container Indicator' in the modal + And the user clicks on 'Create and Link' in the modal + And the user clicks on 'Save Resource' + Then the 'Resource' updated message is displayed + And a new Instance is added to the Resource with the following values + | Type | Accession | + | Top Container | Top Container Indicator | diff --git a/staff_features/resources/step_definitions/resource_edit.rb b/staff_features/resources/step_definitions/resource_edit.rb index 12b592e..73bf320 100644 --- a/staff_features/resources/step_definitions/resource_edit.rb +++ b/staff_features/resources/step_definitions/resource_edit.rb @@ -72,3 +72,20 @@ notes = all('#resource_notes_ .subrecord-form-wrapper') expect(notes.length).to eq 0 end + +Then 'a new Instance is added to the Resource with the following values' do |form_values_table| + instances = all('#resource_instances_ .subrecord-form-list li.subrecord-form-wrapper') + + expect(instances.length).to eq @resource_number_of_instances + 1 + + instance = instances.last + + form_values_hash = form_values_table.rows_hash + form_values_hash.each do |field, value| + if field == 'Top Container' + expect(find('.top_container').text).to eq value + else + expect(instance.find_field(field, visible: true).value).to eq value.downcase.gsub(' ', '_') + end + end +end