From 04d17bb4703ad65575cdbe4080eb228b588397df Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Fri, 8 Nov 2024 14:19:55 +0000 Subject: [PATCH 1/3] Add Policy#task_available? Some policies will have conditions around when a task is available. This commit adds a new method to the base policy `task_available?` which can be overwritten by sub policies. We also update the tasks views to show a policy specific message when the task is not available. --- app/models/base_policy.rb | 4 ++++ app/views/admin/tasks/employment.html.erb | 13 ++++++++----- app/views/admin/tasks/matching_details.html.erb | 12 ++++++++++-- app/views/admin/tasks/payroll_details.html.erb | 8 +++++++- app/views/admin/tasks/payroll_gender.html.erb | 8 +++++++- app/views/admin/tasks/student_loan_plan.html.erb | 8 +++++++- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/app/models/base_policy.rb b/app/models/base_policy.rb index 3adc9e1e01..382b6dbedb 100644 --- a/app/models/base_policy.rb +++ b/app/models/base_policy.rb @@ -74,4 +74,8 @@ def award_amount_column def mailer ClaimMailer end + + def task_available?(task) + true + end end diff --git a/app/views/admin/tasks/employment.html.erb b/app/views/admin/tasks/employment.html.erb index 11a1926c01..18509039cd 100644 --- a/app/views/admin/tasks/employment.html.erb +++ b/app/views/admin/tasks/employment.html.erb @@ -19,12 +19,15 @@
<% if @task.persisted? %> <%= render "task_outcome", task: @task, notes: @notes %> + <% elsif @claim.policy.task_available?(@task) %> + <%= render "form", task_name: "employment", claim: @claim %> <% else %> - <% if @task.employment_task_available? %> - <%= render "form", task_name: "employment", claim: @claim %> - <% else %> - <%= govuk_inset_text(text: "This task will be available from #{l(@claim.eligibility.employment_task_available_at)}") %> - <% end %> + <%= govuk_inset_text( + text: I18n.t( + "#{@claim.policy.to_s.underscore}.admin.task_questions.#{@task.name}.unavailable", + employment_task_available_at: l(@claim.eligibility.employment_task_available_at) + ) + ) %> <% end %> <%= render partial: "admin/task_pagination", locals: { task_pagination: @task_pagination } %> diff --git a/app/views/admin/tasks/matching_details.html.erb b/app/views/admin/tasks/matching_details.html.erb index eb0d1f1c5f..d30d1da418 100644 --- a/app/views/admin/tasks/matching_details.html.erb +++ b/app/views/admin/tasks/matching_details.html.erb @@ -13,14 +13,22 @@

<%= @current_task_name.humanize %>

