Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LUPEYALPHA-1061] Practitioner invalid reference screen #3279

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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?
Expand Down
Original file line number Diff line number Diff line change
@@ -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) %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">
There is a problem
</h1>
<p class="govuk-body">
This claim reference isn’t correct. Check your invite email.
</p>

<p class="govuk-body">
Your employer will also have the claim reference in their claim confirmation email.
</p>

<p class="govuk-body">
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.
</p>

<%= govuk_button_link_to "Try again", claim_path(current_journey_routing_name, "find-reference", request.query_parameters) %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<% ineligibility_reason = Journeys::EarlyYearsPayment::Practitioner::EligibilityChecker.new(journey_session:).ineligibility_reason %>
<%= render "ineligibility_#{ineligibility_reason}" %>
5 changes: 2 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1392,15 +1392,14 @@ en:
claim_subject: "Early Years Payment"
early_years_payment_practitioner:
journey_name: Claim an early years financial incentive payment - practitioner
feedback_email: [email protected]
support_email: "help@opsteam.com"
feedback_email: "[email protected]"
support_email: "help@opsteam.education.gov.uk"
claim_description: for early years financial incentive payment
forms:
find_reference:
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 protected]"
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"
Expand All @@ -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 protected]"
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
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]"
)
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 }
Expand Down Expand Up @@ -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: "[email protected]"
)
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