|
67 | 67 | # 27 - 8 = 19 (Questions left) |
68 | 68 | expect(page).to have_text('17/19 answered') |
69 | 69 |
|
70 | | - condition.remove_data.each.map do |question_id| |
71 | | - expect(page).to have_no_selector("#answer-form-#{question_id}") |
72 | | - end |
73 | | - |
74 | | - expected_remaining_question_ids = @all_questions_ids - condition.remove_data |
75 | | - |
76 | | - expected_remaining_question_ids.each.map do |question_id| |
77 | | - expect(page).to have_selector("#answer-form-#{question_id}") |
78 | | - end |
| 70 | + check_remove_data_effect_on_answer_form_selectors(condition.remove_data) |
79 | 71 |
|
80 | 72 | # Now uncheck checkbox_conditional_question answer. |
81 | 73 | within("#answer-form-#{@conditional_questions[:checkbox].id}") do |
|
144 | 136 | # 24 -8 + 1 = 17 (Answers left) |
145 | 137 | # 27 - 8 = 19 (Questions left) |
146 | 138 | expect(page).to have_text('17/19 answered') |
147 | | - condition.remove_data.each.map do |question_id| |
148 | | - expect(page).to have_no_selector("#answer-form-#{question_id}") |
149 | | - end |
150 | | - |
151 | | - expected_remaining_question_ids = @all_questions_ids - condition.remove_data |
152 | 139 |
|
153 | | - expected_remaining_question_ids.each.map do |question_id| |
154 | | - expect(page).to have_selector("#answer-form-#{question_id}") |
155 | | - end |
| 140 | + check_remove_data_effect_on_answer_form_selectors(condition.remove_data) |
156 | 141 |
|
157 | 142 | # Now for radiobutton_conditional_question answer, there in no unchoose option, |
158 | 143 | # so we switch options to a different option without any conditions. |
|
223 | 208 | # 24 -8 + 1 = 17 (Answers left) |
224 | 209 | # 27 - 8 = 19 (Questions left) |
225 | 210 | expect(page).to have_text('17/19 answered') |
226 | | - condition.remove_data.each.map do |question_id| |
227 | | - expect(page).to have_no_selector("#answer-form-#{question_id}") |
228 | | - end |
229 | | - |
230 | | - expected_remaining_question_ids = @all_questions_ids - condition.remove_data |
231 | 211 |
|
232 | | - expected_remaining_question_ids.each.map do |question_id| |
233 | | - expect(page).to have_selector("#answer-form-#{question_id}") |
234 | | - end |
| 212 | + check_remove_data_effect_on_answer_form_selectors(condition.remove_data) |
235 | 213 |
|
236 | 214 | # Now select another option for dropdown_conditional_question. |
237 | 215 | within("#answer-form-#{@conditional_questions[:dropdown].id}") do |
@@ -350,4 +328,14 @@ def go_to_write_plan_page_and_verify_answered |
350 | 328 | # 24 non-conditional questions in total answered. |
351 | 329 | expect(page).to have_text('24/27 answered') |
352 | 330 | end |
| 331 | + |
| 332 | + def check_remove_data_effect_on_answer_form_selectors(remove_data) |
| 333 | + @all_questions_ids.each do |question_id| |
| 334 | + if remove_data.include?(question_id) |
| 335 | + expect(page).to have_no_selector("#answer-form-#{question_id}") |
| 336 | + else |
| 337 | + expect(page).to have_selector("#answer-form-#{question_id}") |
| 338 | + end |
| 339 | + end |
| 340 | + end |
353 | 341 | end |
0 commit comments