Skip to content

Commit

Permalink
Resource calculate dates (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdimopulu authored Dec 28, 2024
1 parent 2763149 commit 72cf9f2
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/
.byebug_history
tmp
7 changes: 7 additions & 0 deletions helpers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def create_resource(uuid)

select 'Single', from: 'resource_dates__0__date_type_'
fill_in 'resource_dates__0__begin_', with: ORIGINAL_RESOURCE_DATE
@resource_number_of_dates = 1

fill_in 'resource_extents__0__number_', with: '10'
select 'Cassettes', from: 'resource_extents__0__extent_type_'
Expand Down Expand Up @@ -255,6 +256,12 @@ def create_resource_archival_object(uuid)
fill_in 'Component Unique Identifier', with: uuid
select 'Class', from: 'Level of Description'

click_on 'Add Date'
within '#archival_object_dates_' do
select 'Single', from: 'Type'
fill_in 'Begin', with: '2020-01-01'
end

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
Expand Down
19 changes: 19 additions & 0 deletions staff_features/resources/resource_calculate_dates.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Resource calculate dates
Background:
Given an administrator user is logged in
And a Resource has been created
And the Resource is opened in edit mode
Scenario: Dates sub record is added to the Resource
When the user clicks on 'More'
And the user clicks on 'Calculate Dates'
And the user selects 'Calculate for all dates' in the modal
And the user clicks on 'Calculate Date Record' in the modal
And the user selects 'Single' from 'Type' in the modal
And the user fills in 'Begin' with '2022' in the modal
And the user clicks on 'Create Date Record' in the modal
And the user clicks on 'Save'
Then the 'Resource' updated message is displayed
And a new Date is added to the Resource with the following values
| Label | Creation |
| Type | Single |
| Begin | 2022 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

Then 'a new Date is added to the Resource with the following values' do |form_values_table|
dates = all('#resource_dates_ .subrecord-form-list li')

expect(dates.length).to eq @resource_number_of_dates + 1

created_date = dates.last

form_values_hash = form_values_table.rows_hash
form_values_hash.each do |field, value|
expect(created_date.find_field(field).value).to eq value.downcase.gsub(' ', '_')
end
end
10 changes: 10 additions & 0 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
end

When 'the user clicks on {string} in the modal' do |string|
wait_for_ajax

within '.modal-content' do
click_on_string string
end
Expand Down Expand Up @@ -181,7 +183,15 @@
select option, from: label, match: :first
end

When 'the user selects {string} in the modal' do |select_option|
within '.modal-content' do
find('#label').select select_option
end
end

When 'the user selects {string} from {string} in the modal' do |option, label|
wait_for_ajax

within '.modal-content' do
select option, from: label
end
Expand Down

0 comments on commit 72cf9f2

Please sign in to comment.