From 6d89bbe27686eac2395b286a011f84391f024a74 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Wed, 28 Aug 2024 14:34:31 +0100 Subject: [PATCH] [LUPEYALPHA-882] Change checkbox to radio buttons for child-facing page (#3119) --- .../authenticated/child_facing_form.rb | 2 +- .../policy_eligibility_checker.rb | 2 + ...igibility_not_child_facing_enough.html.erb | 26 +++++++++++ .../claims/child_facing.html.erb | 18 +++++--- config/locales/en.yml | 12 +++-- .../provider/authenticated/happy_path_spec.rb | 2 +- .../authenticated/not_child_facing_spec.rb | 44 +++++++++++++++++++ .../authenticated/child_facing_form_spec.rb | 2 +- .../eligible_ey_journey_authenticated.rb | 2 +- 9 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 app/views/early_years_payment/provider/authenticated/claims/_ineligibility_not_child_facing_enough.html.erb create mode 100644 spec/features/early_years_payment/provider/authenticated/not_child_facing_spec.rb diff --git a/app/forms/journeys/early_years_payment/provider/authenticated/child_facing_form.rb b/app/forms/journeys/early_years_payment/provider/authenticated/child_facing_form.rb index 311e5e6d87..dbde1fc476 100644 --- a/app/forms/journeys/early_years_payment/provider/authenticated/child_facing_form.rb +++ b/app/forms/journeys/early_years_payment/provider/authenticated/child_facing_form.rb @@ -6,7 +6,7 @@ class ChildFacingForm < Form attribute :child_facing_confirmation_given, :boolean validates :child_facing_confirmation_given, - presence: {message: i18n_error_message(:presence)} + inclusion: {in: [true, false], message: i18n_error_message(:inclusion)} def save return false if invalid? 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 04f922ef51..d1d7a09e04 100644 --- a/app/models/policies/early_years_payments/policy_eligibility_checker.rb +++ b/app/models/policies/early_years_payments/policy_eligibility_checker.rb @@ -24,6 +24,8 @@ def ineligible? def ineligibility_reason if answers.nursery_urn.to_s == "none_of_the_above" :nursery_is_not_listed + elsif answers.child_facing_confirmation_given == false + :not_child_facing_enough end end end diff --git a/app/views/early_years_payment/provider/authenticated/claims/_ineligibility_not_child_facing_enough.html.erb b/app/views/early_years_payment/provider/authenticated/claims/_ineligibility_not_child_facing_enough.html.erb new file mode 100644 index 0000000000..b1f0c376ce --- /dev/null +++ b/app/views/early_years_payment/provider/authenticated/claims/_ineligibility_not_child_facing_enough.html.erb @@ -0,0 +1,26 @@ +<% title = "#{answers.first_name} is not eligible for this payment" %> +<% content_for(:page_title, page_title(title, journey: current_journey_routing_name)) %> + +
+
+

<%= title %>

+

+ Based on the information you have provided, + <%= answers.first_name %> is not eligible to claim an early years incentive payment. +

+ +

+ For further guidance, you should refer to the + <%= govuk_link_to "full eligibility criteria", claim_path(Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME, "landing-page") %> + at the start of this service. +

+ +

Get help with your claim

+ +

+ If you have any questions, contact us for help at + <%= mail_to support_email_address(current_journey_routing_name), support_email_address(current_journey_routing_name), class: "govuk-link" %> +

+ <%= govuk_button_link_to "Start a new claim", claim_path(Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME, "landing-page") %> +
+
diff --git a/app/views/early_years_payment/provider/authenticated/claims/child_facing.html.erb b/app/views/early_years_payment/provider/authenticated/claims/child_facing.html.erb index 19624cd900..e14f296520 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/child_facing.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/child_facing.html.erb @@ -1,16 +1,24 @@ -<% content_for(:page_title, page_title(@form.t(:question, first_name: answers.first_name), journey: current_journey_routing_name, show_error: @form.errors.any?)) %> +<% question = @form.t("question", first_name: answers.first_name) %> +<% content_for(:page_title, page_title(question, journey: current_journey_routing_name, show_error: @form.errors.any?)) %>
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= f.govuk_error_summary %> - <%= f.govuk_check_boxes_fieldset :child_facing_confirmation_given, multiple: false, legend: { text: @form.t(:question, first_name: answers.first_name), tag: "h1", size: "l" }, hint: -> do %> + <%= f.govuk_radio_buttons_fieldset :child_facing_confirmation_given, + inline: true, + legend: { + text: question, + tag: "h1", + size: "l" + }, hint: -> do %>
<%= @form.t(:hint, first_name: answers.first_name) %>
<% end do %> - <%= f.govuk_check_box :child_facing_confirmation_given, 1, 0, multiple: false, link_errors: true, label: { text: @form.t(:option, first_name: answers.first_name) } %> + <%= f.govuk_radio_button :child_facing_confirmation_given, true, label: { text: "Yes" } %> + <%= f.govuk_radio_button :child_facing_confirmation_given, false, label: { text: "No" } %> <% end %> <%= govuk_details(summary_text: "What does working at least 70% of time directly with children mean?") do %> @@ -23,10 +31,6 @@ <% end %> -

- <%= govuk_link_to "I cannot confirm this information", "" %> -

- <%= f.govuk_submit "Continue" %> <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 57f082f177..8f9e6795ac 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1143,6 +1143,7 @@ en: claim_description: for an early years financial incentive payment journey_name: Claim an early years financial incentive payment - provider feedback_email: "help@opsteam.education.gov.uk" + support_email_address: "help@opsteam.education.gov.uk" forms: consent: question: Declaration of Employee Consent @@ -1184,14 +1185,12 @@ en: date_not_in_future: Start date cannot be in the future year_must_have_4_digits: Year must include 4 numbers child_facing: - question: Confirm %{first_name} spends most of their time in their job working directly with children + question: Does %{first_name} spend most of their time in their job working directly with children? hint: - "%{first_name}’s job must involve spending most of their contracted hours (approximately 70% or more) working - directly with children." - option: - I confirm that at least 70% of %{first_name}’s time in their job is spent working directly with children. + "%{first_name}’s job must involve spending most of their contracted hours (approximately 70% or more) directly working + with children." errors: - presence: You must be able to confirm this information to continue + inclusion: You must select an option below to continue returner: question: Did %{first_name} work in an early years setting between %{six_months_before_start_date} and %{start_date}? @@ -1214,7 +1213,6 @@ en: early_years_payments: <<: *early_years_payment_provider_authenticated claim_subject: "Early Years Payment" - support_email_address: "help@opsteam.education.gov.uk" activerecord: errors: models: diff --git a/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb b/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb index 3cba38300a..edf7bc315e 100644 --- a/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb +++ b/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb @@ -41,7 +41,7 @@ click_button "Continue" expect(page.current_path).to eq "/early-years-payment-provider/child-facing" - check "I confirm that at least 70% of Bobby’s time in their job is spent working directly with children." + choose "Yes" click_button "Continue" expect(page.current_path).to eq "/early-years-payment-provider/returner" diff --git a/spec/features/early_years_payment/provider/authenticated/not_child_facing_spec.rb b/spec/features/early_years_payment/provider/authenticated/not_child_facing_spec.rb new file mode 100644 index 0000000000..ba2a390b66 --- /dev/null +++ b/spec/features/early_years_payment/provider/authenticated/not_child_facing_spec.rb @@ -0,0 +1,44 @@ +require "rails_helper" + +RSpec.feature "Early years payment provider child facing" do + let(:email_address) { "johndoe@example.com" } + let(:journey_session) { Journeys::EarlyYearsPayment::Provider::Authenticated::Session.last } + let(:mail) { ActionMailer::Base.deliveries.last } + let(:magic_link) { mail[:personalisation].unparsed_value[:magic_link] } + let!(:nursery) { create(:eligible_ey_provider, primary_key_contact_email_address: email_address) } + + scenario "selecting No" do + when_early_years_payment_provider_authenticated_journey_configuration_exists + when_early_years_payment_provider_start_journey_completed + + visit magic_link + check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice." + click_button "Continue" + + choose nursery.nursery_name + click_button "Continue" + + fill_in "claim-paye-reference-field", with: "123/123456SE90" + click_button "Continue" + + fill_in "First name", with: "Bobby" + fill_in "Last name", with: "Bobberson" + click_button "Continue" + + date = Date.yesterday + fill_in("Day", with: date.day) + fill_in("Month", with: date.month) + fill_in("Year", with: date.year) + click_button "Continue" + + expect(page.current_path).to eq "/early-years-payment-provider/child-facing" + click_button "Continue" + + expect(page).to have_content "You must select an option below to continue" + choose "No" + click_button "Continue" + + expect(page.current_path).to eq "/early-years-payment-provider/ineligible" + expect(page).to have_content("Bobby is not eligible for this payment") + end +end diff --git a/spec/forms/journeys/early_years_payment/provider/authenticated/child_facing_form_spec.rb b/spec/forms/journeys/early_years_payment/provider/authenticated/child_facing_form_spec.rb index 31a188abe0..496f2ddbf1 100644 --- a/spec/forms/journeys/early_years_payment/provider/authenticated/child_facing_form_spec.rb +++ b/spec/forms/journeys/early_years_payment/provider/authenticated/child_facing_form_spec.rb @@ -22,7 +22,7 @@ is_expected.not_to( allow_value(child_facing_confirmation_given) .for(:child_facing_confirmation_given) - .with_message("You must be able to confirm this information to continue") + .with_message("You must select an option below to continue") ) end end diff --git a/spec/support/steps/eligible_ey_journey_authenticated.rb b/spec/support/steps/eligible_ey_journey_authenticated.rb index 805648d7fa..e0ff028afc 100644 --- a/spec/support/steps/eligible_ey_journey_authenticated.rb +++ b/spec/support/steps/eligible_ey_journey_authenticated.rb @@ -19,7 +19,7 @@ def when_early_years_payment_provider_authenticated_journey_ready_to_submit fill_in("Year", with: date.year) click_button "Continue" - check "I confirm that at least 70% of Bobby’s time in their job is spent working directly with children." + choose "Yes" click_button "Continue" choose "No"