Skip to content

Commit 7cba364

Browse files
Digital object rapid data entry
1 parent cf57b5e commit 7cba364

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

staff_features/digital_objects/digital_object_rapid_data_entry.feature

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Feature: Digital Object Rapid Data Entry
1212
Scenario: Validate row succeeds
1313
When the user clicks on 'Rapid Data Entry'
1414
And the user fills in 'Title' with 'Default Test Title' in the first row of the Rapid Data Entry table
15+
And the user clicks on 'Validate Rows' in the modal
1516
Then the following message is displayed
1617
| All rows are valid |
1718
Scenario: Validate row fails
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# frozen_string_literal: true
2+
3+
When 'the user selects {string} from {string} in the first row of the Rapid Data Entry table' do |option, label|
4+
table_header_cells = all('.fieldset-labels .kiketable-th-text')
5+
6+
label_position = 0
7+
table_header_cells.each_with_index do |header, index|
8+
label_position = index if header.text == label
9+
end
10+
11+
label_position += 1
12+
expect(label_position).to_not eq 0
13+
14+
table_field_cells = all('#rdeTable tbody td')
15+
field_cell = table_field_cells[label_position]
16+
field_cell_select = field_cell.find('select')
17+
field_cell_select.select option
18+
end
19+
20+
When 'the user fills in {string} with {string} in the first row of the Rapid Data Entry table' do |label, value|
21+
table_header_cells = all('.fieldset-labels .kiketable-th-text')
22+
23+
label_position = 0
24+
table_header_cells.each_with_index do |header, index|
25+
label_position = index if header.text == label
26+
end
27+
28+
label_position += 1
29+
expect(label_position).to_not eq 0
30+
31+
table_field_cells = all('#rdeTable tbody td')
32+
field_cell = table_field_cells[label_position]
33+
field_cell_input = field_cell.find('input')
34+
field_cell_input.fill_in with: value
35+
end
36+
37+
Then 'a new row with the following data is added to the Rapid Data Entry table' do |form_values_table|
38+
table_header_cells = all('.fieldset-labels .kiketable-th-text')
39+
table_field_rows = all('#rdeTable tbody tr')
40+
41+
expect(table_field_rows.length).to eq 2
42+
43+
form_values_hash = form_values_table.rows_hash
44+
form_values_hash.each do |field, value|
45+
field_position = 0
46+
table_header_cells.each_with_index do |header, index|
47+
field_position = index if header.text == field
48+
end
49+
field_position += 1
50+
expect(field_position).to_not eq 0
51+
52+
table_field_cells = table_field_rows[1].all('td')
53+
field_cell = table_field_cells[field_position]
54+
55+
expect(field_cell.find('input, select, textarea').value.downcase.gsub(' ', '_')).to eq value.downcase.gsub(' ', '_')
56+
end
57+
end
58+
59+
Then 'a new template with name {string} with the following data is added to the Rapid Data Entry templates' do |template, form_values_table|
60+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
61+
click_on 'Rapid Data Entry'
62+
wait_for_ajax
63+
64+
click_on 'Apply an RDE Template'
65+
find('a span', text: template, match: :first).click
66+
67+
table_header_cells = all('.fieldset-labels .kiketable-th-text')
68+
table_field_rows = all('#rdeTable tbody tr')
69+
70+
expect(table_field_rows.length).to eq 1
71+
72+
form_values_hash = form_values_table.rows_hash
73+
form_values_hash.each do |field, value|
74+
field_position = 0
75+
table_header_cells.each_with_index do |header, index|
76+
field_position = index if header.text == field
77+
end
78+
field_position += 1
79+
expect(field_position).to_not eq 0
80+
81+
table_field_cells = table_field_rows[0].all('td')
82+
field_cell = table_field_cells[field_position]
83+
84+
expect(field_cell.find('input, select, textarea').value.downcase.gsub(' ', '_')).to eq value.downcase.gsub(' ', '_')
85+
end
86+
end
87+
88+
Given 'a Radpid Data Entry template has been created' do
89+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
90+
click_on 'Rapid Data Entry'
91+
wait_for_ajax
92+
93+
click_on 'Save as Template'
94+
fill_in 'templateName', with: "RDE Template #{@uuid}"
95+
click_on 'Save Template'
96+
97+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
98+
wait_for_ajax
99+
end
100+
101+
When 'the user checks the created Rapid Data Entry template' do
102+
find('label', text: "RDE Template #{@uuid}").click
103+
end
104+
105+
Then 'the template is removed from the Rapid Data Entry templates' do
106+
visit "#{STAFF_URL}/digital_objects/#{@digital_object_id}/edit"
107+
click_on 'Rapid Data Entry'
108+
wait_for_ajax
109+
click_on 'Apply an RDE Template'
110+
111+
expect(find('.dropdown-menu')).to_not have_text "RDE Template #{@uuid}"
112+
end
113+
114+
When 'the user unchecks the {string} checkbox in the dropdown menu' do |label|
115+
uncheck label
116+
end
117+
118+
Then 'the {string} column is no longer visible in the Rapid Data Entry table' do |string|
119+
expect(page).to_not have_css('.fieldset-label.sticky.kiketable-th', text: string)
120+
end
121+
122+
Then 'the {string} has value {string} in all rows' do |label, value|
123+
table_header_cells = all('.fieldset-labels .kiketable-th-text')
124+
125+
label_position = 0
126+
table_header_cells.each_with_index do |header, index|
127+
next if header.text != label
128+
129+
label_position = index
130+
break
131+
end
132+
133+
label_position += 1
134+
expect(label_position).to_not eq 0
135+
136+
table_rows = all('#rdeTable tbody tr')
137+
table_rows.each do |row|
138+
cell = row.all('td')
139+
expect(cell[label_position].find('input').value.downcase).to eq value.downcase
140+
end
141+
end
142+
143+
Given 'a Rapid Data Entry template has been created' do
144+
click_on 'Rapid Data Entry'
145+
click_on 'Save as Template'
146+
fill_in 'Template name', with: "RDE Template #{@uuid}"
147+
click_on 'Save Template'
148+
end

0 commit comments

Comments
 (0)