Skip to content

Commit

Permalink
Update system tests for verifying LoPS
Browse files Browse the repository at this point in the history
This updates the system tests for verifying LoPS to use the newer verify
page and updates to use the right permissions.
  • Loading branch information
thomasleese committed Nov 8, 2023
1 parent 9ab23db commit 731874c
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 86 deletions.
2 changes: 1 addition & 1 deletion app/components/status_tag/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def tags
received_reference: "purple",
rejected: "red",
requested: "yellow",
review: "purple",
review: "pink",
submitted: "grey",
valid: "green",
verification: "yellow",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def index

@professional_standing_request =
assessment.professional_standing_request if assessment.professional_standing_request.verify_failed?

render layout: "full_from_desktop"
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/region_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def region_certificate_phrase(region)
end

def region_teaching_authority_name(region)
region.teaching_authority_name.presence || "teaching authority"
region.teaching_authority_name.presence || "relevant competent authority"
end

def region_teaching_authority_name_phrase(region)
Expand Down
82 changes: 47 additions & 35 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def can_award?
all_qualification_requests_review_passed? &&
professional_standing_request_verify_passed?
elsif review?
professional_standing_request_review_passed?
enough_reference_requests_review_passed? &&
all_qualification_requests_review_passed? &&
professional_standing_request_review_passed?
else
false
end
Expand All @@ -112,13 +114,29 @@ def can_decline?
any_preliminary_section_failed? ||
(all_sections_finished? && any_section_failed? && any_section_declines?)
elsif request_further_information?
any_further_information_request_failed?
elsif review?
professional_standing_request_review_failed?
all_further_information_requests_reviewed? &&
any_further_information_requests_failed?
elsif verify?
enough_reference_requests_reviewed? &&
all_qualification_requests_reviewed? &&
professional_standing_request_verified? && !can_review? && !can_award?
return false if professional_standing_request_verify_failed?

unless enough_reference_requests_reviewed? &&
all_qualification_requests_reviewed? &&
professional_standing_request_verify_passed?
return false
end

!enough_reference_requests_review_passed? ||
any_qualification_requests_review_failed?
elsif review?
unless enough_reference_requests_reviewed? &&
all_qualification_requests_reviewed? &&
professional_standing_request_reviewed?
return false
end

!enough_reference_requests_review_passed? ||
any_qualification_requests_review_failed? ||
professional_standing_request_review_failed?
else
false
end
Expand Down Expand Up @@ -206,14 +224,22 @@ def no_section_declines?
sections.none?(&:declines_assessment?)
end

def all_further_information_requests_reviewed?
further_information_requests.present? &&
further_information_requests.all?(&:reviewed?)
end

def all_further_information_requests_passed?
further_information_requests.present? &&
further_information_requests.all?(&:review_passed?)
end

def any_further_information_request_failed?
further_information_requests.present? &&
further_information_requests.any?(&:review_failed?)
def any_further_information_requests_failed?
further_information_requests.any?(&:review_failed?)
end

def enough_reference_requests_reviewed?
references_verified || reference_requests.empty?
end

def enough_reference_requests_review_passed?
Expand All @@ -234,48 +260,37 @@ def enough_reference_requests_review_passed?
months_count >= 9
end

def enough_reference_requests_reviewed?
references_verified || reference_requests.empty?
def all_qualification_requests_reviewed?
qualification_requests.all?(&:reviewed?)
end

def all_qualification_requests_review_passed?
if qualification_requests.present?
qualification_requests.all?(&:review_passed?)
else
true
end
qualification_requests.all?(&:review_passed?)
end

def all_qualification_requests_reviewed?
if qualification_requests.present?
qualification_requests.all?(&:reviewed?)
else
true
end
def any_qualification_requests_review_failed?
qualification_requests.any?(&:review_failed?)
end

def professional_standing_request_review_passed?
def professional_standing_request_reviewed?
if professional_standing_request_part_of_verification?
professional_standing_request.review_passed?
professional_standing_request.reviewed?
else
true
end
end

def professional_standing_request_verified?
def professional_standing_request_review_passed?
if professional_standing_request_part_of_verification?
professional_standing_request.verified?
professional_standing_request.review_passed?
else
true
end
end

def professional_standing_request_review_failed?
if professional_standing_request_part_of_verification?
professional_standing_request_part_of_verification? &&
professional_standing_request.review_failed?
else
false
end
end

def professional_standing_request_verify_passed?
Expand All @@ -287,11 +302,8 @@ def professional_standing_request_verify_passed?
end

def professional_standing_request_verify_failed?
if professional_standing_request_part_of_verification?
professional_standing_request_part_of_verification? &&
professional_standing_request.verify_failed?
else
false
end
end

def professional_standing_request_part_of_verification?
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/requestable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def verify_failed?

def status
if verify_passed? || review_passed?
"accepted"
"completed"
elsif review_failed?
"rejected"
elsif verify_failed?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
<%= govuk_panel(title_text: "QTS application #{@view_object.application_form.reference} has been #{@view_object.status.downcase}") %>
<% end %>

<% unless @view_object.application_form.waiting_on? %>
<p class="govuk-body">The status of this application has been changed to ’<%= @view_object.status %>‘.</p>
<% end %>

<% if @view_object.assessment.review? %>
<p class="govuk-body">An assessor will now review the application and make a decision on awarding or declining QTS.</p>
<% elsif @view_object.application_form.declined? %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<h1 class="govuk-heading-xl"><%= t(".heading") %></h1>

