diff --git a/app/controllers/teacher_interface/further_information_request_items_controller.rb b/app/controllers/teacher_interface/further_information_request_items_controller.rb index 710db9bc98..fe6a276373 100644 --- a/app/controllers/teacher_interface/further_information_request_items_controller.rb +++ b/app/controllers/teacher_interface/further_information_request_items_controller.rb @@ -21,6 +21,12 @@ def update def load_further_information_request_and_item @further_information_request_item = further_information_request_item @further_information_request = further_information_request + @view_object = view_object + end + + def view_object + @view_object ||= + FurtherInformationRequestItemViewObject.new(current_teacher:, params:) end def edit_text diff --git a/app/controllers/teacher_interface/further_information_requests_controller.rb b/app/controllers/teacher_interface/further_information_requests_controller.rb index d148c59ce0..fb2c2b47d9 100644 --- a/app/controllers/teacher_interface/further_information_requests_controller.rb +++ b/app/controllers/teacher_interface/further_information_requests_controller.rb @@ -14,6 +14,7 @@ def show end def edit + render layout: "full_from_desktop" end def update diff --git a/app/view_objects/teacher_interface/further_information_request_item_view_object.rb b/app/view_objects/teacher_interface/further_information_request_item_view_object.rb new file mode 100644 index 0000000000..020c5f4b68 --- /dev/null +++ b/app/view_objects/teacher_interface/further_information_request_item_view_object.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +module TeacherInterface + class FurtherInformationRequestItemViewObject + def initialize(current_teacher:, params:) + @current_teacher = current_teacher + @params = params + end + + def further_information_request_item + @further_information_request_item ||= + FurtherInformationRequestItem + .joins(further_information_request: :assessment) + .where( + further_information_request: { + received_at: nil, + assessments: { + application_form:, + }, + }, + ) + .find(params[:id]) + end + + def item_name + case further_information_request_item.information_type + when "text" + I18n.t( + further_information_request_item.failure_reason_key, + scope: %i[ + teacher_interface + further_information_request + show + failure_reason + ], + ) + when "work_history_contact" + "Update reference details for #{further_information_request_item.work_history.school_name}" + when "document" + if further_information_request_item.document.document_type == "passport" + "Upload your #{I18n.t("document.document_type.#{further_information_request_item.document.document_type}")}" + else + "Upload your " \ + "#{I18n.t("document.document_type.#{further_information_request_item.document.document_type}")} document" + end + end + end + + def item_description + I18n.t( + further_information_request_item.failure_reason_key, + scope: %i[ + teacher_interface + application_forms + show + declined + failure_reasons + ], + ).gsub(".", "") + end + + def application_form + @application_form ||= current_teacher.application_form + end + + private + + attr_reader :current_teacher, :params + end +end diff --git a/app/view_objects/teacher_interface/further_information_request_view_object.rb b/app/view_objects/teacher_interface/further_information_request_view_object.rb index dcf2c11279..bd9d4af269 100644 --- a/app/view_objects/teacher_interface/further_information_request_view_object.rb +++ b/app/view_objects/teacher_interface/further_information_request_view_object.rb @@ -15,41 +15,55 @@ def further_information_request .find(params[:id]) end - def task_list_items - items = - further_information_request - .items - .order(:created_at) - .map do |item| - { - title: item_name(item), - href: [ - :edit, - :teacher_interface, - :application_form, - further_information_request, - item, + def grouped_task_list_items + items_by_assessment_section.map do |assessment_section, items| + { + heading: + I18n.t( + assessment_section.key, + scope: %i[ + teacher_interface + further_information_request + show + section ], - status: item.status, - } - end - - items << { - title: - I18n.t("teacher_interface.further_information_request.show.check"), - href: - if can_check_answers? - [ - :edit, - :teacher_interface, - :application_form, - further_information_request, - ] - end, - status: can_check_answers? ? "not_started" : "cannot_start", - } + ), + items: task_list_items(items), + } + end + end - items + def check_your_answers_task_group + { + heading: + I18n.t( + :check_your_answers, + scope: %i[ + teacher_interface + further_information_request + show + section + ], + ), + items: [ + { + title: + I18n.t( + "teacher_interface.further_information_request.show.check", + ), + href: + if can_check_answers? + [ + :edit, + :teacher_interface, + :application_form, + further_information_request, + ] + end, + status: can_check_answers? ? "not_started" : "cannot_start", + }, + ], + } end def can_check_answers? @@ -58,14 +72,30 @@ def can_check_answers? alias_method :can_submit?, :can_check_answers? - def check_your_answers_fields - further_information_request - .items - .order(:created_at) - .each_with_object({}) do |item, memo| - memo[item.id] = { + def application_form + @application_form ||= current_teacher.application_form + end + + private + + attr_reader :current_teacher, :params + + def items_by_assessment_section + @items_by_assessment_section ||= + FurtherInformationRequestItemsByAssessmentSection.call( + further_information_request:, + ) + end + + def task_list_items(items) + list_items = + items.map do |item| + { title: item_name(item), + description: item_description(item), + value_title: item_value_title(item), value: item_value(item), + assessor_note: item.failure_reason_assessor_feedback, href: [ :edit, :teacher_interface, @@ -73,17 +103,28 @@ def check_your_answers_fields further_information_request, item, ], + status: item.status, } end - end - def application_form - @application_form ||= current_teacher.application_form + list_items.sort_by { |item| item[:title] } end - private - - attr_reader :current_teacher, :params + def item_value_title(item) + if item.text? + "Your response" + elsif item.document? + if item.document.document_type == "passport" + I18n.t( + "document.document_type.#{item.document.document_type}", + ).capitalize + else + "#{I18n.t("document.document_type.#{item.document.document_type}").capitalize} documents" + end + elsif item.work_history_contact? + "Reference details" + end + end def item_value(item) if item.text? @@ -91,9 +132,9 @@ def item_value(item) elsif item.document? item.document elsif item.work_history_contact? - "Contact name: #{item.contact_name}
- Contact job: #{item.contact_job}
- Contact email: #{item.contact_email}".html_safe + "#{item.contact_name}
+ #{item.contact_job}
+ #{item.contact_email}".html_safe end end @@ -104,7 +145,7 @@ def item_name(item) "teacher_interface.further_information_request.show.failure_reason.#{item.failure_reason_key}", ) when "work_history_contact" - "Add work history details" + "Update reference details for #{item.work_history.school_name}" when "document" if item.document.document_type == "passport" "Upload your #{I18n.t("document.document_type.#{item.document.document_type}")}" @@ -113,5 +154,18 @@ def item_name(item) end end end + + def item_description(item) + I18n.t( + item.failure_reason_key, + scope: %i[ + teacher_interface + application_forms + show + declined + failure_reasons + ], + ).gsub(".", "") + end end end diff --git a/app/views/teacher_interface/further_information_request_items/_inner_form.html.erb b/app/views/teacher_interface/further_information_request_items/_inner_form.html.erb index 48b1324f0a..3123573cf9 100644 --- a/app/views/teacher_interface/further_information_request_items/_inner_form.html.erb +++ b/app/views/teacher_interface/further_information_request_items/_inner_form.html.erb @@ -2,9 +2,22 @@ <%= f.govuk_error_summary %> <% end %> -

