From 3cf63c35942524c37af376464651c17b4c8d92a5 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Mon, 6 Nov 2023 14:04:30 +0000 Subject: [PATCH] Split verification in to two pages If the admin decides that the LoPS is not acceptable, and they'd like to send this to review, we've decided to split this in to two pages so the internal notes appears on its own page. --- app/assets/stylesheets/application.sass.scss | 5 ++ ...ssment_recommendation_review_controller.rb | 2 + ...ofessional_standing_requests_controller.rb | 73 ++++++++++++------ .../requestable_verify_failed_form.rb | 20 +++++ ...m.rb => requestable_verify_passed_form.rb} | 8 +- .../professional_standing_request_policy.rb | 6 ++ .../application_forms/status.html.erb | 8 +- .../edit.html.erb | 40 +++++----- .../edit_verify.html.erb | 8 +- .../edit_verify_failed.html.erb | 16 ++++ .../show.html.erb | 20 ++--- config/locales/assessor_interface.en.yml | 8 +- config/locales/helpers.en.yml | 6 +- config/routes.rb | 4 + .../requestable_verify_failed_form_spec.rb | 48 ++++++++++++ ...=> requestable_verify_passed_form_spec.rb} | 48 +++++------- .../assessment_policy_spec.rb | 4 +- .../assessment_recommendation_policy_spec.rb | 4 +- ...ofessional_standing_request_policy_spec.rb | 14 +++- spec/policies/assessor_policy_spec.rb | 10 +-- .../professional_standing_request.rb | 4 +- .../request_professional_standing_request.rb | 11 ++- .../review_professional_standing_request.rb | 13 +++- ...fy_failed_professional_standing_request.rb | 20 +++++ .../verify_professional_standing_request.rb | 11 ++- spec/support/page_helpers.rb | 5 ++ spec/support/shared_examples/policy.rb | 2 +- .../reviewing_professional_standing_spec.rb | 36 +++++++-- .../verifying_professional_standing_spec.rb | 76 ++++++++++++++----- 29 files changed, 389 insertions(+), 141 deletions(-) create mode 100644 app/forms/assessor_interface/requestable_verify_failed_form.rb rename app/forms/assessor_interface/{requestable_verify_form.rb => requestable_verify_passed_form.rb} (66%) create mode 100644 app/views/assessor_interface/professional_standing_requests/edit_verify_failed.html.erb create mode 100644 spec/forms/assessor_interface/requestable_verify_failed_form_spec.rb rename spec/forms/assessor_interface/{requestable_verify_form_spec.rb => requestable_verify_passed_form_spec.rb} (51%) create mode 100644 spec/support/autoload/page_objects/assessor_interface/verify_failed_professional_standing_request.rb diff --git a/app/assets/stylesheets/application.sass.scss b/app/assets/stylesheets/application.sass.scss index 19138abaab..52c2ac8202 100644 --- a/app/assets/stylesheets/application.sass.scss +++ b/app/assets/stylesheets/application.sass.scss @@ -74,3 +74,8 @@ ul.autocomplete__menu { .govuk-inset-text .govuk-details { margin-bottom: 0; } + +.app-table__center { + text-align: center; + vertical-align: middle; +} diff --git a/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb b/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb index 3d333e7532..7039be4b72 100644 --- a/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb +++ b/app/controllers/assessor_interface/assessment_recommendation_review_controller.rb @@ -10,6 +10,8 @@ def edit @professional_standing_request = assessment.professional_standing_request if assessment.professional_standing_request.verify_failed? + + render layout: "full_from_desktop" end def update diff --git a/app/controllers/assessor_interface/professional_standing_requests_controller.rb b/app/controllers/assessor_interface/professional_standing_requests_controller.rb index e3b9795c36..06d223f76e 100644 --- a/app/controllers/assessor_interface/professional_standing_requests_controller.rb +++ b/app/controllers/assessor_interface/professional_standing_requests_controller.rb @@ -4,15 +4,15 @@ module AssessorInterface class ProfessionalStandingRequestsController < BaseController before_action :set_variables - def show + before_action do authorize [:assessor_interface, professional_standing_request] + end + def show render layout: "full_from_desktop" end def edit_locate - authorize [:assessor_interface, professional_standing_request] - @form = ProfessionalStandingRequestLocationForm.new( requestable:, @@ -24,8 +24,6 @@ def edit_locate end def update_locate - authorize [:assessor_interface, professional_standing_request] - @form = ProfessionalStandingRequestLocationForm.new( location_form_params.merge(requestable:, user: current_staff), @@ -39,8 +37,6 @@ def update_locate end def edit_request - authorize [:assessor_interface, professional_standing_request] - @form = RequestableRequestForm.new( requestable:, @@ -50,8 +46,6 @@ def edit_request end def update_request - authorize [:assessor_interface, professional_standing_request] - @form = RequestableRequestForm.new( requestable:, @@ -74,8 +68,6 @@ def update_request end def edit_review - authorize [:assessor_interface, professional_standing_request] - @form = RequestableReviewForm.new( requestable:, @@ -86,8 +78,6 @@ def edit_review end def update_review - authorize [:assessor_interface, professional_standing_request] - @form = RequestableReviewForm.new( review_form_params.merge(requestable:, user: current_staff), @@ -106,23 +96,55 @@ def update_review end def edit_verify - authorize [:assessor_interface, professional_standing_request] - @form = - RequestableVerifyForm.new( + RequestableVerifyPassedForm.new( requestable:, user: current_staff, passed: requestable.verify_passed, - note: requestable.verify_note, ) end def update_verify - authorize [:assessor_interface, professional_standing_request] + @form = + RequestableVerifyPassedForm.new( + verify_passed_form_params.merge(requestable:, user: current_staff), + ) + + if @form.save + if @form.passed + redirect_to [ + :assessor_interface, + application_form, + assessment, + :professional_standing_request, + ] + else + redirect_to [ + :verify_failed, + :assessor_interface, + application_form, + assessment, + :professional_standing_request, + ] + end + else + render :edit_verify, status: :unprocessable_entity + end + end + def edit_verify_failed @form = - RequestableVerifyForm.new( - verify_form_params.merge(requestable:, user: current_staff), + RequestableVerifyFailedForm.new( + requestable:, + user: current_staff, + note: requestable.verify_note, + ) + end + + def update_verify_failed + @form = + RequestableVerifyFailedForm.new( + verify_failed_form_params.merge(requestable:, user: current_staff), ) if @form.save @@ -133,7 +155,7 @@ def update_verify :professional_standing_request, ] else - render :edit_verify, status: :unprocessable_entity + render :edit_verify_failed, status: :unprocessable_entity end end @@ -158,9 +180,14 @@ def review_form_params ) end - def verify_form_params - params.require(:assessor_interface_requestable_verify_form).permit( + def verify_passed_form_params + params.require(:assessor_interface_requestable_verify_passed_form).permit( :passed, + ) + end + + def verify_failed_form_params + params.require(:assessor_interface_requestable_verify_failed_form).permit( :note, ) end diff --git a/app/forms/assessor_interface/requestable_verify_failed_form.rb b/app/forms/assessor_interface/requestable_verify_failed_form.rb new file mode 100644 index 0000000000..69bcd83062 --- /dev/null +++ b/app/forms/assessor_interface/requestable_verify_failed_form.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AssessorInterface::RequestableVerifyFailedForm + include ActiveModel::Model + include ActiveModel::Attributes + + attr_accessor :requestable, :user + validates :requestable, :user, presence: true + + attribute :note, :string + validates :note, presence: true + + def save + return false if invalid? + + VerifyRequestable.call(requestable:, user:, passed: false, note:) + + true + end +end diff --git a/app/forms/assessor_interface/requestable_verify_form.rb b/app/forms/assessor_interface/requestable_verify_passed_form.rb similarity index 66% rename from app/forms/assessor_interface/requestable_verify_form.rb rename to app/forms/assessor_interface/requestable_verify_passed_form.rb index 3fd8ad7306..2630f08bd1 100644 --- a/app/forms/assessor_interface/requestable_verify_form.rb +++ b/app/forms/assessor_interface/requestable_verify_passed_form.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AssessorInterface::RequestableVerifyForm +class AssessorInterface::RequestableVerifyPassedForm include ActiveModel::Model include ActiveModel::Attributes @@ -10,14 +10,12 @@ class AssessorInterface::RequestableVerifyForm attribute :passed, :boolean validates :passed, inclusion: [true, false] - attribute :note, :string - validates :note, presence: true, if: -> { passed == false } - def save return false if invalid? ReceiveRequestable.call(requestable:, user:) unless requestable.received? - VerifyRequestable.call(requestable:, user:, passed:, note:) + + VerifyRequestable.call(requestable:, user:, passed:, note: "") if passed true end diff --git a/app/policies/assessor_interface/professional_standing_request_policy.rb b/app/policies/assessor_interface/professional_standing_request_policy.rb index 7091033b31..b40fa6fd4f 100644 --- a/app/policies/assessor_interface/professional_standing_request_policy.rb +++ b/app/policies/assessor_interface/professional_standing_request_policy.rb @@ -23,6 +23,12 @@ def update_verify? alias_method :edit_verify?, :update_verify? + def update_verify_failed? + user.verify_permission + end + + alias_method :edit_verify_failed?, :update_verify_failed? + def update_review? user.assess_permission end diff --git a/app/views/assessor_interface/application_forms/status.html.erb b/app/views/assessor_interface/application_forms/status.html.erb index ca7c7ce383..c8347b6fbb 100644 --- a/app/views/assessor_interface/application_forms/status.html.erb +++ b/app/views/assessor_interface/application_forms/status.html.erb @@ -2,11 +2,13 @@ <% content_for :back_link_url, assessor_interface_application_form_path(@view_object.application_form) %> <% if @view_object.assessment.review? %> - <%= govuk_panel(title_text: "Application sent for review") %> +

Application sent for review

<% elsif @view_object.application_form.waiting_on? %> - <%= govuk_panel(title_text: "Reference requests sent successfully") %> +

Reference requests sent successfully

+<% elsif @view_object.application_form.awarded? %> + <%= govuk_panel(text: "QTS application #{@view_object.application_form.reference} has been awarded") %> <% else %> - <%= govuk_panel(title_text: "QTS application #{@view_object.application_form.reference} has been #{@view_object.status.downcase}") %> +

QTS application <%= @view_object.application_form.reference %> has been <%= @view_object.status.downcase %>

<% end %> <% if @view_object.assessment.review? %> diff --git a/app/views/assessor_interface/assessment_recommendation_review/edit.html.erb b/app/views/assessor_interface/assessment_recommendation_review/edit.html.erb index b6a6de1219..1a19c703e6 100644 --- a/app/views/assessor_interface/assessment_recommendation_review/edit.html.erb +++ b/app/views/assessor_interface/assessment_recommendation_review/edit.html.erb @@ -5,22 +5,28 @@

The following verification tasks have been flagged for review:

-<%= govuk_table do |table| - if @professional_standing_request.present? - table.with_caption(text: "LoPS") - table.with_head do |head| - head.with_row do |row| - row.with_cell(text: "Internal note") - row.with_cell(text: "Status") - end - end - table.with_body do |body| - body.with_row do |row| - row.with_cell { simple_format @professional_standing_request.verify_note } - row.with_cell { render(StatusTag::Component.new(@professional_standing_request.status)) } - end - end - end -end %> +<% if @professional_standing_request.present? %> + + + + + + + + + + + + + + +
LoPS
+

<%= region_teaching_authority_name(@application_form.region).upcase_first %>

+

Internal note

+ <%= simple_format @professional_standing_request.verify_note %> +
+ <%= render(StatusTag::Component.new(@professional_standing_request.status)) %> +
+<% end %> <%= govuk_button_to "Continue", [:assessor_interface, @application_form, @assessment, :assessment_recommendation_review], method: :put %> diff --git a/app/views/assessor_interface/professional_standing_requests/edit_verify.html.erb b/app/views/assessor_interface/professional_standing_requests/edit_verify.html.erb index 816f027fba..b5e8ef79c7 100644 --- a/app/views/assessor_interface/professional_standing_requests/edit_verify.html.erb +++ b/app/views/assessor_interface/professional_standing_requests/edit_verify.html.erb @@ -6,12 +6,8 @@

Record LoPS response

- <%= f.govuk_radio_buttons_fieldset :passed, legend: { text: "Does the response confirm that the LoPS is valid?" } do %> - <%= f.govuk_radio_button :passed, :true, label: { text: "Yes, mark as completed" }, link_errors: true %> - <%= f.govuk_radio_button :passed, :false, label: { text: "No, send for review" } do %> - <%= f.govuk_text_area :note, label: { text: "Internal note: briefly explain to the assessor why you are sending this LoPS for review." } %> - <% end %> - <% end %> + <%= f.govuk_collection_radio_buttons :passed, %i[true false], :itself, + legend: { text: "Does the response confirm that the LoPS is valid?" } %> <%= f.govuk_submit do %> <%= govuk_link_to "Cancel", [:assessor_interface, @application_form] %> diff --git a/app/views/assessor_interface/professional_standing_requests/edit_verify_failed.html.erb b/app/views/assessor_interface/professional_standing_requests/edit_verify_failed.html.erb new file mode 100644 index 0000000000..5a4c433e2f --- /dev/null +++ b/app/views/assessor_interface/professional_standing_requests/edit_verify_failed.html.erb @@ -0,0 +1,16 @@ +<% content_for :page_title, "#{"Error: " if @form.errors.any?}Record LoPS response" %> +<% content_for :back_link_url, assessor_interface_application_form_path(@application_form) %> + +<%= form_with model: @form, url: [:verify_failed, :assessor_interface, @application_form, @assessment, :professional_standing_request] do |f| %> + <%= f.govuk_error_summary %> + +

Record LoPS response

+ +

You have opted to send this LoPS for review.

+ + <%= f.govuk_text_area :note, label: { text: "Internal note: briefly explain to the assessor why you are sending this LoPS for review." } %> + + <%= f.govuk_submit do %> + <%= govuk_link_to "Cancel", [:assessor_interface, @application_form] %> + <% end %> +<% end %> diff --git a/app/views/assessor_interface/professional_standing_requests/show.html.erb b/app/views/assessor_interface/professional_standing_requests/show.html.erb index cd21887ef4..e15958bf5a 100644 --- a/app/views/assessor_interface/professional_standing_requests/show.html.erb +++ b/app/views/assessor_interface/professional_standing_requests/show.html.erb @@ -26,15 +26,17 @@ status: @professional_standing_request.requested? ? "completed" : "not_started" }, { - name: "Record LoPS verification", - link: [ - :verify, - :assessor_interface, - @application_form, - @assessment, - :professional_standing_request - ], - status: @professional_standing_request.status, + name: "Record LoPS response", + link: if @professional_standing_request.requested? + [ + :verify, + :assessor_interface, + @application_form, + @assessment, + :professional_standing_request + ] + end, + status: @professional_standing_request.requested? ? @professional_standing_request.status : "cannot_start" } ], } diff --git a/config/locales/assessor_interface.en.yml b/config/locales/assessor_interface.en.yml index 16088f2ad8..963e3d4733 100644 --- a/config/locales/assessor_interface.en.yml +++ b/config/locales/assessor_interface.en.yml @@ -397,12 +397,14 @@ en: inclusion: Select whether you are satisfied with the request note: blank: Enter why you are not satisfied - assessor_interface/requestable_verify_form: + assessor_interface/requestable_verify_failed_form: attributes: - passed: - inclusion: Select whether you are satisfied with the request note: blank: Enter why you are not satisfied + assessor_interface/requestable_verify_passed_form: + attributes: + passed: + inclusion: Select whether you are satisfied with the request assessor_interface/select_qualifications_form: attributes: qualification_ids: diff --git a/config/locales/helpers.en.yml b/config/locales/helpers.en.yml index a4dab01fb3..195948f429 100644 --- a/config/locales/helpers.en.yml +++ b/config/locales/helpers.en.yml @@ -119,10 +119,10 @@ en: passed_options: true: "Yes" false: "No" - assessor_interface_requestable_verify_form: + assessor_interface_requestable_verify_passed_form: passed_options: - true: "Yes" - false: "No" + true: "Yes, mark as completed" + false: "No, send for review" assessor_interface_verify_professional_standing_form: verify_professional_standing_options: true: Yes, verify LoPS diff --git a/config/routes.rb b/config/routes.rb index e2835be669..abe94b57da 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -120,6 +120,10 @@ post "review", to: "professional_standing_requests#update_review" get "verify", to: "professional_standing_requests#edit_verify" post "verify", to: "professional_standing_requests#update_verify" + get "verify-failed", + to: "professional_standing_requests#edit_verify_failed" + post "verify-failed", + to: "professional_standing_requests#update_verify_failed" end end diff --git a/spec/forms/assessor_interface/requestable_verify_failed_form_spec.rb b/spec/forms/assessor_interface/requestable_verify_failed_form_spec.rb new file mode 100644 index 0000000000..19db4517a7 --- /dev/null +++ b/spec/forms/assessor_interface/requestable_verify_failed_form_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe AssessorInterface::RequestableVerifyFailedForm, type: :model do + let(:requestable) { create(:reference_request, :received) } + let(:user) { create(:staff) } + let(:note) { "" } + + subject(:form) { described_class.new(requestable:, user:, note:) } + + describe "validations" do + it { is_expected.to validate_presence_of(:note) } + end + + describe "#save" do + subject(:save) { form.save } + + context "when passed is false" do + let(:note) { "Note." } + + it "sets verify_passed" do + expect { save }.to change(requestable, :verify_passed).from(nil).to( + false, + ) + end + + it "sets verify_note" do + expect { save }.to change(requestable, :verify_note).from("").to( + "Note.", + ) + end + + it "sets verified_at" do + freeze_time do + expect { save }.to change(requestable, :verified_at).from(nil).to( + Time.zone.now, + ) + end + end + + it "updates induction required" do + expect(UpdateAssessmentInductionRequired).to receive(:call) + save # rubocop:disable Rails/SaveBang + end + end + end +end diff --git a/spec/forms/assessor_interface/requestable_verify_form_spec.rb b/spec/forms/assessor_interface/requestable_verify_passed_form_spec.rb similarity index 51% rename from spec/forms/assessor_interface/requestable_verify_form_spec.rb rename to spec/forms/assessor_interface/requestable_verify_passed_form_spec.rb index bf71b3890d..3fcc061979 100644 --- a/spec/forms/assessor_interface/requestable_verify_form_spec.rb +++ b/spec/forms/assessor_interface/requestable_verify_passed_form_spec.rb @@ -2,22 +2,17 @@ require "rails_helper" -RSpec.describe AssessorInterface::RequestableVerifyForm, type: :model do - let(:requestable) { create(:reference_request, :received) } +RSpec.describe AssessorInterface::RequestableVerifyPassedForm, type: :model do + let(:requestable) do + create(:reference_request, :received, verify_note: "Old note") + end let(:user) { create(:staff) } let(:passed) { nil } - let(:note) { "" } - subject(:form) { described_class.new(requestable:, user:, passed:, note:) } + subject(:form) { described_class.new(requestable:, user:, passed:) } describe "validations" do it { is_expected.to allow_values(true, false).for(:passed) } - - context "when not passed" do - let(:passed) { "false" } - - it { is_expected.to validate_presence_of(:note) } - end end describe "#save" do @@ -26,13 +21,17 @@ context "when passed is true" do let(:passed) { true } - it "updates review passed field" do + it "sets verify_passed" do expect { save }.to change(requestable, :verify_passed).from(nil).to( true, ) end - it "sets reviewed at" do + it "sets verify_note" do + expect { save }.to change(requestable, :verify_note).to("") + end + + it "sets verified_at" do freeze_time do expect { save }.to change(requestable, :verified_at).from(nil).to( Time.zone.now, @@ -48,30 +47,21 @@ context "when passed is false" do let(:passed) { false } - let(:note) { "Note." } - it "updates review passed field" do - expect { save }.to change(requestable, :verify_passed).from(nil).to( - false, - ) + it "doesn't set verify_passed" do + expect { save }.to_not change(requestable, :verify_passed) end - it "updates review note field" do - expect { save }.to change(requestable, :verify_note).from("").to( - "Note.", - ) + it "doesn't set verify_note" do + expect { save }.to_not change(requestable, :verify_note) end - it "sets reviewed at" do - freeze_time do - expect { save }.to change(requestable, :verified_at).from(nil).to( - Time.zone.now, - ) - end + it "doesn't set verified_at" do + expect { save }.to_not change(requestable, :verified_at) end - it "updates induction required" do - expect(UpdateAssessmentInductionRequired).to receive(:call) + it "doesn't update induction required" do + expect(UpdateAssessmentInductionRequired).to_not receive(:call) save # rubocop:disable Rails/SaveBang end end diff --git a/spec/policies/assessor_interface/assessment_policy_spec.rb b/spec/policies/assessor_interface/assessment_policy_spec.rb index d6654cd0d9..a4c9e89656 100644 --- a/spec/policies/assessor_interface/assessment_policy_spec.rb +++ b/spec/policies/assessor_interface/assessment_policy_spec.rb @@ -40,12 +40,12 @@ describe "#update?" do subject(:update?) { policy.update? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" end describe "#edit?" do subject(:edit?) { policy.edit? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" end describe "#destroy?" do diff --git a/spec/policies/assessor_interface/assessment_recommendation_policy_spec.rb b/spec/policies/assessor_interface/assessment_recommendation_policy_spec.rb index 4514388be7..05685972a7 100644 --- a/spec/policies/assessor_interface/assessment_recommendation_policy_spec.rb +++ b/spec/policies/assessor_interface/assessment_recommendation_policy_spec.rb @@ -40,13 +40,13 @@ describe "#update?" do subject(:update?) { policy.update? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" it_behaves_like "a policy method requiring the verify permission" end describe "#edit?" do subject(:edit?) { policy.edit? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" it_behaves_like "a policy method requiring the verify permission" end diff --git a/spec/policies/assessor_interface/professional_standing_request_policy_spec.rb b/spec/policies/assessor_interface/professional_standing_request_policy_spec.rb index 1e6a8b37c6..a39ca0933a 100644 --- a/spec/policies/assessor_interface/professional_standing_request_policy_spec.rb +++ b/spec/policies/assessor_interface/professional_standing_request_policy_spec.rb @@ -86,14 +86,24 @@ it_behaves_like "a policy method requiring the verify permission" end + describe "#update_verify_failed?" do + subject(:update_verify_failed?) { policy.update_verify_failed? } + it_behaves_like "a policy method requiring the verify permission" + end + + describe "#edit_verify_failed?" do + subject(:edit_verify_failed?) { policy.edit_verify_failed? } + 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 award decline permission" + it_behaves_like "a policy method requiring the assess permission" end describe "#edit_review?" do subject(:edit_review?) { policy.edit_review? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" end describe "#destroy?" do diff --git a/spec/policies/assessor_policy_spec.rb b/spec/policies/assessor_policy_spec.rb index 440858c59b..8ef8d99f96 100644 --- a/spec/policies/assessor_policy_spec.rb +++ b/spec/policies/assessor_policy_spec.rb @@ -21,26 +21,26 @@ describe "#create?" do subject(:create?) { policy.create? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" end describe "#new?" do subject(:new?) { policy.new? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" end describe "#update?" do subject(:update?) { policy.update? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" end describe "#edit?" do subject(:edit?) { policy.edit? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" end describe "#destroy?" do subject(:destroy?) { policy.destroy? } - it_behaves_like "a policy method requiring the award decline permission" + it_behaves_like "a policy method requiring the assess permission" end end diff --git a/spec/support/autoload/page_objects/assessor_interface/professional_standing_request.rb b/spec/support/autoload/page_objects/assessor_interface/professional_standing_request.rb index a8930584ea..d6dbb1ff71 100644 --- a/spec/support/autoload/page_objects/assessor_interface/professional_standing_request.rb +++ b/spec/support/autoload/page_objects/assessor_interface/professional_standing_request.rb @@ -13,8 +13,8 @@ def request_lops_verification_task task_list.find_item("Request LoPS verification") end - def record_lops_verification_task - task_list.find_item("Record LoPS verification") + def record_lops_response_task + task_list.find_item("Record LoPS response") end end end 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 ff7ce7ce91..01e1bd6e4a 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 @@ -10,7 +10,16 @@ class RequestProfessionalStandingRequest < SitePrism::Page element :passed_checkbox, "#assessor-interface-requestable-request-form-passed-true-field", visible: false - element :continue_button, "button" + 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 diff --git a/spec/support/autoload/page_objects/assessor_interface/review_professional_standing_request.rb b/spec/support/autoload/page_objects/assessor_interface/review_professional_standing_request.rb index 3e79c583a7..0ca1663c95 100644 --- a/spec/support/autoload/page_objects/assessor_interface/review_professional_standing_request.rb +++ b/spec/support/autoload/page_objects/assessor_interface/review_professional_standing_request.rb @@ -13,9 +13,20 @@ class ReviewProfessionalStandingRequest < SitePrism::Page section :no_radio_item, PageObjects::GovukRadioItem, ".govuk-radios__item:nth-of-type(2)" - element :failure_reason_textarea, ".govuk-textarea" + element :note_textarea, ".govuk-textarea" element :submit_button, ".govuk-button" end + + def submit_yes + form.yes_radio_item.choose + form.submit_button.click + end + + def submit_no(note:) + form.no_radio_item.choose + form.note_textarea.fill_in with: note + form.submit_button.click + end end end end diff --git a/spec/support/autoload/page_objects/assessor_interface/verify_failed_professional_standing_request.rb b/spec/support/autoload/page_objects/assessor_interface/verify_failed_professional_standing_request.rb new file mode 100644 index 0000000000..24984a8995 --- /dev/null +++ b/spec/support/autoload/page_objects/assessor_interface/verify_failed_professional_standing_request.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module PageObjects + module AssessorInterface + class VerifyFailedProfessionalStandingRequest < SitePrism::Page + set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}" \ + "/professional-standing-request/verify-failed" + + section :form, "form" do + element :note_textarea, ".govuk-textarea" + element :submit_button, ".govuk-button" + end + + def submit(note:) + form.note_textarea.fill_in with: note + form.submit_button.click + end + end + end +end diff --git a/spec/support/autoload/page_objects/assessor_interface/verify_professional_standing_request.rb b/spec/support/autoload/page_objects/assessor_interface/verify_professional_standing_request.rb index 251d571f85..456c76eea6 100644 --- a/spec/support/autoload/page_objects/assessor_interface/verify_professional_standing_request.rb +++ b/spec/support/autoload/page_objects/assessor_interface/verify_professional_standing_request.rb @@ -13,9 +13,18 @@ class VerifyProfessionalStandingRequest < SitePrism::Page section :no_radio_item, PageObjects::GovukRadioItem, ".govuk-radios__item:nth-of-type(2)" - element :failure_reason_textarea, ".govuk-textarea" element :submit_button, ".govuk-button" end + + def submit_yes + form.yes_radio_item.choose + form.submit_button.click + end + + def submit_no + form.no_radio_item.choose + form.submit_button.click + end end end end diff --git a/spec/support/page_helpers.rb b/spec/support/page_helpers.rb index e25ab760b6..ce9bf931ac 100644 --- a/spec/support/page_helpers.rb +++ b/spec/support/page_helpers.rb @@ -225,6 +225,11 @@ def assessor_professional_standing_assessment_recommendation_verify_page PageObjects::AssessorInterface::ProfessionalStandingAssessmentRecommendationVerify.new end + def assessor_verify_failed_professional_standing_request_page + @assessor_verify_failed_professional_standing_request_page ||= + PageObjects::AssessorInterface::VerifyFailedProfessionalStandingRequest.new + end + def assessor_verify_professional_standing_request_page @assessor_verify_professional_standing_request_page ||= PageObjects::AssessorInterface::VerifyProfessionalStandingRequest.new diff --git a/spec/support/shared_examples/policy.rb b/spec/support/shared_examples/policy.rb index 096c7b18bc..625c23ebde 100644 --- a/spec/support/shared_examples/policy.rb +++ b/spec/support/shared_examples/policy.rb @@ -16,7 +16,7 @@ end end -RSpec.shared_examples "a policy method requiring the award decline permission" do +RSpec.shared_examples "a policy method requiring the assess permission" do context "without permission" do let(:user) { create(:staff) } it { is_expected.to be false } diff --git a/spec/system/assessor_interface/reviewing_professional_standing_spec.rb b/spec/system/assessor_interface/reviewing_professional_standing_spec.rb index 81c8e90b00..be85195d08 100644 --- a/spec/system/assessor_interface/reviewing_professional_standing_spec.rb +++ b/spec/system/assessor_interface/reviewing_professional_standing_spec.rb @@ -43,7 +43,7 @@ assessment_id:, ) - when_i_fill_in_the_review_lops_form + when_i_submit_yes_on_the_review_form then_i_see_the( :assessor_review_verifications_page, application_form_id:, @@ -51,6 +51,21 @@ ) and_i_see_the_lops_accepted + when_i_click_on_lops + then_i_see_the( + :assessor_review_professional_standing_request_page, + application_form_id:, + assessment_id:, + ) + + when_i_submit_no_on_the_review_form + then_i_see_the( + :assessor_review_verifications_page, + application_form_id:, + assessment_id:, + ) + and_i_see_the_lops_rejected + when_i_click_on_back_to_overview then_i_see_the(:assessor_application_page, application_form_id:) @@ -99,11 +114,14 @@ def when_i_click_on_lops ) end - def when_i_fill_in_the_review_lops_form - form = assessor_review_professional_standing_request_page.form + def when_i_submit_yes_on_the_review_form + assessor_review_professional_standing_request_page.submit_yes + end - form.yes_radio_item.choose - form.submit_button.click + def when_i_submit_no_on_the_review_form + assessor_review_professional_standing_request_page.submit_no( + note: "A note.", + ) end def when_i_click_on_back_to_overview @@ -126,6 +144,14 @@ def and_i_see_the_lops_accepted expect(item.status_tag.text).to eq("ACCEPTED") end + def and_i_see_the_lops_rejected + item = + assessor_review_verifications_page.task_list.find_item( + "Contact relevant competent authority", + ) + expect(item.status_tag.text).to eq("REJECTED") + end + def application_form @application_form ||= create(:application_form, :submitted).tap do |application_form| diff --git a/spec/system/assessor_interface/verifying_professional_standing_spec.rb b/spec/system/assessor_interface/verifying_professional_standing_spec.rb index b849654fbb..24d25ea5d2 100644 --- a/spec/system/assessor_interface/verifying_professional_standing_spec.rb +++ b/spec/system/assessor_interface/verifying_professional_standing_spec.rb @@ -18,6 +18,7 @@ assessment_id:, ) and_the_request_lops_verification_status_is("NOT STARTED") + and_the_record_lops_response_status_is("CANNOT START") when_i_click_request_lops_verification then_i_see_the( @@ -25,35 +26,58 @@ application_form_id:, assessment_id:, ) - and_i_submit + and_i_submit_unchecked_on_the_request_form then_i_see_the( :assessor_professional_standing_request_page, application_form_id:, assessment_id:, ) + and_the_request_lops_verification_status_is("NOT STARTED") + and_the_record_lops_response_status_is("CANNOT START") when_i_click_request_lops_verification - then_i_select_yes - and_i_submit + and_i_submit_checked_on_the_request_form then_i_see_the( :assessor_professional_standing_request_page, application_form_id:, assessment_id:, ) and_the_request_lops_verification_status_is("COMPLETED") + and_the_record_lops_response_status_is("WAITING ON") - when_i_click_record_lops_verification + when_i_click_record_lops_response then_i_see_the( :assessor_verify_professional_standing_request_page, application_form_id:, assessment_id:, ) - and_i_fill_in_the_verify_form + and_i_submit_yes_on_the_verify_form then_i_see_the( :assessor_professional_standing_request_page, application_form_id:, assessment_id:, ) + and_the_record_lops_response_status_is("COMPLETED") + + when_i_click_record_lops_response + then_i_see_the( + :assessor_verify_professional_standing_request_page, + application_form_id:, + assessment_id:, + ) + and_i_submit_no_on_the_verify_form + then_i_see_the( + :assessor_verify_failed_professional_standing_request_page, + application_form_id:, + assessment_id:, + ) + and_i_submit_an_internal_note + then_i_see_the( + :assessor_professional_standing_request_page, + application_form_id:, + assessment_id:, + ) + and_the_record_lops_response_status_is("REVIEW") end private @@ -70,8 +94,8 @@ def when_i_click_request_lops_verification assessor_professional_standing_request_page.request_lops_verification_task.click end - def when_i_click_record_lops_verification - assessor_professional_standing_request_page.record_lops_verification_task.click + def when_i_click_record_lops_response + assessor_professional_standing_request_page.record_lops_response_task.click end def and_the_request_lops_verification_status_is(status) @@ -83,25 +107,35 @@ def and_the_request_lops_verification_status_is(status) ).to eq(status) end - def and_i_fill_in_the_verify_form - form = assessor_verify_professional_standing_request_page.form + def and_the_record_lops_response_status_is(status) + expect( + assessor_professional_standing_request_page + .record_lops_response_task + .status_tag + .text, + ).to eq(status) + end + + def and_i_submit_checked_on_the_request_form + assessor_request_professional_standing_request_page.submit_checked + end - form.yes_radio_item.choose - form.submit_button.click + def and_i_submit_unchecked_on_the_request_form + assessor_request_professional_standing_request_page.submit_unchecked end - def then_i_select_yes - assessor_request_professional_standing_request_page - .form - .passed_checkbox - .click + def and_i_submit_yes_on_the_verify_form + assessor_verify_professional_standing_request_page.submit_yes end - def and_i_submit - assessor_request_professional_standing_request_page - .form - .continue_button - .click + def and_i_submit_no_on_the_verify_form + assessor_verify_professional_standing_request_page.submit_no + end + + def and_i_submit_an_internal_note + assessor_verify_failed_professional_standing_request_page.submit( + note: "A note.", + ) end def application_form