- <%= render("admin/claims/claims_with_matching_details", {matching_claims: @matching_claims, claim: @claim, show_caption: false}) %> + <% if @claim.policy.task_available?(@task) %> + <%= render("admin/claims/claims_with_matching_details", {matching_claims: @matching_claims, claim: @claim, show_caption: false}) %> + <% end %>
<% if @task.persisted? %> <%= render "task_outcome", task: @task %> - <% else %> + <% elsif @claim.policy.task_available?(@task) %> <%= render "form", task_name: "matching_details", claim: @claim %> + <% else %> + <%= govuk_inset_text( + text: I18n.t( + "#{@claim.policy.to_s.underscore}.admin.task_questions.#{@task.name}.unavailable", + ) + ) %> <% end %> <%= render partial: "admin/task_pagination", locals: { task_pagination: @task_pagination } %> diff --git a/app/views/admin/tasks/payroll_details.html.erb b/app/views/admin/tasks/payroll_details.html.erb index 4d118e19c6..f961026c1f 100644 --- a/app/views/admin/tasks/payroll_details.html.erb +++ b/app/views/admin/tasks/payroll_details.html.erb @@ -46,7 +46,7 @@ <% if !@task.passed.nil? %> <%= render "task_outcome", task: @task, notes: @notes do %> <% end %> - <% else %> + <% elsif @claim.policy.task_available?(@task) %> <%= form_with model: [:admin, @claim, @claim.tasks.where(name: "payroll_details").first_or_initialize] do |f| %>
@@ -75,6 +75,12 @@ <%= f.submit "Save and continue", class: "govuk-button", data: {module: "govuk-button"} %>
<% end %> + <% else %> + <%= govuk_inset_text( + text: I18n.t( + "#{@claim.policy.to_s.underscore}.admin.task_questions.#{@task.name}.unavailable", + ) + ) %> <% end %> <%= render partial: "admin/task_pagination", locals: { task_pagination: @task_pagination } %> diff --git a/app/views/admin/tasks/payroll_gender.html.erb b/app/views/admin/tasks/payroll_gender.html.erb index 3deaa21b32..eb20bf8903 100644 --- a/app/views/admin/tasks/payroll_gender.html.erb +++ b/app/views/admin/tasks/payroll_gender.html.erb @@ -14,7 +14,7 @@ <% if @task.persisted? %> <%= render "task_outcome", task: @task %> - <% else %> + <% elsif @claim.policy.task_available?(@task) %>
<%= form_with url: admin_claim_payroll_gender_tasks_path(@claim), scope: :claim do |f| %>
@@ -46,6 +46,12 @@ <%= f.submit "Save and continue", class: "govuk-button", data: {module: "govuk-button"} %> <% end %>
+ <% else %> + <%= govuk_inset_text( + text: I18n.t( + "#{@claim.policy.to_s.underscore}.admin.task_questions.#{@task.name}.unavailable", + ) + ) %> <% end %> <%= render partial: "admin/task_pagination", locals: { task_pagination: @task_pagination } %> diff --git a/app/views/admin/tasks/student_loan_plan.html.erb b/app/views/admin/tasks/student_loan_plan.html.erb index be68caf4c4..9ead9a7b2b 100644 --- a/app/views/admin/tasks/student_loan_plan.html.erb +++ b/app/views/admin/tasks/student_loan_plan.html.erb @@ -17,7 +17,7 @@
<% if @task.persisted? %> <%= render "task_outcome", task: @task %> - <% else %> + <% elsif @claim.policy.task_available?(@task) %> <%= render "admin/tasks/notes", notes: @notes, display_description: false %>

@@ -27,6 +27,12 @@ No matching entry has been found in the Student Loan Company data yet.

