From 64d43169514719f94ce7896e8d253c6c409ac765 Mon Sep 17 00:00:00 2001
From: vacabor <166112501+vacabor@users.noreply.github.com>
Date: Fri, 4 Oct 2024 10:03:57 +0100
Subject: [PATCH 1/3] WIP: EY Practitioner invalid reference screen
---
.../practitioner/find_reference_form.rb | 14 ++---------
.../practitioner/session_answers.rb | 1 +
.../practitioner/slug_sequence.rb | 8 +++++-
.../policy_eligibility_checker.rb | 12 +++++++--
...bility_reference_number_not_found.html.erb | 25 +++++++++++++++++++
.../practitioner/claims/ineligible.html.erb | 2 ++
config/locales/en.yml | 4 +--
7 files changed, 49 insertions(+), 17 deletions(-)
create mode 100644 app/views/early_years_payment/practitioner/claims/_ineligibility_reference_number_not_found.html.erb
create mode 100644 app/views/early_years_payment/practitioner/claims/ineligible.html.erb
diff --git a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb
index cc16691389..89f7055c1f 100644
--- a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb
+++ b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb
@@ -6,14 +6,14 @@ class FindReferenceForm < Form
attribute :email, :string
validates :reference_number, presence: {message: i18n_error_message(:presence)}
- validate :validate_permissible_reference_number
def save
return false if invalid?
journey_session.answers.assign_attributes(
reference_number:,
- start_email: email
+ start_email: email,
+ reference_number_found: claim_exists?
)
journey_session.save!
end
@@ -27,16 +27,6 @@ def claim_exists?
.where(practitioner_email_address: email)
.exists?
end
-
- def validate_permissible_reference_number
- unless claim_exists?
- errors.add(
- :reference_number,
- :impermissible,
- message: self.class.i18n_error_message(:impermissible)
- )
- end
- end
end
end
end
diff --git a/app/models/journeys/early_years_payment/practitioner/session_answers.rb b/app/models/journeys/early_years_payment/practitioner/session_answers.rb
index 4e96aefd5e..2415e58378 100644
--- a/app/models/journeys/early_years_payment/practitioner/session_answers.rb
+++ b/app/models/journeys/early_years_payment/practitioner/session_answers.rb
@@ -3,6 +3,7 @@ module EarlyYearsPayment
module Practitioner
class SessionAnswers < Journeys::SessionAnswers
attribute :reference_number, :string
+ attribute :reference_number_found, :boolean, default: nil
attribute :start_email, :string
def policy
diff --git a/app/models/journeys/early_years_payment/practitioner/slug_sequence.rb b/app/models/journeys/early_years_payment/practitioner/slug_sequence.rb
index 249ea9e7b8..c917a3b1e5 100644
--- a/app/models/journeys/early_years_payment/practitioner/slug_sequence.rb
+++ b/app/models/journeys/early_years_payment/practitioner/slug_sequence.rb
@@ -2,7 +2,7 @@ module Journeys
module EarlyYearsPayment
module Practitioner
class SlugSequence
- SLUGS = %w[
+ CLAIM_SLUGS = %w[
find-reference
sign-in
how-we-use-your-information
@@ -14,6 +14,12 @@ class SlugSequence
check-your-answers
].freeze
+ RESULTS_SLUGS = %w[
+ ineligible
+ ].freeze
+
+ SLUGS = (CLAIM_SLUGS + RESULTS_SLUGS).freeze
+
def self.start_page_url
Rails.application.routes.url_helpers.landing_page_path("early-years-payment-practitioner")
end
diff --git a/app/models/policies/early_years_payments/policy_eligibility_checker.rb b/app/models/policies/early_years_payments/policy_eligibility_checker.rb
index 7cb772b3f1..67f5908415 100644
--- a/app/models/policies/early_years_payments/policy_eligibility_checker.rb
+++ b/app/models/policies/early_years_payments/policy_eligibility_checker.rb
@@ -20,7 +20,7 @@ def ineligible?
end
def ineligibility_reason
- start_ineligibility_reason || authenticated_ineligibility_reason
+ start_ineligibility_reason || provider_ineligibility_reason || practitioner_ineligibility_reason
end
def start_ineligibility_reason
@@ -31,7 +31,7 @@ def start_ineligibility_reason
end
end
- def authenticated_ineligibility_reason
+ def provider_ineligibility_reason
return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Provider::Authenticated::SessionAnswers)
if answers.nursery_urn.to_s == "none_of_the_above"
@@ -43,6 +43,14 @@ def authenticated_ineligibility_reason
end
end
+ def practitioner_ineligibility_reason
+ return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Practitioner::SessionAnswers)
+
+ if answers.reference_number_found == false
+ :reference_number_not_found
+ end
+ end
+
private
def ineligible_returner?
diff --git a/app/views/early_years_payment/practitioner/claims/_ineligibility_reference_number_not_found.html.erb b/app/views/early_years_payment/practitioner/claims/_ineligibility_reference_number_not_found.html.erb
new file mode 100644
index 0000000000..b4877a8bd6
--- /dev/null
+++ b/app/views/early_years_payment/practitioner/claims/_ineligibility_reference_number_not_found.html.erb
@@ -0,0 +1,25 @@
+<% content_for(:page_title, page_title("There is a problem", journey: current_journey_routing_name)) %>
+<% @backlink_path = claim_path(current_journey_routing_name, "find-reference", request.query_parameters) %>
+
+
+
+
+ There is a problem
+
+
+ This claim reference isn’t correct. Check your invite email.
+
+
+
+ Your employer will also have the claim reference in their claim confirmation email.
+
+
+
+ Contact us at
+ <%= govuk_link_to t("early_years_payment_practitioner.feedback_email"), "mailto:#{t("early_years_payment_practitioner.feedback_email")}", no_visited_state: true %>.
+ if you need further assistance to sign into the early years financial incentive payments service.
+
+
+ <%= govuk_button_link_to "Try again", claim_path(current_journey_routing_name, "find-reference", request.query_parameters) %>
+
+
diff --git a/app/views/early_years_payment/practitioner/claims/ineligible.html.erb b/app/views/early_years_payment/practitioner/claims/ineligible.html.erb
new file mode 100644
index 0000000000..33f31fe93c
--- /dev/null
+++ b/app/views/early_years_payment/practitioner/claims/ineligible.html.erb
@@ -0,0 +1,2 @@
+<% ineligibility_reason = Journeys::EarlyYearsPayment::Practitioner::EligibilityChecker.new(journey_session:).ineligibility_reason %>
+<%= render "ineligibility_#{ineligibility_reason}" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index b22d64db1e..927da7993e 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1392,8 +1392,8 @@ en:
claim_subject: "Early Years Payment"
early_years_payment_practitioner:
journey_name: Claim an early years financial incentive payment - practitioner
- feedback_email: implementme@example.com
- support_email: "help@opsteam.com"
+ feedback_email: "help@opsteam.education.gov.uk"
+ support_email: "help@opsteam.education.gov.uk"
claim_description: for early years financial incentive payment
forms:
find_reference:
From de0153789bd4d16f392a3ccdbccc0c6e18b18fa9 Mon Sep 17 00:00:00 2001
From: vacabor <166112501+vacabor@users.noreply.github.com>
Date: Fri, 4 Oct 2024 16:50:00 +0100
Subject: [PATCH 2/3] Spec to cover the unhappy path
---
config/locales/en.yml | 1 -
.../practitioner/find_reference_spec.rb | 27 +++++++++++++++----
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 927da7993e..20cbaf5b50 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1400,7 +1400,6 @@ en:
question: Enter your claim reference
errors:
presence: Enter your claim reference number
- impermissible: Enter a valid claim reference number
email_address:
label: Your email address
hint1: We’ll use this to update you with progress on your claim.
diff --git a/spec/features/early_years_payment/practitioner/find_reference_spec.rb b/spec/features/early_years_payment/practitioner/find_reference_spec.rb
index 0aa49c38b1..fd3c9be9dd 100644
--- a/spec/features/early_years_payment/practitioner/find_reference_spec.rb
+++ b/spec/features/early_years_payment/practitioner/find_reference_spec.rb
@@ -18,17 +18,13 @@
fill_in "Claim reference number", with: claim.reference
click_button "Submit"
- expect(page).to have_content "Enter your claim reference"
+ expect(page).to have_content "This claim reference isn’t correct."
end
scenario "after multiple attempts should work" do
when_early_years_payment_practitioner_journey_configuration_exists
visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=user@example.com"
- expect(page).to have_content "Enter your claim reference"
- fill_in "Claim reference number", with: "foo"
- click_button "Submit"
-
expect(page).to have_content "Enter your claim reference"
fill_in "Claim reference number", with: claim.reference
click_button "Submit"
@@ -41,4 +37,25 @@
click_button "Submit"
expect(page).to have_content "Sign in with GOV.UK One Login"
end
+
+ scenario "should show ineligibility page when an invalid reference is given" do
+ when_early_years_payment_practitioner_journey_configuration_exists
+
+ visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=user@example.com"
+ expect(page).to have_content "Enter your claim reference"
+ fill_in "Claim reference number", with: "invalid"
+ click_button "Submit"
+
+ expect(page).to have_content "This claim reference isn’t correct."
+ click_link "Try again"
+
+ expect(page).to have_content "Enter your claim reference"
+ fill_in "Claim reference number", with: "also invalid"
+ click_button "Submit"
+
+ expect(page).to have_content "This claim reference isn’t correct."
+ click_link "Back"
+
+ expect(page).to have_content "Enter your claim reference"
+ end
end
From 9d557e90bfca2fe4ac114382d8a746ca1c09540b Mon Sep 17 00:00:00 2001
From: vacabor <166112501+vacabor@users.noreply.github.com>
Date: Fri, 4 Oct 2024 20:53:10 +0100
Subject: [PATCH 3/3] Form specs for reference_number_found
---
.../practitioner/find_reference_form_spec.rb | 62 +++++++++++--------
1 file changed, 35 insertions(+), 27 deletions(-)
diff --git a/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb b/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb
index 9b08b262ab..b78fc4e50c 100644
--- a/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb
+++ b/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb
@@ -21,33 +21,6 @@
end
end
- context "when random string" do
- let(:reference_number) { "foo" }
-
- it "is not valid" do
- expect(subject).to be_invalid
- expect(subject.errors[:reference_number]).to be_present
- end
- end
-
- context "when non EY claim" do
- let(:reference_number) { claim.reference }
- let(:email) { claim.practitioner_email_address }
-
- let(:claim) do
- create(
- :claim,
- reference: "foo",
- practitioner_email_address: "user@example.com"
- )
- end
-
- it "is not valid" do
- expect(subject).to be_invalid
- expect(subject.errors[:reference_number]).to be_present
- end
- end
-
context "when EY claim" do
let(:reference_number) { claim.reference }
let(:email) { claim.practitioner_email_address }
@@ -84,5 +57,40 @@
subject.save
}.to change { journey_session.reload.answers.reference_number }.from(nil).to(reference_number)
end
+
+ it "updates reference_number_found in session" do
+ expect {
+ subject.save
+ }.to change { journey_session.reload.answers.reference_number_found }.from(nil).to(true)
+ end
+
+ context "when reference is a random string" do
+ let(:reference_number) { "foo" }
+
+ it "updates reference_number_found in session" do
+ expect {
+ subject.save
+ }.to change { journey_session.reload.answers.reference_number_found }.from(nil).to(false)
+ end
+ end
+
+ context "when reference is a non EY claim" do
+ let(:reference_number) { claim.reference }
+ let(:email) { claim.practitioner_email_address }
+
+ let(:claim) do
+ create(
+ :claim,
+ reference: "foo",
+ practitioner_email_address: "user@example.com"
+ )
+ end
+
+ it "updates reference_number_found in session" do
+ expect {
+ subject.save
+ }.to change { journey_session.reload.answers.reference_number_found }.from(nil).to(false)
+ end
+ end
end
end