Skip to content

Commit

Permalink
Merge pull request #3231 from DFE-Digital/LUPEYALPHA-1101-automated-t…
Browse files Browse the repository at this point in the history
…ask-student-loan-plan

[LUPEYALPHA-1101] remove radio buttons from Student Loan Plan task
  • Loading branch information
alkesh authored Sep 30, 2024
2 parents 6a7ae5c + 1465863 commit 81e0602
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 32 deletions.
5 changes: 4 additions & 1 deletion app/helpers/admin/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ def task_status_tag(claim, task_name)
status_colour = "red"
end

tag_classes = "govuk-tag app-task-list__task-completed govuk-tag--#{status_colour}"
task_status_content_tag(status_colour:, status:)
end

def task_status_content_tag(status_colour:, status:)
tag_classes = "govuk-tag app-task-list__task-completed govuk-tag--#{status_colour}"
content_tag("strong", status, class: tag_classes)
end

Expand Down
11 changes: 9 additions & 2 deletions app/views/admin/tasks/student_loan_plan.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
</div>

<div class="govuk-grid-column-two-thirds">
<% if !@task.passed.nil? %>
<% if @task.persisted? %>
<%= render "task_outcome", task: @task %>
<% else %>
<%= render "form", task_name: "student_loan_plan", claim: @claim %>
<div class="govuk-inset-text task-outcome">
<p class="govuk-body">
<%= task_status_content_tag(status_colour: "grey", status: "Incomplete") %>
</p>
<p class="govuk-body">
This task has not been checked against Student Loan Company data yet.
</p>
</div>
<% end %>

<%= render partial: "admin/task_pagination" %>
Expand Down
2 changes: 0 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,6 @@ en:
claimant_answers:
true: "Yes"
false: "No"
student_loan_plan:
title: "Does the claimant’s student loan plan match the information we hold about their loan?"
forms:
ineligible:
courses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
trait :eligible do
eligible_school
contract_type { "permanent" }
verified
end

trait :not_verified do
eligible_school
contract_type { "permanent" }
end

trait :eligible_school do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "rails_helper"

RSpec.feature "Admin checks an Further Education Payments claim" do
it_behaves_like "Admin Checks", Policies::FurtherEducationPayments
end
8 changes: 4 additions & 4 deletions spec/features/admin/admin_claims_filtering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
let(:approved_awaiting_qa_claims) { create_list(:claim, 2, :approved, :flagged_for_qa, policy: Policies::LevellingUpPremiumPayments) }
let(:auto_approved_awaiting_payroll_claims) { create_list(:claim, 2, :auto_approved, policy: Policies::LevellingUpPremiumPayments) }
let(:approved_claim) { create(:claim, :approved, policy: Policies::LevellingUpPremiumPayments, assigned_to: mette, decision_creator: mary) }
let(:further_education_claims_awaiting_provider_verification) { create_list(:claim, 2, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible, assigned_to: valentino) }
let(:further_education_claims_awaiting_provider_verification) { create_list(:claim, 2, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :not_verified, assigned_to: valentino) }
let(:rejected_claim) { create(:claim, :rejected, policy: Policies::LevellingUpPremiumPayments, assigned_to: valentino) }

let!(:claims) do
Expand Down Expand Up @@ -74,8 +74,8 @@
scenario "the service operator can filter by themselves or other team members" do
click_on "View claims"

expect(page.find("table")).to have_content("TSLR").exactly(5).times
expect(page.find("table")).to have_content("ECP").exactly(10).times
expect(page).to have_selector("td[text()='TSLR']", count: 5)
expect(page).to have_selector("td[text()='ECP']", count: 10)

# Excludes payroll users and deleted users
expect(page).to have_select("team_member", options: ["All", "Unassigned", "#{user.given_name} #{user.family_name}", "Mary Wasu Wabi", "Valentino Ricci", "Mette Jørgensen"])
Expand Down Expand Up @@ -109,7 +109,7 @@
select "Unassigned", from: "team_member"
click_on "Apply filters"

expect(page.find("table")).to have_content("STRI").exactly(2).times
expect(page).to have_selector("td[text()='STRI']", count: 2)

