Skip to content

Commit

Permalink
Resource container instance (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdimopulu authored Dec 28, 2024
1 parent 58884ca commit 1905d94
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 18 additions & 0 deletions staff_features/resources/resource_container_instance.feature
Original file line number Diff line number Diff line change
@@ -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 |
17 changes: 17 additions & 0 deletions staff_features/resources/step_definitions/resource_edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1905d94

Please sign in to comment.