From b2c5c25d868668a9ac5a5580ad453326a67d0b1b Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 28 Feb 2024 16:43:01 +0100 Subject: [PATCH] Add request Ecctis verification page This adds the page which allows admins to mark that they have requested verification with Ecctis. --- app/components/status_tag/component.rb | 9 +-- .../qualification_requests_controller.rb | 33 ++++++++ app/lib/application_form_status_updater.rb | 22 +++--- .../qualification_request_policy.rb | 6 ++ .../qualification_requests_view_object.rb | 13 +++- .../edit_request.html.erb | 2 +- .../edit_request.html.erb | 14 ++++ config/locales/components.en.yml | 15 ++-- config/routes.rb | 3 +- .../application_form_status_updater_spec.rb | 4 +- .../qualification_request_policy_spec.rb | 10 +++ spec/services/receive_requestable_spec.rb | 2 +- spec/services/unreceive_requestable_spec.rb | 2 +- .../request_professional_standing_request.rb | 18 +---- .../request_qualification_request.rb | 10 +++ .../request_requestable_page.rb | 23 ++++++ spec/support/page_helpers.rb | 5 ++ .../verifying_qualifications_spec.rb | 78 +++++++++++++++++++ ...qualification_requests_view_object_spec.rb | 6 +- 19 files changed, 221 insertions(+), 54 deletions(-) create mode 100644 app/views/assessor_interface/qualification_requests/edit_request.html.erb create mode 100644 spec/support/autoload/page_objects/assessor_interface/request_qualification_request.rb create mode 100644 spec/support/autoload/page_objects/assessor_interface/request_requestable_page.rb diff --git a/app/components/status_tag/component.rb b/app/components/status_tag/component.rb index 086209913f..327025bd04 100644 --- a/app/components/status_tag/component.rb +++ b/app/components/status_tag/component.rb @@ -38,20 +38,18 @@ def tags not_started: "grey", overdue: "pink", overdue_consent: "pink", + overdue_ecctis: "pink", overdue_further_information: "pink", overdue_lops: "pink", - overdue_professional_standing: "pink", - overdue_qualification: "pink", overdue_reference: "pink", potential_duplicate_in_dqt: "pink", pre_assessment: "pink", preliminary_check: "pink", received: "purple", received_consent: "purple", + received_ecctis: "purple", received_further_information: "purple", received_lops: "purple", - received_professional_standing: "purple", - received_qualification: "purple", received_reference: "purple", rejected: "red", requested: "yellow", @@ -63,10 +61,9 @@ def tags verification_not_started: "grey", waiting_on: "yellow", waiting_on_consent: "yellow", + waiting_on_ecctis: "yellow", waiting_on_further_information: "yellow", waiting_on_lops: "yellow", - waiting_on_professional_standing: "yellow", - waiting_on_qualification: "yellow", waiting_on_reference: "yellow", withdrawn: "red", }.freeze diff --git a/app/controllers/assessor_interface/qualification_requests_controller.rb b/app/controllers/assessor_interface/qualification_requests_controller.rb index 795eb63cc8..1eee4b8cf8 100644 --- a/app/controllers/assessor_interface/qualification_requests_controller.rb +++ b/app/controllers/assessor_interface/qualification_requests_controller.rb @@ -19,6 +19,8 @@ class QualificationRequestsController < BaseController update edit_consent_method update_consent_method + edit_request + update_request edit_review update_review ] @@ -168,6 +170,37 @@ def update_consent_method end end + def edit_request + @form = + RequestableRequestForm.new( + requestable:, + user: current_staff, + passed: qualification_request.requested?, + ) + end + + def update_request + @form = + RequestableRequestForm.new( + requestable:, + user: current_staff, + passed: + params.dig(:assessor_interface_requestable_request_form, :passed) || + false, + ) + + if @form.save + redirect_to [ + :assessor_interface, + application_form, + assessment, + :qualification_requests, + ] + else + render :edit_request, status: :unprocessable_entity + end + end + def edit_review @form = RequestableReviewForm.new(requestable:) end diff --git a/app/lib/application_form_status_updater.rb b/app/lib/application_form_status_updater.rb index c1a5964d78..3b54ad722d 100644 --- a/app/lib/application_form_status_updater.rb +++ b/app/lib/application_form_status_updater.rb @@ -52,15 +52,15 @@ def action_required_by application_form.awarded_at.present? "none" elsif dqt_trn_request.present? || assessment_in_review? || - overdue_further_information || overdue_qualification || - received_further_information || received_qualification + overdue_further_information || overdue_ecctis || + received_further_information || received_ecctis "assessor" elsif preliminary_check? || need_to_request_lops? || overdue_consent || received_consent || overdue_lops || received_lops || overdue_reference || received_reference "admin" elsif waiting_on_consent || waiting_on_further_information || - waiting_on_lops || waiting_on_qualification || waiting_on_reference + waiting_on_lops || waiting_on_ecctis || waiting_on_reference "external" elsif application_form.submitted_at.present? "assessor" @@ -81,10 +81,10 @@ def stage (teaching_authority_provides_written_statement && waiting_on_lops) "pre_assessment" elsif assessment_in_verify? || need_to_request_lops? || overdue_consent || - overdue_lops || overdue_qualification || overdue_reference || - received_consent || received_lops || received_qualification || + overdue_lops || overdue_ecctis || overdue_reference || + received_consent || received_lops || received_ecctis || received_reference || waiting_on_consent || waiting_on_lops || - waiting_on_qualification || waiting_on_reference + waiting_on_ecctis || waiting_on_reference "verification" elsif overdue_further_information || received_further_information || waiting_on_further_information || @@ -166,7 +166,7 @@ def need_to_request_lops? def requestable_statuses @requestable_statuses ||= %w[overdue received waiting_on] - .product(%w[consent further_information lops qualification reference]) + .product(%w[consent ecctis further_information lops reference]) .map { |status, requestable| "#{status}_#{requestable}" } .filter { |column| send(column) } end @@ -184,8 +184,8 @@ def overdue_lops overdue?(requestables: professional_standing_requests) end - def overdue_qualification - overdue?(requestables: qualification_requests.select(&:requested?)) + def overdue_ecctis + overdue?(requestables: qualification_requests) end def overdue_reference @@ -205,7 +205,7 @@ def received_lops received?(requestables: professional_standing_requests) end - def received_qualification + def received_ecctis received?(requestables: qualification_requests) end @@ -245,7 +245,7 @@ def waiting_on_lops waiting_on?(requestables: professional_standing_requests) end - def waiting_on_qualification + def waiting_on_ecctis waiting_on?(requestables: qualification_requests) end diff --git a/app/policies/assessor_interface/qualification_request_policy.rb b/app/policies/assessor_interface/qualification_request_policy.rb index 80b74b5d38..d04bac87d6 100644 --- a/app/policies/assessor_interface/qualification_request_policy.rb +++ b/app/policies/assessor_interface/qualification_request_policy.rb @@ -34,6 +34,12 @@ def update_consent_method? alias_method :edit_consent_method?, :update_consent_method? + def update_request? + user.verify_permission + end + + alias_method :edit_request?, :update_request? + def update_review? user.assess_permission end diff --git a/app/view_objects/assessor_interface/qualification_requests_view_object.rb b/app/view_objects/assessor_interface/qualification_requests_view_object.rb index 435218f8c6..aec358e3e4 100644 --- a/app/view_objects/assessor_interface/qualification_requests_view_object.rb +++ b/app/view_objects/assessor_interface/qualification_requests_view_object.rb @@ -242,7 +242,16 @@ def ecctis_task_items(qualification_request) [ { name: "Request Ecctis verification", - link: "#", + link: + if can_start && !qualification_request.requested? + [ + :request, + :assessor_interface, + application_form, + assessment, + qualification_request, + ] + end, status: if can_start qualification_request.requested? ? "completed" : "not_started" @@ -255,7 +264,7 @@ def ecctis_task_items(qualification_request) link: "#", status: if can_start && qualification_request.requested? - qualification_request.received? ? "completed" : "not_started" + qualification_request.received? ? "completed" : "waiting_on" else "cannot_start" end, diff --git a/app/views/assessor_interface/professional_standing_requests/edit_request.html.erb b/app/views/assessor_interface/professional_standing_requests/edit_request.html.erb index 113928616c..fc79aad239 100644 --- a/app/views/assessor_interface/professional_standing_requests/edit_request.html.erb +++ b/app/views/assessor_interface/professional_standing_requests/edit_request.html.erb @@ -17,7 +17,7 @@ <%= f.govuk_check_boxes_fieldset :passed, multiple: false, legend: { text: "Confirm you have requested verification for this LoPS", size: "s" } do %> - <%= f.govuk_check_box :passed, true, false, multiple: false, link_errors: true, label: { text: "Verification has been requested." } %> + <%= f.govuk_check_box :passed, true, false, link_errors: true, label: { text: "Verification has been requested." } %> <% end %> <%= render "shared/assessor_interface/continue_cancel_button", f: %> diff --git a/app/views/assessor_interface/qualification_requests/edit_request.html.erb b/app/views/assessor_interface/qualification_requests/edit_request.html.erb new file mode 100644 index 0000000000..622a19666e --- /dev/null +++ b/app/views/assessor_interface/qualification_requests/edit_request.html.erb @@ -0,0 +1,14 @@ +<% title = "Request Ecctis verification" %> + +<% content_for :page_title, title_with_error_prefix(title, error: @form.errors.any?) %> +<% content_for :back_link_url, back_history_path(default: assessor_interface_application_form_path(@application_form)) %> + +<%= form_with model: @form, url: [:request, :assessor_interface, @application_form, @assessment, @qualification_request] do |f| %> +

<%= title %>

+ + <%= f.govuk_check_boxes_fieldset :passed, multiple: false, legend: { text: "Confirm you have requested verification for this qualification", size: "s" } do %> + <%= f.govuk_check_box :passed, true, false, link_errors: true, label: { text: "Verification has been requested." } %> + <% end %> + + <%= render "shared/assessor_interface/continue_cancel_button", f: %> +<% end %> diff --git a/config/locales/components.en.yml b/config/locales/components.en.yml index 40925f8167..a9ce94d079 100644 --- a/config/locales/components.en.yml +++ b/config/locales/components.en.yml @@ -17,10 +17,9 @@ en: not_started: Not started overdue: Overdue overdue_consent: Overdue consent + overdue_ecctis: Overdue Ecctis overdue_further_information: Overdue further information - overdue_lops: Overdue LOPS - overdue_professional_standing: Overdue professional standing - overdue_qualification: Overdue qualification + overdue_lops: Overdue LoPS overdue_reference: Overdue reference potential_duplicate_in_dqt: Potential duplication in DQT pre_assessment: Pre-assessment @@ -28,10 +27,9 @@ en: received: Received received_and_overdue: Received (overdue) received_consent: Received consent + received_ecctis: Received Ecctis received_further_information: Received further information - received_lops: Received LOPS - received_professional_standing: Received professional standing - received_qualification: Received qualification + received_lops: Received LoPS received_reference: Received reference rejected: Rejected requested: Waiting on @@ -43,10 +41,9 @@ en: verification_not_started: Verification not started waiting_on: Waiting on waiting_on_consent: Waiting on consent + waiting_on_ecctis: Waiting on Ecctis waiting_on_further_information: Waiting on further information - waiting_on_lops: Waiting on LOPS - waiting_on_professional_standing: Waiting on professional standing - waiting_on_qualification: Waiting on qualification + waiting_on_lops: Waiting on LoPS waiting_on_reference: Waiting on reference withdrawn: Withdrawn diff --git a/config/routes.rb b/config/routes.rb index 8f38f67689..74c7f82789 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -167,7 +167,8 @@ to: "qualification_requests#edit_consent_method" post "consent-method", to: "qualification_requests#update_consent_method" - + get "request", to: "qualification_requests#edit_request" + post "request", to: "qualification_requests#update_request" get "review", to: "qualification_requests#edit_review" post "review", to: "qualification_requests#update_review" end diff --git a/spec/lib/application_form_status_updater_spec.rb b/spec/lib/application_form_status_updater_spec.rb index 4041aa3602..a3abe01bff 100644 --- a/spec/lib/application_form_status_updater_spec.rb +++ b/spec/lib/application_form_status_updater_spec.rb @@ -204,7 +204,7 @@ include_examples "changes action required by", "assessor" include_examples "changes stage", "verification" - include_examples "changes statuses", %w[received_qualification] + include_examples "changes statuses", %w[received_ecctis] end context "with a requested qualification request" do @@ -217,7 +217,7 @@ include_examples "changes action required by", "external" include_examples "changes stage", "verification" - include_examples "changes statuses", %w[waiting_on_qualification] + include_examples "changes statuses", %w[waiting_on_ecctis] end context "with a received reference request" do diff --git a/spec/policies/assessor_interface/qualification_request_policy_spec.rb b/spec/policies/assessor_interface/qualification_request_policy_spec.rb index 25ac4c8f70..e3d7a443d2 100644 --- a/spec/policies/assessor_interface/qualification_request_policy_spec.rb +++ b/spec/policies/assessor_interface/qualification_request_policy_spec.rb @@ -81,6 +81,16 @@ it_behaves_like "a policy method requiring the verify permission" end + describe "#update_request?" do + subject(:update_request?) { policy.update_request? } + it_behaves_like "a policy method requiring the verify permission" + end + + describe "#edit_request?" do + subject(:edit_request?) { policy.edit_request? } + it_behaves_like "a policy method requiring the verify permission" + end + describe "#update_review?" do subject(:update_review?) { policy.update_review? } it_behaves_like "a policy method requiring the assess permission" diff --git a/spec/services/receive_requestable_spec.rb b/spec/services/receive_requestable_spec.rb index 5f473292df..37f419fc98 100644 --- a/spec/services/receive_requestable_spec.rb +++ b/spec/services/receive_requestable_spec.rb @@ -30,7 +30,7 @@ it "changes the application form status" do expect { call }.to change { application_form.reload.statuses }.to( - %w[received_qualification], + %w[received_ecctis], ) end diff --git a/spec/services/unreceive_requestable_spec.rb b/spec/services/unreceive_requestable_spec.rb index 38633fda89..f6109962b9 100644 --- a/spec/services/unreceive_requestable_spec.rb +++ b/spec/services/unreceive_requestable_spec.rb @@ -4,7 +4,7 @@ RSpec.describe UnreceiveRequestable do let(:application_form) do - create(:application_form, :submitted, statuses: %w[received_qualification]) + create(:application_form, :submitted, statuses: %w[received_ecctis]) end let(:requestable) do create( diff --git a/spec/support/autoload/page_objects/assessor_interface/request_professional_standing_request.rb b/spec/support/autoload/page_objects/assessor_interface/request_professional_standing_request.rb index a094f5acf5..e2c87fa2a4 100644 --- a/spec/support/autoload/page_objects/assessor_interface/request_professional_standing_request.rb +++ b/spec/support/autoload/page_objects/assessor_interface/request_professional_standing_request.rb @@ -2,25 +2,9 @@ module PageObjects module AssessorInterface - class RequestProfessionalStandingRequest < SitePrism::Page + class RequestProfessionalStandingRequest < RequestRequestablePage set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \ "/professional-standing-request/request" - - section :form, "form" do - element :passed_checkbox, - "#assessor-interface-requestable-request-form-passed-true-field", - visible: false - element :submit_button, ".govuk-button" - end - - def submit_checked - form.passed_checkbox.click - form.submit_button.click - end - - def submit_unchecked - form.submit_button.click - end end end end diff --git a/spec/support/autoload/page_objects/assessor_interface/request_qualification_request.rb b/spec/support/autoload/page_objects/assessor_interface/request_qualification_request.rb new file mode 100644 index 0000000000..c033005789 --- /dev/null +++ b/spec/support/autoload/page_objects/assessor_interface/request_qualification_request.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module PageObjects + module AssessorInterface + class RequestQualificationRequest < RequestRequestablePage + set_url "/assessor/applications/{reference}/assessments/{assessment_id}" \ + "/qualification-requests/{id}/request" + end + end +end diff --git a/spec/support/autoload/page_objects/assessor_interface/request_requestable_page.rb b/spec/support/autoload/page_objects/assessor_interface/request_requestable_page.rb new file mode 100644 index 0000000000..b10d4404e7 --- /dev/null +++ b/spec/support/autoload/page_objects/assessor_interface/request_requestable_page.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module PageObjects + module AssessorInterface + class RequestRequestablePage < SitePrism::Page + section :form, "form" do + element :passed_checkbox, + "#assessor-interface-requestable-request-form-passed-true-field", + visible: false + element :submit_button, ".govuk-button" + end + + def submit_checked + form.passed_checkbox.click + form.submit_button.click + end + + def submit_unchecked + form.submit_button.click + end + end + end +end diff --git a/spec/support/page_helpers.rb b/spec/support/page_helpers.rb index 4501b9aaa0..29c64e36e5 100644 --- a/spec/support/page_helpers.rb +++ b/spec/support/page_helpers.rb @@ -196,6 +196,11 @@ def assessor_request_professional_standing_request_page PageObjects::AssessorInterface::RequestProfessionalStandingRequest.new end + def assessor_request_qualification_request_page + @assessor_request_qualification_request_page ||= + PageObjects::AssessorInterface::RequestQualificationRequest.new + end + def assessor_reverse_decision_page @assessor_reverse_decision_page ||= PageObjects::AssessorInterface::ReverseDecision.new diff --git a/spec/system/assessor_interface/verifying_qualifications_spec.rb b/spec/system/assessor_interface/verifying_qualifications_spec.rb index 914b0e3bb5..7f32e3bf21 100644 --- a/spec/system/assessor_interface/verifying_qualifications_spec.rb +++ b/spec/system/assessor_interface/verifying_qualifications_spec.rb @@ -88,6 +88,33 @@ then_i_see_the(:assessor_application_page, reference:) end + it "request ecctis" do + given_the_admin_has_accepted_the_consent_requests + + when_i_visit_the(:assessor_application_page, reference:) + and_i_click_the_verify_qualifications_task + then_i_see_the(:assessor_qualification_requests_page, reference:) + and_the_request_ecctis_verification_task_is_not_started + and_the_record_ecctis_response_task_is_cannot_start + + when_i_click_the_request_ecctis_verification_task + then_i_see_the(:assessor_request_qualification_request_page) + and_i_submit_unchecked_on_the_request_form + then_i_see_the(:assessor_qualification_requests_page, reference:) + and_the_request_ecctis_verification_task_is_not_started + and_the_record_ecctis_response_task_is_cannot_start + + when_i_click_the_request_ecctis_verification_task + then_i_see_the(:assessor_request_qualification_request_page) + and_i_submit_checked_on_the_request_form + then_i_see_the(:assessor_qualification_requests_page, reference:) + and_the_request_ecctis_verification_task_is_completed + and_the_record_ecctis_response_task_is_waiting_on + + when_i_go_back_to_overview + then_i_see_the(:assessor_application_page, reference:) + end + private def given_there_is_an_application_form_with_qualification_request @@ -102,6 +129,11 @@ def given_the_applicant_has_responded_to_the_consent_requests end end + def given_the_admin_has_accepted_the_consent_requests + assessment.update!(unsigned_consent_document_generated: true) + assessment.qualification_requests.each(&:consent_method_unsigned!) + end + def and_i_click_the_verify_qualifications_task assessor_application_page.verify_qualifications_task.link.click end @@ -236,6 +268,40 @@ def and_the_record_applicant_response_task_is_review expect(record_applicant_response_task_item.status_tag.text).to eq("REVIEW") end + def and_the_request_ecctis_verification_task_is_not_started + expect(request_ecctis_verification_task_item.status_tag.text).to eq( + "NOT STARTED", + ) + end + + def and_the_record_ecctis_response_task_is_cannot_start + expect(record_ecctis_response_task_item.status_tag.text).to eq( + "CANNOT START", + ) + end + + def when_i_click_the_request_ecctis_verification_task + request_ecctis_verification_task_item.click + end + + def and_i_submit_checked_on_the_request_form + assessor_request_qualification_request_page.submit_checked + end + + def and_i_submit_unchecked_on_the_request_form + assessor_request_qualification_request_page.submit_unchecked + end + + def and_the_request_ecctis_verification_task_is_completed + expect(request_ecctis_verification_task_item.status_tag.text).to eq( + "COMPLETED", + ) + end + + def and_the_record_ecctis_response_task_is_waiting_on + expect(record_ecctis_response_task_item.status_tag.text).to eq("WAITING ON") + end + def when_i_go_back_to_overview assessor_qualification_requests_page.continue_button.click end @@ -270,6 +336,18 @@ def record_applicant_response_task_item ) end + def request_ecctis_verification_task_item + assessor_qualification_requests_page.task_lists.second.find_item( + "Request Ecctis verification", + ) + end + + def record_ecctis_response_task_item + assessor_qualification_requests_page.task_lists.second.find_item( + "Record Ecctis response", + ) + end + def application_form @application_form ||= create( diff --git a/spec/view_objects/assessor_interface/qualification_requests_view_object_spec.rb b/spec/view_objects/assessor_interface/qualification_requests_view_object_spec.rb index 0e11d452c0..95e695b2ba 100644 --- a/spec/view_objects/assessor_interface/qualification_requests_view_object_spec.rb +++ b/spec/view_objects/assessor_interface/qualification_requests_view_object_spec.rb @@ -72,7 +72,7 @@ }, { name: "Request Ecctis verification", - link: "#", + link: nil, status: "cannot_start", }, { @@ -134,7 +134,7 @@ }, { name: "Request Ecctis verification", - link: "#", + link: nil, status: "cannot_start", }, { @@ -180,7 +180,7 @@ }, { name: "Request Ecctis verification", - link: "#", + link: nil, status: "cannot_start", }, {