<p class="govuk-body">If you choose to verify this applicant’s letter of professional standing, you’ll need to email the competent authority directly, then come back to record the outcome.</p>
<p class="govuk-body">If you choose to verify this application's LoPS an admin will email the competent authority and record the response.</p>

<%= f.govuk_collection_radio_buttons :verify_professional_standing, %i[true false], :itself, legend: nil %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1 class="govuk-heading-xl">Verify LoPS</h1>

<p class="govuk-body">
You need to request verification for this applications LoPS. Follow the steps below:
You need to request verification for this application’s LoPS.
</p>

<%= render(TaskList::Component.new(
Expand Down
31 changes: 21 additions & 10 deletions app/views/assessor_interface/review_verifications/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@

<h1 class="govuk-heading-xl">Review verifications</h1>

<%= govuk_table do |table|
<p class="govuk-body govuk-!-padding-bottom-2">
The following verification tasks have been flagged for review:
</p>

<%= render(TaskList::Component.new(
if @professional_standing_request.present?
table.with_caption(text: "LoPS")
table.with_body do |body|
body.with_row do |row|
row.with_cell { govuk_link_to region_certificate_name(@application_form.region), [:review, :assessor_interface, @application_form, @assessment, :professional_standing_request] }
row.with_cell { render(StatusTag::Component.new(@professional_standing_request.review_status)) }
end
end
[
{
title: "LoPS",
items: [
{
name: region_teaching_authority_name(@application_form.region).upcase_first,
link: [:review, :assessor_interface, @application_form, @assessment, :professional_standing_request],
status: @professional_standing_request.review_status,
}
],
}
]
end
end %>
)) %>

<%= govuk_button_link_to "Back to overview", [:assessor_interface, @application_form] %>
<div class="govuk-!-padding-top-3">
<%= govuk_button_link_to "Back to overview", [:assessor_interface, @application_form] %>
</div>
3 changes: 2 additions & 1 deletion spec/mailers/teacher_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@
it do
is_expected.to include(
"Thank you for requesting your letter that proves you’re recognised as a teacher from " \
"the teaching authority. We have now received this document and attached it to your application.",
"the relevant competent authority. We have now received this document and attached it " \
"to your application.",
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/assessment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@

context "when awarded pending verification" do
before { assessment.verify! }
it { is_expected.to be true }
it { is_expected.to be false }
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def request_further_information
def decline_qts
new_states.find { |radio_item| radio_item.label.text == "Decline QTS" }
end

def send_for_review
new_states.find do |radio_item|
radio_item.label.text == "Send application for review"
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ class ReviewVerifications < SitePrism::Page
set_url "/assessor/applications/{application_form_id}/assessments/{assessment_id}" \
"/review-verifications"

sections :rows, ".govuk-table__row" do
element :link, ".govuk-link"
element :tag, ".govuk-tag"
end
section :task_list, TaskList, ".app-task-list"

element :back_to_overview_button, ".govuk-button"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_examples/requestable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
it "is accepted when passed is true" do
subject.review_passed = true
subject.reviewed_at = Time.zone.now
expect(subject.status).to eq("accepted")
expect(subject.status).to eq("completed")
end

it "is rejected when passed is false" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
then_i_see_the(:assessor_application_page, application_form_id:)

when_i_click_on_verification_decision
then_i_see_the(:assessor_complete_assessment_page, application_form_id:)

when_i_select_send_for_review
then_i_see_the(
:assessor_assessment_recommendation_review_page,
application_form_id:,
)

when_i_click_continue_from_review
then_i_see_the(:assessor_application_status_page, application_form_id:)

when_i_click_on_overview_button
then_i_see_the(:assessor_application_page, application_form_id:)

when_i_click_on_review_verifications
Expand Down Expand Up @@ -58,12 +70,19 @@ def given_there_is_an_application_form_with_failed_verifications

def when_i_click_on_verification_decision
assessor_application_page.verification_decision_task.click
end

# TODO: review functionality is not built yet, this page can never be reached
application_form.assessment.review!
def when_i_select_send_for_review
assessor_complete_assessment_page.send_for_review.choose
assessor_complete_assessment_page.continue_button.click
end

# TODO: reload the page
when_i_visit_the(:assessor_application_page, application_form_id:)
def when_i_click_continue_from_review
assessor_assessment_recommendation_review_page.continue_button.click
end

def when_i_click_on_overview_button
assessor_application_status_page.button_group.overview_button.click
end

def when_i_click_on_review_verifications
Expand All @@ -75,7 +94,9 @@ def when_i_click_on_assessment_decision
end

def when_i_click_on_lops
assessor_review_verifications_page.rows.first.link.click
assessor_application_page.task_list.click_item(
"Relevant competent authority",
)
end

def when_i_fill_in_the_review_lops_form
Expand All @@ -90,15 +111,19 @@ def when_i_click_on_back_to_overview
end

def and_i_see_the_lops_not_started
expect(assessor_review_verifications_page.rows.first.tag.text).to eq(
"NOT STARTED",
)
item =
assessor_review_verifications_page.task_list.find_item(
"Relevant competent authority",
)
expect(item.status_tag.text).to eq("NOT STARTED")
end

def and_i_see_the_lops_accepted
expect(assessor_review_verifications_page.rows.first.tag.text).to eq(
"ACCEPTED",
)
item =
assessor_review_verifications_page.task_list.find_item(
"Relevant competent authority",
)
expect(item.status_tag.text).to eq("ACCEPTED")
end

def application_form
Expand Down
Loading

0 comments on commit 731874c

Please sign in to comment.