From ac0e8b977b14f2c2740409abec5817fbea31bec0 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Mon, 19 Aug 2024 14:34:08 +0100 Subject: [PATCH 1/3] employee email address --- .../authenticated/employee_email_form.rb | 20 +++++++++++ .../provider/authenticated.rb | 3 +- .../provider/authenticated/session_answers.rb | 1 + .../provider/authenticated/slug_sequence.rb | 8 ++++- .../claims/check_your_answers.html.erb | 0 .../claims/employee_email.html.erb | 12 +++++++ config/locales/en.yml | 5 +++ .../provider/authenticated/happy_path_spec.rb | 5 +++ .../authenticated/employee_email_form_spec.rb | 33 +++++++++++++++++++ 9 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 app/forms/journeys/early_years_payment/provider/authenticated/employee_email_form.rb create mode 100644 app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb create mode 100644 spec/forms/journeys/early_years_payment/provider/authenticated/employee_email_form_spec.rb diff --git a/app/forms/journeys/early_years_payment/provider/authenticated/employee_email_form.rb b/app/forms/journeys/early_years_payment/provider/authenticated/employee_email_form.rb new file mode 100644 index 0000000000..0a07bbdbea --- /dev/null +++ b/app/forms/journeys/early_years_payment/provider/authenticated/employee_email_form.rb @@ -0,0 +1,20 @@ +module Journeys + module EarlyYearsPayment + module Provider + module Authenticated + class EmployeeEmailForm < Form + attribute :practitioner_email_address + + validates :practitioner_email_address, presence: {message: i18n_error_message(:valid)} + + def save + return false if invalid? + + journey_session.answers.assign_attributes(practitioner_email_address:) + journey_session.save! + end + end + end + end + end +end diff --git a/app/models/journeys/early_years_payment/provider/authenticated.rb b/app/models/journeys/early_years_payment/provider/authenticated.rb index 9ec9ccb522..36e8af9cd1 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated.rb @@ -17,7 +17,8 @@ module Authenticated "claimant-name" => ClaimantNameForm, "start-date" => StartDateForm, "child-facing" => ChildFacingForm, - "returner" => ReturnerForm + "returner" => ReturnerForm, + "employee-email" => EmployeeEmailForm } } START_WITH_MAGIC_LINK = true diff --git a/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb b/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb index c1dc694a66..e3e877e138 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb @@ -10,6 +10,7 @@ class SessionAnswers < Journeys::SessionAnswers attribute :child_facing_confirmation_given, :boolean attribute :first_job_within_6_months, :boolean attribute :start_date, :date + attribute :practitioner_email_address def policy Policies::EarlyYearsPayments diff --git a/app/models/journeys/early_years_payment/provider/authenticated/slug_sequence.rb b/app/models/journeys/early_years_payment/provider/authenticated/slug_sequence.rb index f15ca6c721..d094cc7171 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated/slug_sequence.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated/slug_sequence.rb @@ -3,7 +3,7 @@ module EarlyYearsPayment module Provider module Authenticated class SlugSequence - SLUGS = %w[ + ELIGIBILITY_SLUGS = %w[ consent current-nursery paye-reference @@ -12,9 +12,15 @@ class SlugSequence child-facing returner employee-email + ].freeze + + RESULTS_SLUGS = %w[ + check-your-answers ineligible ].freeze + SLUGS = (ELIGIBILITY_SLUGS + RESULTS_SLUGS).freeze + MAGIC_LINK_SLUG = "consent" def self.start_page_url diff --git a/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb b/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb b/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb index e69de29bb2..1978a95cf6 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb @@ -0,0 +1,12 @@ +<% content_for(:page_title, page_title(@form.t(:question, first_name: answers.first_name), 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_text_field :practitioner_email_address, + label: { text: @form.t(:question, first_name: answers.first_name), tag: "h1", size: "l" }, + hint: { text: @form.t(:hint) }, spellcheck: "false" %> + <%= f.govuk_submit %> + <% end %> +
+
diff --git a/config/locales/en.yml b/config/locales/en.yml index 053e269929..bf6960257a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1163,6 +1163,11 @@ en: Did %{first_name} work in an early years setting between %{six_months_before_start_date} and %{start_date}? errors: inclusion: You must select an option below to continue + employee_email: + question: What is %{first_name}’s email address? + hint: We’ll use this to ask your employee to provide their payment details. + errors: + valid: Enter a valid email address early_years_payments: <<: *early_years_payment_provider_authenticated claim_subject: "Early Years Payment" 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 85320aa585..da62683cbf 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 @@ -46,7 +46,12 @@ expect(page.current_path).to eq "/early-years-payment-provider/returner" choose "No" click_button "Continue" + expect(page.current_path).to eq "/early-years-payment-provider/employee-email" + fill_in "claim-practitioner-email-address-field", with: "practitioner@example.com" + click_button "Continue" + + expect(page.current_path).to eq "/early-years-payment-provider/check-your-answers" end scenario "using magic link after having completed some of the journey" do diff --git a/spec/forms/journeys/early_years_payment/provider/authenticated/employee_email_form_spec.rb b/spec/forms/journeys/early_years_payment/provider/authenticated/employee_email_form_spec.rb new file mode 100644 index 0000000000..38609c9054 --- /dev/null +++ b/spec/forms/journeys/early_years_payment/provider/authenticated/employee_email_form_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Journeys::EarlyYearsPayment::Provider::Authenticated::EmployeeEmailForm, type: :model do + let(:journey) { Journeys::EarlyYearsPayment::Provider::Authenticated } + let(:journey_session) { create(:early_years_payment_provider_authenticated_session) } + let(:practitioner_email_address) { nil } + + let(:params) do + ActionController::Parameters.new( + claim: { + practitioner_email_address: + } + ) + end + + subject do + described_class.new(journey_session:, journey:, params:) + end + + describe "validations" do + it { should validate_presence_of(:practitioner_email_address).with_message("Enter a valid email address") } + end + + describe "#save" do + let(:practitioner_email_address) { "practitioner@example.com" } + + it "updates the journey session" do + expect { subject.save }.to( + change { journey_session.answers.practitioner_email_address }.to(practitioner_email_address) + ) + end + end +end From 37ff8c139f2d6dda9b5807b4c1bc70f29cd97dee Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Mon, 19 Aug 2024 15:11:32 +0100 Subject: [PATCH 2/3] mark spec as flaky --- spec/features/admin/admin_timeout_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/admin_timeout_spec.rb b/spec/features/admin/admin_timeout_spec.rb index ac4ec41c82..bc021147ba 100644 --- a/spec/features/admin/admin_timeout_spec.rb +++ b/spec/features/admin/admin_timeout_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.feature "Admin user session timeout", js: true do +RSpec.feature "Admin user session timeout", js: true, flaky: true do let(:one_second_in_minutes) { 1 / 60.to_f } let(:two_seconds_in_minutes) { 2 / 60.to_f } From d3e8471963b81a0c7674eb4bc0b00015e7ab6160 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Tue, 20 Aug 2024 12:03:09 +0100 Subject: [PATCH 3/3] use CLAIM_SLUGS for slugs that are not RESULTS_SLUGS --- .../provider/authenticated/slug_sequence.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/journeys/early_years_payment/provider/authenticated/slug_sequence.rb b/app/models/journeys/early_years_payment/provider/authenticated/slug_sequence.rb index d094cc7171..25cb3c5f28 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated/slug_sequence.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated/slug_sequence.rb @@ -3,7 +3,7 @@ module EarlyYearsPayment module Provider module Authenticated class SlugSequence - ELIGIBILITY_SLUGS = %w[ + CLAIM_SLUGS = %w[ consent current-nursery paye-reference @@ -19,7 +19,7 @@ class SlugSequence ineligible ].freeze - SLUGS = (ELIGIBILITY_SLUGS + RESULTS_SLUGS).freeze + SLUGS = (CLAIM_SLUGS + RESULTS_SLUGS).freeze MAGIC_LINK_SLUG = "consent"