Skip to content

Commit

Permalink
Digital object rapid data entry
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Feb 7, 2025
1 parent 2e3a706 commit 31f0140
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Feature: Digital Object Rapid Data Entry
Scenario: Validate row succeeds
When the user clicks on 'Rapid Data Entry'
And the user fills in 'Title' with 'Default Test Title' in the first row of the Rapid Data Entry table
And the user clicks on 'Validate Rows' in the modal
Then the following message is displayed
| All rows are valid |
Scenario: Validate row fails
Expand Down Expand Up @@ -39,7 +40,7 @@ Feature: Digital Object Rapid Data Entry
And the user clicks on 'Save as Template' in the modal
And the user fills in 'Template name' with 'Test Template'
And the user clicks on 'Save Template'
Then a new template with name 'Test Template' with the following data is added to the Rapid Data Entry templates
Then a new template with name 'Test Template' with the following data is added to the Digital Object Rapid Data Entry templates
| Title | Default Test Title |
| Date Type | Single |
| Begin | 2021 |
Expand All @@ -50,4 +51,4 @@ Feature: Digital Object Rapid Data Entry
And the user clicks on 'Remove Templates' in the modal
And the user checks the created Rapid Data Entry template
And the user clicks on 'Confirm Removal'
Then the template is removed from the Rapid Data Entry templates
Then the template is removed from the Digital Object Rapid Data Entry templates
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# frozen_string_literal: true

Then 'a new template with name {string} with the following data is added to the Digital Object Rapid Data Entry templates' do |template, form_values_table|
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
click_on 'Rapid Data Entry'
wait_for_ajax

click_on 'Apply an RDE Template'
find('a span', text: template, match: :first).click

table_header_cells = all('.fieldset-labels .kiketable-th-text')
table_field_rows = all('#rdeTable tbody tr')

expect(table_field_rows.length).to eq 1

form_values_hash = form_values_table.rows_hash
form_values_hash.each do |field, value|
field_position = 0
table_header_cells.each_with_index do |header, index|
field_position = index if header.text == field
end
field_position += 1
expect(field_position).to_not eq 0

table_field_cells = table_field_rows[0].all('td')
field_cell = table_field_cells[field_position]

expect(field_cell.find('input, select, textarea').value.downcase.gsub(' ', '_')).to eq value.downcase.gsub(' ', '_')
end
end

Given 'a Radpid Data Entry template has been created' do
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
click_on 'Rapid Data Entry'
wait_for_ajax

click_on 'Save as Template'
fill_in 'templateName', with: "RDE Template #{@uuid}"
click_on 'Save Template'

visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
wait_for_ajax
end

Then 'the template is removed from the Digital Object Rapid Data Entry templates' do
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
click_on 'Rapid Data Entry'
wait_for_ajax
click_on 'Apply an RDE Template'

expect(find('.dropdown-menu')).to_not have_text "RDE Template #{@uuid}"
end

Then 'the {string} has value {string} in all rows' do |label, value|
table_header_cells = all('.fieldset-labels .kiketable-th-text')

label_position = 0
table_header_cells.each_with_index do |header, index|
next if header.text != label

label_position = index
break
end

label_position += 1
expect(label_position).to_not eq 0

table_rows = all('#rdeTable tbody tr')
table_rows.each do |row|
cell = row.all('td')
expect(cell[label_position].find('input, select').value.downcase).to eq value.downcase
end
end
4 changes: 2 additions & 2 deletions staff_features/resources/resource_rapid_data_entry.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Feature: Resource Rapid Data Entry
And the user clicks on 'Save as Template' in the modal
And the user fills in 'Template name' with 'Test Template'
And the user clicks on 'Save Template'
Then a new template with name 'Test Template' with the following data is added to the Rapid Data Entry templates
Then a new template with name 'Test Template' with the following data is added to the Resource Rapid Data Entry templates
| Level of Description | File |
| Title | Default Test Title |
| Date Type | Single |
Expand All @@ -61,4 +61,4 @@ Feature: Resource Rapid Data Entry
And the user clicks on 'Remove Templates' in the modal
And the user checks the created Rapid Data Entry template
And the user clicks on 'Confirm Removal'
Then the template is removed from the Rapid Data Entry templates
Then the template is removed from the Resource Rapid Data Entry templates
Original file line number Diff line number Diff line change
@@ -1,62 +1,6 @@
# frozen_string_literal: true

When 'the user selects {string} from {string} in the first row of the Rapid Data Entry table' do |option, label|
table_header_cells = all('.fieldset-labels .kiketable-th-text')

label_position = 0
table_header_cells.each_with_index do |header, index|
label_position = index if header.text == label
end

label_position += 1
expect(label_position).to_not eq 0

table_field_cells = all('#rdeTable tbody td')
field_cell = table_field_cells[label_position]
field_cell_select = field_cell.find('select')
field_cell_select.select option
end

When 'the user fills in {string} with {string} in the first row of the Rapid Data Entry table' do |label, value|
table_header_cells = all('.fieldset-labels .kiketable-th-text')

label_position = 0
table_header_cells.each_with_index do |header, index|
label_position = index if header.text == label
end

label_position += 1
expect(label_position).to_not eq 0