+ <% else %> + <%= govuk_inset_text( + text: I18n.t( + "#{@claim.policy.to_s.underscore}.admin.task_questions.#{@task.name}.unavailable", + ) + ) %> <% end %> <%= render partial: "admin/task_pagination", locals: { task_pagination: @task_pagination } %> From d0df6e945f553a68881ed4d9d6fd41048e30c2ea Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Fri, 8 Nov 2024 14:21:29 +0000 Subject: [PATCH 2/3] Add remaining EY tasks Adds the remaining EY tasks along with copy for the tasks being unavilable. --- app/models/policies/early_years_payments.rb | 9 + .../claim_checking_tasks.rb | 4 +- config/locales/en.yml | 17 +- spec/features/admin/admin_ey_tasks_spec.rb | 669 ++++++++++++++++++ ...dmin_view_claim_feature_shared_examples.rb | 2 +- 5 files changed, 697 insertions(+), 4 deletions(-) create mode 100644 spec/features/admin/admin_ey_tasks_spec.rb diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index ae60443fe3..eee3035374 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -85,5 +85,14 @@ def decision_deadline_date(claim) def mailer EarlyYearsPaymentsMailer end + + def task_available?(task) + case task.name + when "employment" + task.claim.eligibility.employment_task_available? + else + task.claim.eligibility.practitioner_journey_completed? + end + end end end diff --git a/app/models/policies/early_years_payments/claim_checking_tasks.rb b/app/models/policies/early_years_payments/claim_checking_tasks.rb index 09b14daf1f..343d457b2d 100644 --- a/app/models/policies/early_years_payments/claim_checking_tasks.rb +++ b/app/models/policies/early_years_payments/claim_checking_tasks.rb @@ -15,8 +15,10 @@ def applicable_task_names tasks = [] tasks << "identity_confirmation" - tasks << "student_loan_plan" if claim.submitted_without_slc_data? tasks << "employment" + tasks << "student_loan_plan" if claim.submitted_without_slc_data? + tasks << "payroll_details" if claim.must_manually_validate_bank_details? + tasks << "payroll_gender" if claim.payroll_gender_missing? || claim.tasks.exists?(name: "payroll_gender") tasks << "matching_details" if matching_claims.exists? tasks diff --git a/config/locales/en.yml b/config/locales/en.yml index d6162c10b1..15d869f661 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1467,12 +1467,25 @@ en: no_response: No response other: Other task_questions: - matching_details: - title: Is this claim still valid despite having matching details with other claims? employment: title: Is the claimant still working at the current nursery above? + unavailable: This task will be available from %{employment_task_available_at} identity_confirmation: title: "Do these names match?" + student_loan_amount: + title: Does the claimant’s student loan amount and plan type match the information we hold about their loan? + unavailable: This task is not available until the claimant has submitted their claim + student_loan_plan: + unavailable: This task is not available until the claimant has submitted their claim + payroll_details: + title: "Check bank account details" + question: "The claimant’s personal bank account details have not been automatically validated. Has the claimant confirmed their personal bank account details?" + unavailable: This task is not available until the claimant has submitted their claim + payroll_gender: + unavailable: This task is not available until the claimant has submitted their claim + matching_details: + title: Is this claim still valid despite having matching details with other claims? + unavailable: This task is not available until the claimant has submitted their claim early_years_payment_practitioner: journey_name: Claim an early years financial incentive payment feedback_email: "EY.Financial-Incentives@education.gov.uk" diff --git a/spec/features/admin/admin_ey_tasks_spec.rb b/spec/features/admin/admin_ey_tasks_spec.rb new file mode 100644 index 0000000000..b0cae30dd2 --- /dev/null +++ b/spec/features/admin/admin_ey_tasks_spec.rb @@ -0,0 +1,669 @@ +require "rails_helper" + +RSpec.describe "Admin EY tasks" do + around do |example| + travel_to DateTime.new(2024, 10, 30, 9, 0, 0) do + example.run + end + end + + describe "identity_confirmation" do + context "when the practitioner hasn't completed their half of the claim" do + it "shows that the task is unavailable" do + claim = complete_provider_journey + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Identity confirmation")).to eq("Incomplete") + + click_on "Confirm the claimant made the claim" + + expect(page).to have_content( + "Provider entered claimant name Bobby Bobberson" + ) + + expect(page).to have_content( + "This task is not available until the claimant has submitted their claim" + ) + end + end + + context "when the practitioner has completed their half of the claim" do + context "when OL IDV is a pass and the names match" do + it "passes the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + date_of_birth: Date.new(1986, 1, 1), + one_login_first_name: "Bobby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1) + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Identity confirmation")).to eq("Passed") + + click_on "Confirm the claimant made the claim" + + expect(page).to have_content( + "Provider entered claimant name Bobby Bobberson" + ) + + expect(page).to have_content( + "Claimant name from One login Bobby Bobberson" + ) + + expect(page).to have_content( + "This task was performed by GOV.UK One Login on " \ + "30 October 2024 9:00am" + ) + end + end + + context "when OL IDV is a pass and the names don't match" do + context "when the names are a parital match" do + let(:claim) { complete_provider_journey } + + before do + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1) + ) + + sign_in_as_service_operator + end + + it "shows the task as a partial match" do + visit admin_claim_tasks_path(claim) + + expect(task_status("Identity confirmation")).to eq("Partial match") + + click_on "Confirm the claimant made the claim" + + expect(page).to have_content( + "Provider entered claimant name Bobby Bobberson" + ) + + expect(page).to have_content( + "Claimant name from One login Robby Bobberson" + ) + + expect(page).to have_content( + "[GOV UK One Login Name] - Names partially match" + ) + + expect(page).to have_content('Provider: "Bobby Bobberson"') + + expect(page).to have_content('GOV.UK One Login: "Robby Bobberson"') + end + + it "allows the admin to mark the task as passed" do + visit admin_claim_task_path(claim, name: "identity_confirmation") + + choose "Yes" + + click_on "Save and continue" + + visit admin_claim_task_path(claim, name: "identity_confirmation") + + expect(page).to have_content( + "This task was performed by Aaron Admin" + ) + + visit admin_claim_tasks_path(claim) + + expect(task_status("Identity confirmation")).to eq("Passed") + end + + it "allows the admin to mark the task as failed" do + visit admin_claim_task_path(claim, name: "identity_confirmation") + + choose "No" + + click_on "Save and continue" + + visit admin_claim_task_path(claim, name: "identity_confirmation") + + expect(page).to have_content( + "This task was performed by Aaron Admin" + ) + + visit admin_claim_tasks_path(claim) + + expect(task_status("Identity confirmation")).to eq("Failed") + end + end + + context "when the names don't match" do + let(:claim) { complete_provider_journey } + + before do + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Robberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1) + ) + + sign_in_as_service_operator + end + + it "shows the task as failed" do + visit admin_claim_tasks_path(claim) + + expect(task_status("Identity confirmation")).to eq("Failed") + + click_on "Confirm the claimant made the claim" + + expect(page).to have_content( + "Provider entered claimant name Bobby Bobberson" + ) + + expect(page).to have_content( + "Claimant name from One login Robby Robberson" + ) + + expect(page).to have_content( + "[GOV UK One Login Name] - Names do not match" + ) + + expect(page).to have_content('Provider: "Bobby Bobberson"') + + expect(page).to have_content('GOV.UK One Login: "Robby Robberson"') + end + + it "doesn't allow the admin to complete the task" do + visit admin_claim_task_path(claim, name: "identity_confirmation") + + expect(page).not_to have_button("Save and continue") + end + end + end + + context "when OL IDV is a fail" do + it "fails the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Bobby", + one_login_last_name: "Bobberson", + date_of_birth: Date.new(1986, 1, 11), + one_login_date_of_birth: Date.new(1986, 1, 1) + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Identity confirmation")).to eq("Failed") + + click_on "Confirm the claimant made the claim" + + expect(page).to have_content( + "[GOV UK One Login] - IDV mismatch:" + ) + + expect(page).to have_content('GOV.UK One Login Name: "Bobby Bobberson"') + + expect(page).to have_content('GOV.UK One Login DOB: "1986-01-01"') + + expect(page).not_to have_button("Save and continue") + end + end + end + end + + describe "employment_check" do + context "when the practitioner hasn't completed their half of the claim" do + it "shows that the task is unavailable" do + claim = complete_provider_journey + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Employment")).to eq("Incomplete") + + click_on "Check employment information" + + expect(page).to have_content( + "This task will be available from 29 April 2025" + ) + end + end + + context "when the practitioner has completed their half of the claim" do + context "when the employment task is available" do + it "allows the admin to pass / fail the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1) + ) + + claim.eligibility.update!( + start_date: Policies::EarlyYearsPayments::RETENTION_PERIOD.ago + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Employment")).to eq("Incomplete") + + click_on "Check employment information" + + choose "Yes" + + click_on "Save and continue" + + visit admin_claim_tasks_path(claim) + + expect(task_status("Employment")).to eq("Passed") + end + end + end + end + + describe "student_loan_plan" do + context "when the practitioner hasn't completed their half of the claim" do + it "shows that the task is unavailable" do + claim = complete_provider_journey + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Student loan plan")).to eq("Incomplete") + + click_on "Check student loan plan" + + expect(page).to have_content( + "This task is not available until the claimant has submitted their claim" + ) + end + end + + context "when the practitioner has completed their half of the claim" do + it "allows the admin to pass / fail the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1) + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Student loan plan")).to eq("Incomplete") + + click_on "Check student loan plan" + + expect(page).to have_content( + "No matching entry has been found in the Student Loan Company data yet." + ) + end + end + end + + describe "payroll_details" do + context "when the practitioner hasn't completed their half of the claim" do + it "shows that the task is unavailable" do + claim = complete_provider_journey + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Payroll details")).to eq("Incomplete") + + click_on "Check bank account details" + + expect(page).to have_content( + "This task is not available until the claimant has submitted their claim" + ) + end + end + + context "when the practitioner has completed their half of the claim" do + it "allows the admin to pass / fail the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1) + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Payroll details")).to eq("Incomplete") + + click_on "Check bank account details" + + choose "Yes" + + click_on "Save and continue" + + visit admin_claim_tasks_path(claim) + + expect(task_status("Payroll details")).to eq("Passed") + end + end + end + + describe "payroll_gender" do + context "when the practitioner hasn't completed their half of the claim" do + it "shows that the task is unavailable" do + claim = complete_provider_journey + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Payroll gender")).to eq("Incomplete") + + click_on "How is the claimant’s gender recorded for payroll purposes?" + + expect(page).to have_content( + "This task is not available until the claimant has submitted their claim" + ) + end + end + + context "when the practitioner has completed their half of the claim" do + context "when payroll gender is missing" do + it "allows the admin to pass / fail the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1), + payroll_gender: "I don’t know" + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Payroll gender")).to eq("Incomplete") + + click_on "How is the claimant’s gender recorded for payroll purposes?" + + choose "Male" + + click_on "Save and continue" + + visit admin_claim_tasks_path(claim) + + expect(task_status("Payroll gender")).to eq("Passed") + end + end + + context "when payroll gender is present" do + it "doesn't show the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1), + payroll_gender: "Male" + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(page).not_to have_content("Payroll gender") + end + end + end + end + + describe "matching_details" do + context "when the practitioner has completed their half of the claim" do + context "when the claim has matching details" do + it "allows the admin to pass / fail the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1) + ) + + create( + :claim, + :submitted, + :current_academic_year, + email_address: claim.reload.email_address + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(task_status("Matching details")).to eq("Incomplete") + + click_on "Review matching details from other claims" + + choose "Yes" + + click_on "Save and continue" + + visit admin_claim_tasks_path(claim) + + expect(task_status("Matching details")).to eq("Passed") + end + end + + context "when the claim doesn't have matching details" do + it "doesn't show the task" do + claim = complete_provider_journey + + complete_practitioner_journey( + claim: claim, + one_login_first_name: "Robby", + one_login_last_name: "Bobberson", + one_login_date_of_birth: Date.new(1986, 1, 1), + date_of_birth: Date.new(1986, 1, 1) + ) + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + + expect(page).not_to have_content("Matching details") + end + end + end + end + + def complete_provider_journey + create(:journey_configuration, :early_years_payment_provider_start) + + create(:journey_configuration, :early_years_payment_provider_authenticated) + + nursery = create( + :eligible_ey_provider, + primary_key_contact_email_address: "johndoe@example.com", + secondary_contact_email_address: "janedoe@example.com" + ) + + visit landing_page_path( + Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME + ) + + click_link "Start now" + + fill_in "Email address", with: "johndoe@example.com" + click_on "Submit" + + mail = ActionMailer::Base.deliveries.last + magic_link = mail[:personalisation].unparsed_value[:magic_link] + + 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" + + # /early-years-payment-provider/child-facing + choose "Yes" + click_button "Continue" + + # /early-years-payment-provider/returner + choose "Yes" + click_button "Continue" + + # /early-years-payment-provider/returner-worked-with-children + choose "Yes" + click_button "Continue" + + # /early-years-payment-provider/returner-contract-type + choose "casual or temporary" + click_button "Continue" + + # /early-years-payment-provider/employee-email + fill_in( + "claim-practitioner-email-address-field", + with: "practitioner@example.com" + ) + + click_button "Continue" + + # /early-years-payment-provider/check-your-answers + fill_in "claim-provider-contact-name-field", with: "John Doe" + perform_enqueued_jobs { click_button "Accept and send" } + + Claim.last + end + + def complete_practitioner_journey( + claim:, + date_of_birth:, + one_login_first_name:, + one_login_last_name:, + one_login_date_of_birth:, + payroll_gender: "Male" + ) + stub_const( + "OmniauthCallbacksController::ONE_LOGIN_TEST_USER", + { + first_name: one_login_first_name, + last_name: one_login_last_name, + date_of_birth: one_login_date_of_birth + } + ) + + create(:journey_configuration, :early_years_payment_practitioner) + + visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=practitioner@example.com" + + fill_in "Claim reference number", with: claim.reference + + click_button "Submit" + + sign_in_with_one_login + + click_on "Continue" + + expect(page).to have_content("Personal details") + fill_in "Day", with: date_of_birth.day + fill_in "Month", with: date_of_birth.month + fill_in "Year", with: date_of_birth.year + fill_in "National Insurance number", with: "PX321499A" + click_on "Continue" + + expect(page).to have_content("What is your address?") + fill_in "House number or name", with: "57" + fill_in "Building and street", with: "Walthamstow Drive" + fill_in "Town or city", with: "Derby" + fill_in "County", with: "City of Derby" + fill_in "Postcode", with: "DE22 4BS" + click_on "Continue" + + expect(page).to have_content("Your email address") + fill_in "claim-email-address-field", with: "johndoe@example.com" + click_on "Continue" + + expect(page).to have_content("Enter the 6-digit passcode") + mail = ActionMailer::Base.deliveries.last + otp_in_mail_sent = mail[:personalisation].unparsed_value[:one_time_password] + fill_in "claim-one-time-password-field", with: otp_in_mail_sent + click_on "Confirm" + + expect(page).to have_content("Would you like to provide your mobile number?") + choose "No" + click_on "Continue" + + fill_in "Name on your account", with: "#{claim.first_name} #{claim.surname}" + fill_in "Sort code", with: "123456" + fill_in "Account number", with: "87654321" + click_on "Continue" + + expect(page).to have_text(I18n.t("forms.gender.questions.payroll_gender")) + choose payroll_gender + click_on "Continue" + + expect(page).to have_content("Check your answers before submitting this claim") + + perform_enqueued_jobs { click_on "Accept and send" } + end + + def task_status(task_name) + find("h2.app-task-list__section", text: task_name) + .find(:xpath, 'following-sibling::ul//strong[contains(@class, "govuk-tag")]') + .text + end +end diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb index e4fa1c403a..87d2f2193a 100644 --- a/spec/support/admin_view_claim_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_feature_shared_examples.rb @@ -163,7 +163,7 @@ def expect_page_to_have_policy_sections(policy) when Policies::FurtherEducationPayments ["Identity confirmation", "Provider verification", "Student loan plan", "Decision"] when Policies::EarlyYearsPayments - ["Identity confirmation", "Student loan plan", "Employment", "Decision"] + ["Identity confirmation", "Employment", "Student loan plan", "Decision"] else raise "Unimplemented policy: #{policy}" end From 9210943738d71aca3d64e05753c27b61e13d2aca Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Fri, 8 Nov 2024 14:24:42 +0000 Subject: [PATCH 3/3] Remove Task#employment_task_available? We no longer need this method as we now check the policy rather than the task when rendering the admin view. --- app/models/task.rb | 6 ------ spec/models/task_spec.rb | 33 --------------------------------- 2 files changed, 39 deletions(-) diff --git a/app/models/task.rb b/app/models/task.rb index 77023f8492..eac6d3c426 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -54,10 +54,4 @@ def to_param def identity_confirmation? name == "identity_confirmation" end - - def employment_task_available? - return true unless claim.has_early_years_payments_policy? - - claim.eligibility.employment_task_available? - end end diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb index 6a6902b4ca..764c02ea05 100644 --- a/spec/models/task_spec.rb +++ b/spec/models/task_spec.rb @@ -54,37 +54,4 @@ end end end - - describe "#employment_task_available?" do - subject { task.employment_task_available? } - - let(:task) { build(:task, claim: claim) } - let(:claim) { create(:claim, :submitted, policy:) } - - context "for claims with EarlyYearsPayments policy" do - let(:policy) { Policies::EarlyYearsPayments } - - context "when the task is available" do - let(:claim) { create(:claim, :submitted, policy:, eligibility_attributes: {start_date: 1.year.ago}) } - - it { is_expected.to be true } - end - - context "when the task is not yet available" do - let(:claim) { create(:claim, :submitted, policy:, eligibility_attributes: {start_date: 1.day.ago}) } - - it { is_expected.to be false } - end - end - - context "for claims with other policies" do - (Policies.all - [Policies::EarlyYearsPayments]).each do |policy| - context policy do - let(:policy) { policy } - - it { is_expected.to be true } - end - end - end - end end