Further information required

- -

<%= I18n.t("teacher_interface.application_forms.show.declined.failure_reasons.#{@further_information_request_item.failure_reason_key}") %>

+<% + section_name = @further_information_request_item + .further_information_request + .assessment + .sections + .includes(:selected_failure_reasons) + .find_by(selected_failure_reasons: { key: @further_information_request_item.failure_reason_key }) + .key +%> +<%= I18n.t("teacher_interface.further_information_request.show.section.#{section_name}") %> +<% if @further_information_request_item.document? %> +

Review note from assessor

+<% else %> +

<%= @view_object.item_name %>

+<% end %> +

<%= @view_object.item_description %>

<%= govuk_inset_text do %> <%= simple_format @further_information_request_item.failure_reason_assessor_feedback %> @@ -20,9 +33,7 @@ <% if @further_information_request_item.work_history_contact? %> <% work_history = @further_information_request_item.work_history %> -

Enter the contact details of a suitable referee who can verify your time spent working at <%= work_history.school_name %> from <%= work_history.start_date.to_fs(:month_and_year) %> <% if work_history.end_date.present? %> - to <%= work_history.end_date.to_fs(:month_and_year) %> - <% end %>

+

Enter the contact details of a suitable referee who can verify your time spent working at <%= work_history.school_name %> from <%= work_history.start_date.to_fs(:month_and_year) %><% if work_history.end_date.present? %> to <%= work_history.end_date.to_fs(:month_and_year) %><% end %>.