table_field_cells = all('#rdeTable tbody td')
field_cell = table_field_cells[label_position]
field_cell_input = field_cell.find('input')
field_cell_input.fill_in with: value
end

Then 'a new row with the following data is added to the Rapid Data Entry table' do |form_values_table|
table_header_cells = all('.fieldset-labels .kiketable-th-text')
table_field_rows = all('#rdeTable tbody tr')

expect(table_field_rows.length).to eq 2

form_values_hash = form_values_table.rows_hash
form_values_hash.each do |field, value|
field_position = 0
table_header_cells.each_with_index do |header, index|
field_position = index if header.text == field
end
field_position += 1
expect(field_position).to_not eq 0

table_field_cells = table_field_rows[1].all('td')
field_cell = table_field_cells[field_position]

expect(field_cell.find('input, select, textarea').value.downcase.gsub(' ', '_')).to eq value.downcase.gsub(' ', '_')
end
end

Then 'a new template with name {string} with the following data is added to the Rapid Data Entry templates' do |template, form_values_table|
Then 'a new template with name {string} with the following data is added to the Resource Rapid Data Entry templates' do |template, form_values_table|
visit "#{STAFF_URL}/resources/#{@resource_id}/edit"
click_on 'Rapid Data Entry'
wait_for_ajax
Expand Down Expand Up @@ -98,48 +42,11 @@
wait_for_ajax
end

When 'the user checks the created Rapid Data Entry template' do
find('label', text: "RDE Template #{@uuid}").click
end

Then 'the template is removed from the Rapid Data Entry templates' do
Then 'the template is removed from the Resource Rapid Data Entry templates' do
visit "#{STAFF_URL}/resources/#{@resource_id}/edit"
click_on 'Rapid Data Entry'
wait_for_ajax
click_on 'Apply an RDE Template'

expect(find('.dropdown-menu')).to_not have_text "RDE Template #{@uuid}"
end

When 'the user unchecks the {string} checkbox in the dropdown menu' do |label|
uncheck label
end

Then 'the {string} column is no longer visible in the Rapid Data Entry table' do |string|
expect(page).to_not have_css('.fieldset-label.sticky.kiketable-th', text: string)
end

Then 'the {string} has value {string} in all rows' do |label, value|
table_header_cells = all('.fieldset-labels .kiketable-th-text')

label_position = 0
table_header_cells.each_with_index do |header, index|
label_position = index if header.text == label
end

label_position += 1
expect(label_position).to_not eq 0

table_rows = all('#rdeTable tbody tr')
table_rows.each do |row|
cell = row.all('td')
expect(cell[label_position].find('select').value.downcase).to eq value.downcase
end
end

Given 'a Rapid Data Entry template has been created' do
click_on 'Rapid Data Entry'
click_on 'Save as Template'
fill_in 'Template name', with: "RDE Template #{@uuid}"
click_on 'Save Template'
end
75 changes: 75 additions & 0 deletions staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,78 @@
select '', from: label
end
end

When 'the user selects {string} from {string} in the first row of the Rapid Data Entry table' do |option, label|
table_header_cells = all('.fieldset-labels .kiketable-th-text')

label_position = 0
table_header_cells.each_with_index do |header, index|
label_position = index if header.text == label
end

label_position += 1
expect(label_position).to_not eq 0

table_field_cells = all('#rdeTable tbody td')
field_cell = table_field_cells[label_position]
field_cell_select = field_cell.find('select')
field_cell_select.select option
end

When 'the user fills in {string} with {string} in the first row of the Rapid Data Entry table' do |label, value|
table_header_cells = all('.fieldset-labels .kiketable-th-text')

label_position = 0
table_header_cells.each_with_index do |header, index|
label_position = index if header.text == label
end

label_position += 1
expect(label_position).to_not eq 0

table_field_cells = all('#rdeTable tbody td')
field_cell = table_field_cells[label_position]
field_cell_input = field_cell.find('input')
field_cell_input.fill_in with: value
end

When 'the user unchecks the {string} checkbox in the dropdown menu' do |label|
uncheck label
end

Then 'the {string} column is no longer visible in the Rapid Data Entry table' do |string|
expect(page).to_not have_css('.fieldset-label.sticky.kiketable-th', text: string)
end

Then 'a new row with the following data is added to the Rapid Data Entry table' do |form_values_table|
table_header_cells = all('.fieldset-labels .kiketable-th-text')
table_field_rows = all('#rdeTable tbody tr')

expect(table_field_rows.length).to eq 2

form_values_hash = form_values_table.rows_hash
form_values_hash.each do |field, value|
field_position = 0
table_header_cells.each_with_index do |header, index|
field_position = index if header.text == field
end
field_position += 1
expect(field_position).to_not eq 0

table_field_cells = table_field_rows[1].all('td')
field_cell = table_field_cells[field_position]

expect(field_cell.find('input, select, textarea').value.downcase.gsub(' ', '_')).to eq value.downcase.gsub(' ', '_')
end
end

Given 'a Rapid Data Entry template has been created' do
click_on 'Rapid Data Entry'
click_on 'Save as Template'
fill_in 'Template name', with: "RDE Template #{@uuid}"
click_on 'Save Template'
end

When 'the user checks the created Rapid Data Entry template' do
find('label', text: "RDE Template #{@uuid}").click
end

0 comments on commit 31f0140

Please sign in to comment.