expect_page_to_show_claims(lup_claims_unassigned)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
policy: Policies::FurtherEducationPayments,
eligibility: build(
:further_education_payments_eligibility,
:eligible
:not_verified
))
}

Expand All @@ -24,7 +24,7 @@
policy: Policies::FurtherEducationPayments,
eligibility: build(
:further_education_payments_eligibility,
:eligible,
:not_verified,
provider_verification_email_last_sent_at: DateTime.new(2024, 10, 1, 7, 0, 0)
))
}
Expand All @@ -35,7 +35,7 @@
policy: Policies::FurtherEducationPayments,
eligibility: build(
:further_education_payments_eligibility,
:eligible,
:not_verified,
provider_verification_email_last_sent_at: DateTime.new(2024, 10, 15, 7, 0, 0)
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ClaimVerifiers
let(:claim_arg) { claim }
let(:claim) { create(:claim, :submitted, policy:) }

shared_examples :execution_with_an_outcome do
shared_examples :creating_a_task_and_note do
let(:saved_task) { claim_arg.tasks.find_by(name: "student_loan_plan") }
let(:saved_note) { claim_arg.notes.last }

Expand Down Expand Up @@ -49,7 +49,7 @@ module ClaimVerifiers
end
end

shared_examples :execution_without_an_outcome do
shared_examples :not_creating_a_task_or_note do
it "does not save anything and returns immediately", :aggregate_failures do
is_expected.to be_nil

Expand All @@ -64,7 +64,7 @@ module ClaimVerifiers
context "when the claim policy is TSLR" do
let(:policy) { Policies::StudentLoans }

it_behaves_like :execution_without_an_outcome
it_behaves_like :not_creating_a_task_or_note
end

context "when the claim policy is ECP/LUP/FE" do
Expand All @@ -79,14 +79,14 @@ module ClaimVerifiers

let(:submitted_using_slc_data) { false }

it_behaves_like :execution_without_an_outcome
it_behaves_like :not_creating_a_task_or_note
end

context "when the claim was submitted using SLC data" do
let(:submitted_using_slc_data) { true }
let(:claim_student_loan_plan) { StudentLoan::PLAN_1 }

it_behaves_like :execution_without_an_outcome
it_behaves_like :not_creating_a_task_or_note
end

context "when the claim was not submitted using SLC data" do
Expand All @@ -97,7 +97,7 @@ module ClaimVerifiers
let(:expected_match_value) { nil }
let(:expected_note) { "[SLC Student loan plan] - No data" }

it_behaves_like :execution_with_an_outcome
it_behaves_like :creating_a_task_and_note
end

context "when there is student loan data - with a plan" do
Expand All @@ -109,7 +109,7 @@ module ClaimVerifiers
let(:expected_match_value) { "all" }
let(:expected_note) { "[SLC Student loan plan] - Matched - has a student loan" }

it_behaves_like :execution_with_an_outcome
it_behaves_like :creating_a_task_and_note
end

context "when there is student loan data - without a plan" do
Expand All @@ -121,7 +121,7 @@ module ClaimVerifiers
let(:expected_match_value) { "all" }
let(:expected_note) { "[SLC Student loan plan] - Matched - does not have a student loan" }

it_behaves_like :execution_with_an_outcome
it_behaves_like :creating_a_task_and_note
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@
subject { described_class.awaiting_further_education_provider_verification }

let!(:claim_with_fe_provider_verification) { create(:claim, policy: Policies::FurtherEducationPayments, eligibility_trait: :verified) }
let!(:claim_awaiting_fe_provider_verification) { create(:claim, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible) }
let!(:claim_awaiting_fe_provider_verification) { create(:claim, policy: Policies::FurtherEducationPayments, eligibility_trait: :not_verified) }
let!(:non_fe_claim) { create(:claim, policy: Policies::StudentLoans) }

it "returns claims that are awaiting FE provider verification" do
Expand Down
66 changes: 55 additions & 11 deletions spec/support/admin_checks_feature_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

before do
@signed_in_user = sign_in_as_service_operator
create(:task, :automated, :passed, name: "student_loan_plan", claim:)
end

def lup_claim_checking_steps
Expand Down Expand Up @@ -66,15 +67,13 @@ def lup_claim_checking_steps

expect(claim.tasks.find_by!(name: "employment").passed?).to eq(true)

expect(page).to have_content(I18n.t("#{claim.policy.to_s.underscore}.admin.task_questions.student_loan_plan.title"))
expect(page).to have_content("Student loan plan")
expect(page).to have_link("Next: Decision")
expect(page).to have_link("Previous: Employment")
expect(page).to have_content("Passed")
expect(page).not_to have_button("Save and continue")

choose "Yes"
click_on "Save and continue"

expect(claim.tasks.find_by!(name: "student_loan_plan").passed?).to eq(true)
click_link "Next: Decision"

expect(page).to have_content("Claim decision")
expect(page).not_to have_link("Next")
Expand Down Expand Up @@ -149,15 +148,13 @@ def ecp_claim_checking_steps

expect(claim.tasks.find_by!(name: "employment").passed?).to eq(true)

expect(page).to have_content(I18n.t("#{claim.policy.to_s.underscore}.admin.task_questions.student_loan_plan.title"))
expect(page).to have_content("Student loan plan")
expect(page).to have_link("Next: Decision")
expect(page).to have_link("Previous: Employment")
expect(page).to have_content("Passed")
expect(page).not_to have_button("Save and continue")

choose "Yes"
click_on "Save and continue"

expect(claim.tasks.find_by!(name: "student_loan_plan").passed?).to eq(true)
click_link "Next: Decision"

expect(page).to have_content("Claim decision")
expect(page).not_to have_link("Next")
Expand Down Expand Up @@ -243,6 +240,51 @@ def tslr_claim_checking_steps
expect(claim.latest_decision.created_by).to eq(@signed_in_user)
end

def fe_claim_checking_steps
visit admin_claims_path
find("a[href='#{admin_claim_tasks_path(claim)}']").click

click_on I18n.t("admin.tasks.identity_confirmation.title")

expect(page).to have_content(I18n.t("#{claim.policy.to_s.underscore}.admin.task_questions.identity_confirmation.title"))
expect(page).to have_link("Next: Provider verification")
expect(page).not_to have_link("Previous")

choose "Yes"
click_on "Save and continue"

expect(claim.tasks.find_by!(name: "identity_confirmation").passed?).to eq(true)

expect(page).to have_content(I18n.t("#{claim.policy.to_s.underscore}.admin.task_questions.provider_verification.title"))
expect(page).to have_link("Next: Student loan plan")
expect(page).to have_link("Previous: Identity confirmation")

choose "Yes"
click_on "Save and continue"

expect(claim.tasks.find_by!(name: "provider_verification").passed?).to eq(true)

expect(page).to have_content("Student loan plan")
expect(page).to have_content("Passed")
expect(page).not_to have_button("Save and continue")
expect(page).to have_link("Next: Decision")
expect(page).to have_link("Previous: Provider verification")

click_link "Next: Decision"

expect(page).to have_content("Claim decision")
expect(page).not_to have_link("Next")
expect(page).to have_link("Previous: Student loan plan")

choose "Approve"
fill_in "Decision notes", with: "All checks passed!"
click_on "Confirm decision"

expect(page).to have_content("Claim has been approved successfully")
expect(claim.latest_decision).to be_approved
expect(claim.latest_decision.created_by).to eq(@signed_in_user)
end

def qa_approval_steps
expect(page).to have_content("This claim has been marked for a quality assurance review")
expect(page).to have_content("Quality assurance decision")
Expand All @@ -269,6 +311,8 @@ def claim_checking_steps(policy)
ecp_claim_checking_steps
elsif policy == Policies::StudentLoans
tslr_claim_checking_steps
elsif policy == Policies::FurtherEducationPayments
fe_claim_checking_steps
else
raise "Unimplemented policy: #{policy}"
end
Expand All @@ -281,7 +325,7 @@ def claim_checking_steps(policy)
claim_checking_steps(policy)
end

scenario "service operator QAs a #{policy_name} claim" do
scenario "service operator QAs a #{policy_name} claim", if: policy::MIN_QA_THRESHOLD.positive? do
claim_checking_steps(policy)
qa_approval_steps
end
Expand Down

0 comments on commit 81e0602

Please sign in to comment.