<%= f.govuk_text_field :contact_name, label: {text: "Contact’s name"} %> diff --git a/app/views/teacher_interface/further_information_requests/edit.html.erb b/app/views/teacher_interface/further_information_requests/edit.html.erb index 6e745c9860..afa37cb6d3 100644 --- a/app/views/teacher_interface/further_information_requests/edit.html.erb +++ b/app/views/teacher_interface/further_information_requests/edit.html.erb @@ -1,16 +1,48 @@ <% content_for :page_title, "Check your answers before submitting" %> <% content_for :back_link_url, back_history_path(origin: true, default: teacher_interface_application_form_further_information_request_path(@view_object.further_information_request)) %> +Your application

Check your answers before submitting

-<%= render(CheckYourAnswersSummary::Component.new( - id: "check-your-answers", - model: @view_object.further_information_request, - title: t(".check_your_answers"), - fields: @view_object.check_your_answers_fields -)) %> +<% @view_object.grouped_task_list_items.each do |grouped_task_list_item| %> +

<%= grouped_task_list_item[:heading] %>

+ <% grouped_task_list_item[:items].each do |item| %> + <%= govuk_summary_card(title: item[:title] ) do |card| + card.with_summary_list do |summary_list| + summary_list.with_row do |row| + row.with_key { item[:value_title] } + row.with_value do + if item[:value].is_a?(Document) + tag.ul(class: "govuk-list") do + item[:value] + .uploads + .order(:created_at) + .each { |upload| concat(tag.li(upload_link_to(upload))) } + end + else + item[:value] + end + end + row.with_action( + href: item[:href], + visually_hidden_text: item[:title].downcase + ) + end + summary_list.with_row do |row| + row.with_key { "Note from assessor" } + row.with_value do + govuk_details(summary_text: "View note", text: item[:assessor_note]) + end + end + end + end %> + <% end %> +<% end %> <% if @view_object.can_submit? %> +

How we handle your data

+

You can read about the data we collect from you, how we use it and how it’s stored, in our <%= govuk_link_to "privacy policy", "https://www.gov.uk/government/publications/privacy-information-education-providers-workforce-including-teachers/5a254207-a566-44f7-ac77-6ba59fd26e04#using-your-data-when-you-use-the-apply-for-qualified-teacher-status-qts-in-england-service" %>.

+

Submitting your further information

By selecting the ‘Submit your response’ button you confirm that, to the best of your knowledge, the details you’ve provided are correct.

You will not be able to change your response, add new documents or delete anything once you submit it.

diff --git a/app/views/teacher_interface/further_information_requests/show.html.erb b/app/views/teacher_interface/further_information_requests/show.html.erb index 67f20218e6..0d21951b06 100644 --- a/app/views/teacher_interface/further_information_requests/show.html.erb +++ b/app/views/teacher_interface/further_information_requests/show.html.erb @@ -1,19 +1,35 @@ -<% content_for :page_title, "Apply for qualified teacher status (QTS)" %> +<% content_for :page_title, "Review the information we’ve asked for" %> <% content_for :back_link_url, back_history_path(default: teacher_interface_application_form_path) %> -

Apply for qualified teacher status (QTS)

+Your application +

Review the information we’ve asked for

-

Further information requested

+<% @view_object.grouped_task_list_items.each do |grouped_task_list_item| %> +

<%= grouped_task_list_item[:heading] %>

+ <%= govuk_task_list do |task_list| + grouped_task_list_item[:items].each do |item| + task_list.with_item do |row| + row.with_title(text: item[:title], hint: item[:description], href: item[:href]) + row.with_status(text: render(StatusTag::Component.new(item[:status])), classes: "app-white-space-nowrap") + end + end + end %> +<% end %> +

<%= @view_object.check_your_answers_task_group[:heading] %>

