diff --git a/app/flows/uk_benefits_abroad_flow.rb b/app/flows/uk_benefits_abroad_flow.rb index e0d2d5990a0..9efe1fd0bc5 100644 --- a/app/flows/uk_benefits_abroad_flow.rb +++ b/app/flows/uk_benefits_abroad_flow.rb @@ -104,16 +104,17 @@ def define else question :employer_paying_ni? # Q10, Q11, Q16 going_abroad and Q9, Q10, Q15 already_abroad end + when "winter_fuel_payment" - if calculator.country_eligible_for_winter_fuel_payment? - if calculator.country == "ireland" - question :is_british_or_irish? - else - question :worked_in_eea_or_switzerland? # A7 already_abroad - end + # The following are all the same for going_abroad and already abroad + if calculator.country == "ireland" + question :is_british_or_irish? + elsif calculator.country_eligible_for_winter_fuel_payment? + question :worked_in_eea_or_switzerland? else - outcome :wfp_not_eligible_outcome # A8 going_abroad and A6 already_abroad + outcome :wfp_not_eligible_outcome end + when "child_benefit" if calculator.eea_country? question :do_either_of_the_following_apply? # Q13 going_abroad and Q12 already_abroad @@ -579,7 +580,7 @@ def define when "jsa" outcome :jsa_eea_going_abroad_maybe_outcome when "winter_fuel_payment" - outcome :wfp_going_abroad_eea_maybe_outcome + question :born_before_23_September_1958? when "esa" outcome(calculator.going_abroad ? :esa_going_abroad_eea_outcome : :esa_already_abroad_eea_outcome) when "disability_benefits" @@ -603,7 +604,7 @@ def define when "jsa" outcome :jsa_eea_going_abroad_maybe_outcome when "winter_fuel_payment" - outcome :wfp_going_abroad_eea_maybe_outcome + question :born_before_23_September_1958? when "esa" outcome(calculator.going_abroad ? :esa_going_abroad_eea_outcome : :esa_already_abroad_eea_outcome) when "disability_benefits" @@ -624,6 +625,48 @@ def define end end + radio :born_before_23_September_1958? do + option :yes + option :no + + next_node do |response| + case response + when "yes" + question :you_or_partner_get_a_benefit_in_the_country? + when "no" + outcome :wfp_not_eligible_outcome + end + end + end + + radio :you_or_partner_get_a_benefit_in_the_country? do + option :yes + option :no + + next_node do |response| + case response + when "yes" + outcome :wfp_not_eligible_outcome + when "no" + question :you_or_partner_get_a_means_tested_benefit_in_the_country? + end + end + end + + radio :you_or_partner_get_a_means_tested_benefit_in_the_country? do + option :yes + option :no + + next_node do |response| + case response + when "yes" + outcome :wfp_maybe_outcome + when "no" + outcome :wfp_not_eligible_outcome + end + end + end + radio :is_british_or_irish? do option :yes option :no @@ -635,14 +678,18 @@ def define when "jsa" outcome :jsa_ireland_outcome when "winter_fuel_payment" - outcome :wfp_ireland_outcome + question :born_before_23_September_1958? when "esa" outcome(calculator.going_abroad ? :esa_going_abroad_eea_outcome : :esa_already_abroad_eea_outcome) when "disability_benefits" outcome :db_going_abroad_ireland_outcome end when "no" - question :worked_in_eea_or_switzerland? + if calculator.benefit == "winter_fuel_payment" && calculator.going_abroad + outcome :wfp_not_eligible_outcome + else + question :worked_in_eea_or_switzerland? + end end end end @@ -650,7 +697,6 @@ def define outcome :pension_going_abroad_outcome # A2 going_abroad outcome :jsa_social_security_going_abroad_outcome # A6 going_abroad outcome :jsa_not_entitled_outcome # A7 going_abroad and A5 already_abroad - outcome :wfp_not_eligible_outcome # A8 going_abroad and A6 already_abroad outcome :maternity_benefits_maternity_allowance_outcome # A10 going_abroad and A8 already_abroad outcome :maternity_benefits_social_security_going_abroad_outcome # A12 going_abroad outcome :maternity_benefits_not_entitled_outcome # A13 going_abroad and A11 already_abroad @@ -714,8 +760,9 @@ def define outcome :jsa_eea_going_abroad_maybe_outcome outcome :jsa_ireland_outcome - outcome :wfp_going_abroad_eea_maybe_outcome outcome :wfp_ireland_outcome + outcome :wfp_maybe_outcome + outcome :wfp_not_eligible_outcome outcome :db_going_abroad_ireland_outcome end diff --git a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_going_abroad_eea_maybe_outcome.erb b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_going_abroad_eea_maybe_outcome.erb deleted file mode 100644 index dd537f30119..00000000000 --- a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_going_abroad_eea_maybe_outcome.erb +++ /dev/null @@ -1,5 +0,0 @@ -<% govspeak_for :body do %> -Eligibility for Winter Fuel Payment has changed for winter 2024. - -[Read the Winter Fuel Payment if you live abroad guidance](https://www.gov.uk/winter-fuel-payment/if-you-live-abroad) for more information. -<% end %> diff --git a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_maybe_outcome.erb b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_maybe_outcome.erb new file mode 100644 index 00000000000..656ff0de847 --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_maybe_outcome.erb @@ -0,0 +1,4 @@ +<% govspeak_for :body do %> + You might be eligible for Winter Fuel Payment. + Find out [how to apply for Winter Fuel Payment if you live abroad](https://www.gov.uk/winter-fuel-payment/if-you-live-abroad). +<% end %> diff --git a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_not_eligible_outcome.erb b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_not_eligible_outcome.erb index e9d5ee2122d..d5d43367f16 100644 --- a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_not_eligible_outcome.erb +++ b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_not_eligible_outcome.erb @@ -1,3 +1,3 @@ <% govspeak_for :body do %> - You cannot get a [Winter Fuel Payment](/winter-fuel-payment). + You cannot get a [Winter Fuel Payment](/winter-fuel-payment) abroad. <% end %> diff --git a/app/flows/uk_benefits_abroad_flow/questions/born_before_23_September_1958.erb b/app/flows/uk_benefits_abroad_flow/questions/born_before_23_September_1958.erb new file mode 100644 index 00000000000..98937ec1542 --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/questions/born_before_23_September_1958.erb @@ -0,0 +1,8 @@ +<% text_for :title do %> + Were you born before 23 September 1958? +<% end %> + +<% options( + "yes": "Yes", + "no": "No" +) %> diff --git a/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_benefit_in_the_country.erb b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_benefit_in_the_country.erb new file mode 100644 index 00000000000..304df74a5fb --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_benefit_in_the_country.erb @@ -0,0 +1,8 @@ +<% text_for :title do %> + Do you or your partner get a pension or a benefit based on your work contributions in the country you are living in? +<% end %> + +<% options( + "yes": "Yes", + "no": "No" +) %> diff --git a/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_means_tested_benefit_in_the_country.erb b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_means_tested_benefit_in_the_country.erb new file mode 100644 index 00000000000..1cd7215e145 --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_means_tested_benefit_in_the_country.erb @@ -0,0 +1,21 @@ +<% text_for :title do %> + Did you or your partner get a means-tested benefit in the country you are living in between 16 and 22 September 2024? +<% end %> + +<% govspeak_for :body do %> + You must have been getting a benefit from the country you live in that’s equivalent to: + + - Pension Credit + - Universal Credit + - Income-related Employment and Support Allowance (ESA) + - Income-based Jobseeker’s Allowance (JSA) + - Income Support + - Working Tax Credit + - Child Tax Credit + +<% end %> + +<% options( + "yes": "Yes", + "no": "No" +) %> diff --git a/test/flows/uk_benefits_abroad_flow_test.rb b/test/flows/uk_benefits_abroad_flow_test.rb index 1b590e59b0d..f992ca604a5 100644 --- a/test/flows/uk_benefits_abroad_flow_test.rb +++ b/test/flows/uk_benefits_abroad_flow_test.rb @@ -1,6 +1,7 @@ require "test_helper" require "support/flow_test_helper" +# noinspection RubyResolve class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase include FlowTestHelper @@ -40,8 +41,10 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end context "next_node" do - should "have a next node of which_benefit? for any response" do - assert_next_node :which_benefit?, for_response: "going_abroad" + %w[going_abroad already_abroad].each do |response| + should "have a next node of which_benefit? for a '#{response}' response" do + assert_next_node :which_benefit?, for_response: response + end end end end @@ -58,7 +61,7 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase context "next_node" do %w[winter_fuel_payment maternity_benefits child_benefit ssp bereavement_benefits jsa].each do |benefit| - should "have a next node of which_country? for a '#{benefit}' response" do + should "have a next node of which_country? for a '#{benefit}' response if going_abroad" do assert_next_node :which_country?, for_response: benefit end end @@ -925,13 +928,18 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end context "next_node" do - should "have a next node of jsa_eea_going_abroad_maybe_outcome for a 'before_jan_2021' response if benefit is jsa" do - assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" - end + context "winter_fuel_payment" do + should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment" do + add_responses which_benefit?: "winter_fuel_payment" + assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" + end - should "have a next node of wfp_going_abroad_eea_maybe_outcome for a 'before_jan_2021' response if benefit is winter_fuel_payment" do - add_responses which_benefit?: "winter_fuel_payment" - assert_next_node :wfp_going_abroad_eea_maybe_outcome, for_response: "before_jan_2021" + %w[no after_jan_2021].each do |response| + should "have a next node of parents_lived_in_eea_or_switzerland? for a #{response} response if benefit is winter_fuel_payment" do + add_responses which_benefit?: "winter_fuel_payment" + assert_next_node :parents_lived_in_eea_or_switzerland?, for_response: response + end + end end should "have a next node of esa_going_abroad_eea_outcome for a 'before_jan_2021' response if benefit is esa and going_abroad" do @@ -960,11 +968,16 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :db_already_abroad_eea_outcome, for_response: "before_jan_2021" end - should "have a next node of parents_lived_in_eea_or_switzerland? for a 'after_jan_2021' response" do + # TODO: Do we need to cycle through the different benefits for the following tests? + should "have a next node of jsa_eea_going_abroad_maybe_outcome for a 'before_jan_2021' response if benefit is jsa" do + assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" + end + + should "have a next node of parents_lived_in_eea_or_switzerland? for a 'after_jan_2021' response if benefit is jsa" do assert_next_node :parents_lived_in_eea_or_switzerland?, for_response: "after_jan_2021" end - should "have a next node of parents_lived_in_eea_or_switzerland? for a 'no' response" do + should "have a next node of parents_lived_in_eea_or_switzerland? for a 'no' response if benefit is jsa" do assert_next_node :parents_lived_in_eea_or_switzerland?, for_response: "no" end end @@ -988,11 +1001,6 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" end - should "have a next node of wfp_going_abroad_eea_maybe_outcome for a 'before_jan_2021' response if benefit is winter_fuel_payment" do - add_responses which_benefit?: "winter_fuel_payment" - assert_next_node :wfp_going_abroad_eea_maybe_outcome, for_response: "before_jan_2021" - end - should "have a next node of esa_going_abroad_eea_outcome for a 'before_jan_2021' response if benefit is esa and going_abroad" do add_responses which_benefit?: "esa", esa_how_long_abroad?: "esa_more_than_a_year" @@ -1019,6 +1027,13 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :db_already_abroad_eea_outcome, for_response: "before_jan_2021" end + context "winter_fuel_payment" do + should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment" do + add_responses which_benefit?: "winter_fuel_payment" + assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" + end + end + %w[after_jan_2021 no].each do |response| should "have a next node of jsa_not_entitled_outcome for a '#{response}' response if benefit is jsa" do assert_next_node :jsa_not_entitled_outcome, for_response: response @@ -1071,22 +1086,39 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end context "next_node" do - should "have a next node of jsa_ireland_outcome for a 'yes' response if benefit is jsa" do - assert_next_node :jsa_ireland_outcome, for_response: "yes" + context "winter_fuel_payment" do + setup do + add_responses which_benefit?: "winter_fuel_payment" + end + + %w[going_abroad already_abroad].each do |location| + should "have a next node of born_before_23_September_1958? for a 'yes' response if benefit is winter_fuel_payment and #{location}" do + add_responses going_or_already_abroad?: location + assert_next_node :born_before_23_September_1958?, for_response: "yes" + end + end + + should "have a next node of wfp_outcome_not_eligible for a 'no' response if benefit is winter_fuel_payment and going abroad" do + assert_next_node :wfp_not_eligible_outcome, for_response: "no" + end + + should "have a next node of worked_in_eea_or_switzerland? for a 'no' response if benefit is winter_fuel_payment and already abroad" do + add_responses going_or_already_abroad?: "already_abroad" + assert_next_node :worked_in_eea_or_switzerland?, for_response: "no" + end end - should "have a next node of wfp_ireland_outcome for a 'yes' response if benefit is winter_fuel_payment" do - add_responses which_benefit?: "winter_fuel_payment" - assert_next_node :wfp_ireland_outcome, for_response: "yes" + should "have a next node of jsa_ireland_outcome for a 'yes' response if benefit is jsa" do + assert_next_node :jsa_ireland_outcome, for_response: "yes" end - should "have a next node of esa_going_abroad_eea_outcome for a 'yes' response if benefit is winter_fuel_payment and going_abroad" do + should "have a next node of esa_going_abroad_eea_outcome for a 'yes' response if benefit is esa and going_abroad" do add_responses which_benefit?: "esa", esa_how_long_abroad?: "esa_more_than_a_year" assert_next_node :esa_going_abroad_eea_outcome, for_response: "yes" end - should "have a next node of esa_already_abroad_eea_outcome for a 'yes' response if benefit is winter_fuel_payment and already_abroad" do + should "have a next node of esa_already_abroad_eea_outcome for a 'yes' response if benefit is esa and already_abroad" do add_responses going_or_already_abroad?: "already_abroad", which_benefit?: "esa", esa_how_long_abroad?: "esa_more_than_a_year" @@ -1105,6 +1137,75 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end end + context "question: born_before_23_September_1958? for winter_fuel_payment" do + setup do + testing_node :born_before_23_September_1958? + add_responses going_or_already_abroad?: "going_abroad", + which_benefit?: "winter_fuel_payment", + which_country?: "ireland", + is_british_or_irish?: "yes" + end + + should "render the question" do + assert_rendered_question + end + + should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'yes' response" do + assert_next_node :you_or_partner_get_a_benefit_in_the_country?, for_response: "yes" + end + + should "have a next node of wfp_not_eligible_outcome for a 'no' response" do + assert_next_node :wfp_not_eligible_outcome, for_response: "no" + end + end + + context "question: you_or_partner_get_a_benefit_in_the_country? for winter_fuel_payment" do + setup do + testing_node :you_or_partner_get_a_benefit_in_the_country? + add_responses going_or_already_abroad?: "already_abroad", + which_benefit?: "winter_fuel_payment", + which_country?: "ireland", + is_british_or_irish?: "yes", + born_before_23_September_1958?: "yes" + end + + should "render the question" do + assert_rendered_question + end + + context "next_node" do + should "have a next node of wfp_not_eligible_outcome for a 'yes' response" do + assert_next_node :wfp_not_eligible_outcome, for_response: "yes" + end + + should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'no' response" do + assert_next_node :you_or_partner_get_a_means_tested_benefit_in_the_country?, for_response: "no" + end + end + end + + context "question: you_or_partner_get_a_means_tested_benefit_in_the_country? for winter_fuel_payment" do + setup do + testing_node :you_or_partner_get_a_means_tested_benefit_in_the_country? + add_responses which_benefit?: "winter_fuel_payment", + going_or_already_abroad?: "already_abroad", + which_country?: "ireland", + is_british_or_irish?: "yes", + born_before_23_September_1958?: "yes", + you_or_partner_get_a_benefit_in_the_country?: "no" + end + + context "next_node" do + should "have a next node of wfp_not_eligible_outcome for a 'no' response" do + assert_next_node :wfp_not_eligible_outcome, for_response: "no" + end + + should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'yes' response" do + assert_next_node :wfp_maybe_outcome, for_response: "yes" + end + end + end + context "outcome: bb_already_abroad_ss_outcome" do setup do testing_node :bb_already_abroad_ss_outcome