Skip to content

Commit c70c8fe

Browse files
committed
Fix tests
1 parent 2098cf8 commit c70c8fe

File tree

5 files changed

+50
-53
lines changed

5 files changed

+50
-53
lines changed

spec/support/autoload/page_objects/govuk_task_list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class GovukTaskList < SitePrism::Section
1010
end
1111

1212
def find_item(text)
13-
items.find { |item| item.name_and_hint.text == text }
13+
items.find { |item| item.name_and_hint.text.include?(text) }
1414
end
1515

1616
def click_item(link_text)

spec/support/autoload/page_objects/teacher_interface/check_further_information_request_answers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class CheckFurtherInformationRequestAnswers < SitePrism::Page
66
set_url "/teacher/application/further_information_requests/{request_id}/edit"
77

88
element :heading, ".govuk-heading-xl"
9-
section :summary_list, GovukSummaryList, ".govuk-summary-list"
9+
sections :summary_lists, GovukSummaryList, ".govuk-summary-list"
1010
element :submit_button, ".govuk-button"
1111
end
1212
end

spec/support/autoload/page_objects/teacher_interface/further_information_requested.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class FurtherInformationRequested < SitePrism::Page
66
set_url "/teacher/application/further_information_requests/{request_id}"
77

88
element :heading, ".govuk-heading-l"
9-
section :task_list, GovukTaskList, ".govuk-task-list"
9+
sections :task_lists, GovukTaskList, ".govuk-task-list"
1010

1111
element :check_your_answers_button,
1212
".govuk-button:not(.govuk-button--secondary)"

spec/system/teacher_interface/further_information_spec.rb

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@
33
require "rails_helper"
44

55
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+
617
before do
718
given_i_am_authorized_as_a_user(teacher)
8-
given_there_is_an_application_form
19+
given_there_is_an_application_form_with_assessment
920
given_malware_scanning_is_enabled
1021
end
1122

@@ -106,10 +117,6 @@
106117
end
107118
end
108119

109-
def given_there_is_an_application_form
110-
application_form
111-
end
112-
113120
def when_i_click_the_start_button
114121
teacher_further_information_requested_start_page.start_button.click
115122
end
@@ -151,22 +158,22 @@ def when_i_click_the_text_task_list_item
151158
expect(
152159
teacher_further_information_required_page.failure_reason_heading.text,
153160
).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",
155162
)
156163
end
157164

158165
def when_i_click_the_work_history_contact_task_list_item
159166
work_history_task_list_item.click
160167
expect(
161168
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")
163170
end
164171

165172
def when_i_click_the_document_task_list_item
166173
document_task_list_item.click
167174
expect(
168175
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")
170177
end
171178

172179
def when_i_fill_in_the_response
@@ -208,25 +215,21 @@ def when_i_click_the_check_your_answers_task_list_item
208215
end
209216

210217
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(
212219
"Check your answers before submitting",
213220
)
214221
end
215222

216223
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
221225

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)
228227

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")
230233
end
231234

232235
def when_i_click_the_text_check_your_answers_item
@@ -246,7 +249,7 @@ def and_i_see_the_further_information_received_information
246249
"Further information successfully submitted",
247250
)
248251
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}",
250253
)
251254
end
252255

@@ -268,64 +271,56 @@ def and_i_receive_a_further_information_received_email
268271
expect(message.to).to include(application_form.teacher.email)
269272
end
270273

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
293286
end
294287

295288
def further_information_request
296-
application_form.assessment.further_information_requests.first
289+
application_form.reload.assessment.further_information_requests.first
297290
end
298291

299292
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(
301294
"Tell us more about the subjects you can teach",
302295
)
303296
end
304297

305298
def text_check_answers_item
306299
teacher_check_further_information_request_answers_page
307-
.summary_list
300+
.summary_lists
301+
.second
308302
.rows
309303
.first
310304
end
311305

312306
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(
314308
"Update reference details for #{application_form.work_histories.first.school_name}",
315309
)
316310
end
317311

318312
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(
320314
"Upload your identity document",
321315
)
322316
end
323317

324318
def document_check_answers_item
325319
teacher_check_further_information_request_answers_page
326-
.summary_list
320+
.summary_lists
321+
.first
327322
.rows
328-
.last
323+
.first
329324
end
330325

331326
def then_i_see_the_warning_text

spec/view_objects/teacher_interface/further_information_request_view_object_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
status: "not_started",
8686
value: nil,
8787
value_title: "Your response",
88+
assessor_note: text_item.failure_reason_assessor_feedback,
8889
],
8990
},
9091
)
@@ -108,6 +109,7 @@
108109
status: "not_started",
109110
value: document_item.document,
110111
value_title: "Identity documents",
112+
assessor_note: document_item.failure_reason_assessor_feedback,
111113
],
112114
},
113115
)

0 commit comments

Comments
 (0)