<%= govuk_task_list do |task_list| - @view_object.task_list_items.each do |item| + @view_object.check_your_answers_task_group[:items].each do |item| task_list.with_item do |row| - row.with_title(text: item[:title], href: item[:href]) + row.with_title(text: item[:title], hint: item[:description], href: item[:href]) row.with_status(text: render(StatusTag::Component.new(item[:status])), classes: "app-white-space-nowrap") end end end %> +<% if @view_object.further_information_request.third_request? %> + <%= govuk_warning_text(text: "This is your final opportunity to provide the required information. You must submit this information by 11:59pm (#{@view_object.further_information_request.expires_at.in_time_zone('Europe/London').strftime('%Z')}) on #{@view_object.further_information_request.expires_at.to_date.to_fs} or your application will be declined.") %> +<% end %> + <% if FeatureFlags::FeatureFlag.active?(:gov_one_applicant_login) %> <%= govuk_button_link_to t("teacher_interface.application_forms.show.draft.save"), logout_uri, secondary: true %> <% else %> diff --git a/config/locales/teacher_interface.en.yml b/config/locales/teacher_interface.en.yml index de60b9a149..fbdfa503c9 100644 --- a/config/locales/teacher_interface.en.yml +++ b/config/locales/teacher_interface.en.yml @@ -100,7 +100,7 @@ en: check: Check your answers before submitting failure_reason: age_range: Tell us more about the age range you can teach - applicant_already_dqt: Additional personal information + applicant_already_dqt: Provide additional personal information english_language_unverifiable_reference_number: Tell us more about your English language proficiency qualifications_dont_match_other_details: Tell us more about your qualifications qualifications_dont_match_subjects: Tell us more about the subjects you can teach @@ -111,6 +111,14 @@ en: work_history_break: Tell us more about your work history work_history_information: Tell us more about your work history written_statement_mismatch: Tell us more about your written statement + section: + check_your_answers: Check your answers + personal_information: About you + qualifications: Your qualifications + age_range_subjects: The age range and subjects you can teach + english_language_proficiency: Your English language proficiency + work_history: Your work history + professional_standing: Proof that you’re recognised as a teacher reference_requests: show: title: You’ve been asked to act as a reference diff --git a/spec/support/autoload/page_objects/govuk_task_list.rb b/spec/support/autoload/page_objects/govuk_task_list.rb index d18eaa9973..fcab98a5cc 100644 --- a/spec/support/autoload/page_objects/govuk_task_list.rb +++ b/spec/support/autoload/page_objects/govuk_task_list.rb @@ -10,7 +10,7 @@ class GovukTaskList < SitePrism::Section end def find_item(text) - items.find { |item| item.name_and_hint.text == text } + items.find { |item| item.name_and_hint.text.include?(text) } end def click_item(link_text) diff --git a/spec/support/autoload/page_objects/teacher_interface/check_further_information_request_answers.rb b/spec/support/autoload/page_objects/teacher_interface/check_further_information_request_answers.rb index c9c3467b1f..864c38bd91 100644 --- a/spec/support/autoload/page_objects/teacher_interface/check_further_information_request_answers.rb +++ b/spec/support/autoload/page_objects/teacher_interface/check_further_information_request_answers.rb @@ -6,7 +6,7 @@ class CheckFurtherInformationRequestAnswers < SitePrism::Page set_url "/teacher/application/further_information_requests/{request_id}/edit" element :heading, ".govuk-heading-xl" - section :summary_list, GovukSummaryList, ".govuk-summary-list" + sections :summary_lists, GovukSummaryList, ".govuk-summary-list" element :submit_button, ".govuk-button" end end diff --git a/spec/support/autoload/page_objects/teacher_interface/further_information_requested.rb b/spec/support/autoload/page_objects/teacher_interface/further_information_requested.rb index b25f0f48b5..8b42f473c9 100644 --- a/spec/support/autoload/page_objects/teacher_interface/further_information_requested.rb +++ b/spec/support/autoload/page_objects/teacher_interface/further_information_requested.rb @@ -6,7 +6,7 @@ class FurtherInformationRequested < SitePrism::Page set_url "/teacher/application/further_information_requests/{request_id}" element :heading, ".govuk-heading-l" - section :task_list, GovukTaskList, ".govuk-task-list" + sections :task_lists, GovukTaskList, ".govuk-task-list" element :check_your_answers_button, ".govuk-button:not(.govuk-button--secondary)" diff --git a/spec/system/teacher_interface/further_information_spec.rb b/spec/system/teacher_interface/further_information_spec.rb index 3a5d9558a6..9a5c59dde6 100644 --- a/spec/system/teacher_interface/further_information_spec.rb +++ b/spec/system/teacher_interface/further_information_spec.rb @@ -3,9 +3,20 @@ require "rails_helper" RSpec.describe "Teacher further information", type: :system do + let(:teacher) { create(:teacher) } + let!(:application_form) do + create( + :application_form, + :submitted, + :with_work_history, + statuses: %w[waiting_on_further_information], + teacher:, + ) + end + before do given_i_am_authorized_as_a_user(teacher) - given_there_is_an_application_form + given_there_is_an_application_form_with_assessment given_malware_scanning_is_enabled end @@ -106,10 +117,6 @@ end end - def given_there_is_an_application_form - application_form - end - def when_i_click_the_start_button teacher_further_information_requested_start_page.start_button.click end @@ -151,7 +158,7 @@ def when_i_click_the_text_task_list_item expect( teacher_further_information_required_page.failure_reason_heading.text, ).to eq( - "The subjects you entered are acceptable for QTS, but the uploaded qualifications do not match them.", + "The subjects you entered are acceptable for QTS, but the uploaded qualifications do not match them", ) end @@ -159,14 +166,14 @@ def when_i_click_the_work_history_contact_task_list_item work_history_task_list_item.click expect( teacher_further_information_required_page.failure_reason_heading.text, - ).to eq("We could not verify one or more references you provided.") + ).to eq("We could not verify one or more references you provided") end def when_i_click_the_document_task_list_item document_task_list_item.click expect( teacher_further_information_required_page.failure_reason_heading.text, - ).to eq("Your ID document is illegible or in a format we cannot accept.") + ).to eq("Your ID document is illegible or in a format we cannot accept") end def when_i_fill_in_the_response @@ -208,23 +215,21 @@ def when_i_click_the_check_your_answers_task_list_item end def check_your_answers_task_list_item - teacher_further_information_requested_page.task_list.find_item( + teacher_further_information_requested_page.task_lists.last.find_item( "Check your answers before submitting", ) end def and_i_see_the_check_your_answers_items - rows = - teacher_check_further_information_request_answers_page.summary_list.rows + lists = teacher_check_further_information_request_answers_page.summary_lists - expect(rows.count).to eq(3) - - expect(rows.first.key.text).to eq( - "Tell us more about the subjects you can teach", - ) - expect(rows.second.key.text).to eq("Add work history details") + expect(lists.count).to eq(3) - expect(rows.last.key.text).to eq("Upload your identity document") + expect( + teacher_check_further_information_request_answers_page, + ).to have_content("Your response").and have_content( + "Reference details", + ).and have_content("Identity documents") end def when_i_click_the_text_check_your_answers_item @@ -244,7 +249,7 @@ def and_i_see_the_further_information_received_information "Further information successfully submitted", ) expect(teacher_submitted_application_page.panel.body.text).to eq( - "Your application reference number\n#{@application_form.reference}", + "Your application reference number\n#{application_form.reference}", ) end @@ -266,64 +271,56 @@ def and_i_receive_a_further_information_received_email expect(message.to).to include(application_form.teacher.email) end - def teacher - @teacher ||= create(:teacher) - end - - def application_form - @application_form ||= - begin - application_form = - create( - :application_form, - :submitted, - :with_work_history, - statuses: %w[waiting_on_further_information], - teacher:, - ) - create( - :assessment, - :with_further_information_request, - application_form:, - ) - application_form - end + def given_there_is_an_application_form_with_assessment + assessment = + create(:assessment, :with_further_information_request, application_form:) + assessment_section = + create(:assessment_section, :personal_information, assessment:) + assessment.further_information_requests.first.items.each do |item| + create( + :selected_failure_reason, + assessment_section: assessment_section, + key: item.failure_reason_key, + ) + end end def further_information_request - application_form.assessment.further_information_requests.first + application_form.reload.assessment.further_information_requests.first end def text_task_list_item - teacher_further_information_requested_page.task_list.find_item( + teacher_further_information_requested_page.task_lists.first.find_item( "Tell us more about the subjects you can teach", ) end def text_check_answers_item teacher_check_further_information_request_answers_page - .summary_list + .summary_lists + .first .rows .first end def work_history_task_list_item - teacher_further_information_requested_page.task_list.find_item( - "Add work history details", + teacher_further_information_requested_page.task_lists.first.find_item( + "Update reference details for #{application_form.work_histories.first.school_name}", ) end def document_task_list_item - teacher_further_information_requested_page.task_list.find_item( + teacher_further_information_requested_page.task_lists.first.find_item( "Upload your identity document", ) end def document_check_answers_item teacher_check_further_information_request_answers_page - .summary_list + .summary_lists + .third .rows - .last + .first end def then_i_see_the_warning_text diff --git a/spec/view_objects/teacher_interface/further_information_request_item_view_object_spec.rb b/spec/view_objects/teacher_interface/further_information_request_item_view_object_spec.rb new file mode 100644 index 0000000000..2c6500b861 --- /dev/null +++ b/spec/view_objects/teacher_interface/further_information_request_item_view_object_spec.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe TeacherInterface::FurtherInformationRequestItemViewObject do + subject(:view_object) do + described_class.new( + current_teacher:, + params: ActionController::Parameters.new(params), + ) + end + + let(:current_teacher) { create(:teacher) } + let(:application_form) { create(:application_form, teacher: current_teacher) } + let(:further_information_request) do + create( + :further_information_request, + :requested, + assessment: create(:assessment, application_form:), + ) + end + + let(:params) do + { + id: further_information_request_item.id, + application_form_id: application_form.id, + } + end + + describe "#item_name" do + subject(:item_name) { view_object.item_name } + + context "when item is a text response" do + let(:further_information_request_item) do + create( + :further_information_request_item, + :with_text_response, + further_information_request:, + ) + end + + it { is_expected.to eq("Tell us more about the subjects you can teach") } + end + + context "when item is a document response" do + let(:further_information_request_item) do + create( + :further_information_request_item, + :with_document_response, + further_information_request:, + ) + end + + it { is_expected.to eq("Upload your identity document") } + end + + context "when item is a work history reference contact response" do + let(:further_information_request_item) do + create( + :further_information_request_item, + :with_work_history_contact_response, + further_information_request:, + ) + end + + it do + expect(subject).to eq( + "Update reference details for #{further_information_request_item.work_history.school_name}", + ) + end + end + end + + describe "#item_description" do + subject(:item_description) { view_object.item_description } + + let(:further_information_request_item) do + create( + :further_information_request_item, + :with_text_response, + further_information_request:, + ) + end + + it do + expect(subject).to eq( + "The subjects you entered are acceptable for QTS, but the uploaded qualifications do not match them", + ) + end + end +end diff --git a/spec/view_objects/teacher_interface/further_information_request_view_object_spec.rb b/spec/view_objects/teacher_interface/further_information_request_view_object_spec.rb index 4ce48d90fa..afd4b415b2 100644 --- a/spec/view_objects/teacher_interface/further_information_request_view_object_spec.rb +++ b/spec/view_objects/teacher_interface/further_information_request_view_object_spec.rb @@ -26,8 +26,20 @@ } end - describe "#task_list_items" do - subject(:task_list_items) { view_object.task_list_items } + let(:personal_information_assessment_section) do + create :assessment_section, + :personal_information, + assessment: further_information_request.assessment + end + + let(:qualifications_assessment_section) do + create :assessment_section, + :qualifications, + assessment: further_information_request.assessment + end + + describe "#grouped_task_list_items" do + subject(:grouped_task_list_items) { view_object.grouped_task_list_items } let!(:text_item) do create( @@ -45,18 +57,36 @@ ) end + before do + create :selected_failure_reason, + assessment_section: personal_information_assessment_section, + key: text_item.failure_reason_key + + create :selected_failure_reason, + assessment_section: qualifications_assessment_section, + key: document_item.failure_reason_key + end + it do expect(subject).to include( { - title: "Tell us more about the subjects you can teach", - href: [ - :edit, - :teacher_interface, - :application_form, - further_information_request, - text_item, + heading: "About you", + items: [ + title: "Tell us more about the subjects you can teach", + description: + "The subjects you entered are acceptable for QTS, but the uploaded qualifications do not match them", + href: [ + :edit, + :teacher_interface, + :application_form, + further_information_request, + text_item, + ], + status: "not_started", + value: nil, + value_title: "Your response", + assessor_note: text_item.failure_reason_assessor_feedback, ], - status: "not_started", }, ) end @@ -64,44 +94,26 @@ it do expect(subject).to include( { - title: "Upload your identity document", - href: [ - :edit, - :teacher_interface, - :application_form, - further_information_request, - document_item, + heading: "Your qualifications", + items: [ + title: "Upload your identity document", + description: + "Your ID document is illegible or in a format we cannot accept", + href: [ + :edit, + :teacher_interface, + :application_form, + further_information_request, + document_item, + ], + status: "not_started", + value: document_item.document, + value_title: "Identity documents", + assessor_note: document_item.failure_reason_assessor_feedback, ], - status: "not_started", }, ) end - - context "when items are incomplete" do - it "disables check your answers in task list" do - check_answers_item = task_list_items.last - expect(check_answers_item[:status]).to eq("cannot_start") - expect(check_answers_item[:href]).to be_nil - end - end - - context "when items are complete" do - before do - text_item.update!(response: "Response") - create( - :upload, - :clean, - document: document_item.document, - filename: "upload.pdf", - ) - end - - it "enables check your answers in task list" do - check_answers_item = task_list_items.last - expect(check_answers_item[:status]).to eq("not_started") - expect(check_answers_item[:href]).to be_present - end - end end describe "#can_check_answers?" do @@ -129,94 +141,58 @@ end end - describe "#check_your_answers_fields" do - subject(:check_your_answers_fields) do - view_object.check_your_answers_fields + describe "#check_your_answers_task_group" do + subject(:check_your_answers_task_group) do + view_object.check_your_answers_task_group end let!(:text_item) do create( :further_information_request_item, :with_text_response, - :completed, further_information_request:, ) end + let!(:document_item) do create( :further_information_request_item, :with_document_response, - :completed, further_information_request:, ) end - it do - expect(subject).to eq( - { - text_item.id => { - title: "Tell us more about the subjects you can teach", - href: [ - :edit, - :teacher_interface, - :application_form, - further_information_request, - text_item, - ], - value: text_item.response, - }, - document_item.id => { - title: "Upload your identity document", - href: [ - :edit, - :teacher_interface, - :application_form, - further_information_request, - document_item, - ], - value: document_item.document, - }, - }, - ) + context "when items are incomplete" do + it "disables check your answers in task list group" do + expect(check_your_answers_task_group[:heading]).to eq( + "Check your answers", + ) + expect(check_your_answers_task_group[:items].first[:status]).to eq( + "cannot_start", + ) + expect(check_your_answers_task_group[:items].first[:href]).to be_nil + end end - context "when the document item is passport" do - let!(:document_item) do + context "when items are complete" do + before do + text_item.update!(response: "Response") create( - :further_information_request_item, - :with_passport_document_response, - :completed, - further_information_request:, + :upload, + :clean, + document: document_item.document, + filename: "upload.pdf", ) end - it do - expect(subject).to eq( - { - text_item.id => { - title: "Tell us more about the subjects you can teach", - href: [ - :edit, - :teacher_interface, - :application_form, - further_information_request, - text_item, - ], - value: text_item.response, - }, - document_item.id => { - title: "Upload your passport", - href: [ - :edit, - :teacher_interface, - :application_form, - further_information_request, - document_item, - ], - value: document_item.document, - }, - }, + it "enables check your answers in task list group" do + expect(check_your_answers_task_group[:heading]).to eq( + "Check your answers", + ) + expect(check_your_answers_task_group[:items].first[:status]).to eq( + "not_started", ) + expect(check_your_answers_task_group[:items].first[:href]).to be_present end end end