3
3
require "rails_helper"
4
4
5
5
RSpec . describe "Teacher further information" , type : :system do
6
+ let ( :teacher ) { create ( :teacher ) }
7
+ let! ( :application_form ) do
8
+ create (
9
+ :application_form ,
10
+ :submitted ,
11
+ :with_work_history ,
12
+ statuses : %w[ waiting_on_further_information ] ,
13
+ teacher :,
14
+ )
15
+ end
16
+
6
17
before do
7
18
given_i_am_authorized_as_a_user ( teacher )
8
- given_there_is_an_application_form
19
+ given_there_is_an_application_form_with_assessment
9
20
given_malware_scanning_is_enabled
10
21
end
11
22
106
117
end
107
118
end
108
119
109
- def given_there_is_an_application_form
110
- application_form
111
- end
112
-
113
120
def when_i_click_the_start_button
114
121
teacher_further_information_requested_start_page . start_button . click
115
122
end
@@ -151,22 +158,22 @@ def when_i_click_the_text_task_list_item
151
158
expect (
152
159
teacher_further_information_required_page . failure_reason_heading . text ,
153
160
) . to eq (
154
- "The subjects you entered are acceptable for QTS, but the uploaded qualifications do not match them. " ,
161
+ "The subjects you entered are acceptable for QTS, but the uploaded qualifications do not match them" ,
155
162
)
156
163
end
157
164
158
165
def when_i_click_the_work_history_contact_task_list_item
159
166
work_history_task_list_item . click
160
167
expect (
161
168
teacher_further_information_required_page . failure_reason_heading . text ,
162
- ) . to eq ( "We could not verify 1 or more references you provided. " )
169
+ ) . to eq ( "We could not verify 1 or more references you provided" )
163
170
end
164
171
165
172
def when_i_click_the_document_task_list_item
166
173
document_task_list_item . click
167
174
expect (
168
175
teacher_further_information_required_page . failure_reason_heading . text ,
169
- ) . to eq ( "Your ID document is illegible or in a format we cannot accept. " )
176
+ ) . to eq ( "Your ID document is illegible or in a format we cannot accept" )
170
177
end
171
178
172
179
def when_i_fill_in_the_response
@@ -208,25 +215,21 @@ def when_i_click_the_check_your_answers_task_list_item
208
215
end
209
216
210
217
def check_your_answers_task_list_item
211
- teacher_further_information_requested_page . task_list . find_item (
218
+ teacher_further_information_requested_page . task_lists . last . find_item (
212
219
"Check your answers before submitting" ,
213
220
)
214
221
end
215
222
216
223
def and_i_see_the_check_your_answers_items
217
- rows =
218
- teacher_check_further_information_request_answers_page . summary_list . rows
219
-
220
- expect ( rows . count ) . to eq ( 3 )
224
+ lists = teacher_check_further_information_request_answers_page . summary_lists
221
225
222
- expect ( rows . first . key . text ) . to eq (
223
- "Tell us more about the subjects you can teach" ,
224
- )
225
- expect ( rows . second . key . text ) . to eq (
226
- "Update reference details for #{ application_form . work_histories . first . school_name } " ,
227
- )
226
+ expect ( lists . count ) . to eq ( 3 )
228
227
229
- expect ( rows . last . key . text ) . to eq ( "Upload your identity document" )
228
+ expect (
229
+ teacher_check_further_information_request_answers_page ,
230
+ ) . to have_content ( "Your response" ) . and have_content (
231
+ "Reference details" ,
232
+ ) . and have_content ( "Identity documents" )
230
233
end
231
234
232
235
def when_i_click_the_text_check_your_answers_item
@@ -246,7 +249,7 @@ def and_i_see_the_further_information_received_information
246
249
"Further information successfully submitted" ,
247
250
)
248
251
expect ( teacher_submitted_application_page . panel . body . text ) . to eq (
249
- "Your application reference number\n #{ @ application_form. reference } " ,
252
+ "Your application reference number\n #{ application_form . reference } " ,
250
253
)
251
254
end
252
255
@@ -268,64 +271,56 @@ def and_i_receive_a_further_information_received_email
268
271
expect ( message . to ) . to include ( application_form . teacher . email )
269
272
end
270
273
271
- def teacher
272
- @teacher ||= create ( :teacher )
273
- end
274
-
275
- def application_form
276
- @application_form ||=
277
- begin
278
- application_form =
279
- create (
280
- :application_form ,
281
- :submitted ,
282
- :with_work_history ,
283
- statuses : %w[ waiting_on_further_information ] ,
284
- teacher :,
285
- )
286
- create (
287
- :assessment ,
288
- :with_further_information_request ,
289
- application_form :,
290
- )
291
- application_form
292
- end
274
+ def given_there_is_an_application_form_with_assessment
275
+ assessment =
276
+ create ( :assessment , :with_further_information_request , application_form :)
277
+ assessment_section =
278
+ create ( :assessment_section , :personal_information , assessment :)
279
+ assessment . further_information_requests . first . items . each do |item |
280
+ create (
281
+ :selected_failure_reason ,
282
+ assessment_section : assessment_section ,
283
+ key : item . failure_reason_key ,
284
+ )
285
+ end
293
286
end
294
287
295
288
def further_information_request
296
- application_form . assessment . further_information_requests . first
289
+ application_form . reload . assessment . further_information_requests . first
297
290
end
298
291
299
292
def text_task_list_item
300
- teacher_further_information_requested_page . task_list . find_item (
293
+ teacher_further_information_requested_page . task_lists . first . find_item (
301
294
"Tell us more about the subjects you can teach" ,
302
295
)
303
296
end
304
297
305
298
def text_check_answers_item
306
299
teacher_check_further_information_request_answers_page
307
- . summary_list
300
+ . summary_lists
301
+ . second
308
302
. rows
309
303
. first
310
304
end
311
305
312
306
def work_history_task_list_item
313
- teacher_further_information_requested_page . task_list . find_item (
307
+ teacher_further_information_requested_page . task_lists . first . find_item (
314
308
"Update reference details for #{ application_form . work_histories . first . school_name } " ,
315
309
)
316
310
end
317
311
318
312
def document_task_list_item
319
- teacher_further_information_requested_page . task_list . find_item (
313
+ teacher_further_information_requested_page . task_lists . first . find_item (
320
314
"Upload your identity document" ,
321
315
)
322
316
end
323
317
324
318
def document_check_answers_item
325
319
teacher_check_further_information_request_answers_page
326
- . summary_list
320
+ . summary_lists
321
+ . first
327
322
. rows
328
- . last
323
+ . first
329
324
end
330
325
331
326
def then_i_see_the_warning_text
0 commit comments