diff --git a/app/helpers/interuption_screen_helper.rb b/app/helpers/interuption_screen_helper.rb
index c5578c009..e3fc158da 100644
--- a/app/helpers/interuption_screen_helper.rb
+++ b/app/helpers/interuption_screen_helper.rb
@@ -1,7 +1,16 @@
module InteruptionScreenHelper
def display_informative_text(informative_text, case_log)
- translation_question = informative_text["argument"].map { |x| case_log.form.get_question(x) }
- translation = I18n.t(informative_text["translation"], informative_text["argument"][0].to_sym => translation_question[0].answer_label(case_log), informative_text["argument"][1].to_sym => translation_question[1].answer_label(case_log))
- "#{translation}".html_safe
+ translation_questions = informative_text["argument"].map { |x| case_log.form.get_question(x) }
+ begin
+ case translation_questions.count
+ when 2
+ translation = I18n.t(informative_text["translation"], informative_text["argument"][0].to_sym => translation_questions[0].answer_label(case_log), informative_text["argument"][1].to_sym => translation_questions[1].answer_label(case_log))
+ when 1
+ translation = I18n.t(informative_text["translation"], informative_text["argument"][0].to_sym => translation_questions[0].answer_label(case_log))
+ end
+ rescue StandardError
+ return ""
+ end
+ translation.html_safe
end
end
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index 575a3ea94..cb1208e53 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -4578,12 +4578,16 @@
},
"net_income_value_check": {
"depends_on": [{ "net_income_soft_validation_triggered?": true }],
- "title_text": "Net income value outside expected range",
+ "title_text": "Net income is higher than expected based on the main tenant’s working situation",
+ "informative_text": {
+ "translation": "soft_validations.net_income.hint_text",
+ "argument": ["ecstat1", "earnings"]
+ },
"questions": {
"net_income_value_check": {
"check_answer_label": "Net income soft validation",
"hidden_in_check_answers": true,
- "header": "Is this value correct?",
+ "header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
"0": {
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c155cab1a..d692fc5fb 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -90,8 +90,8 @@ en:
reasonpref:
not_homeless: "Answer cannot be ‘homeless or about to lose their home’ as you already told us the tenant was not homeless immediately prior to this letting"
reasonable_preference_reason:
- reason_required: "If reasonable preference is \"Yes\", a reason must be given"
- reason_not_required: "If reasonable preference is \"No\", no reasons should be given"
+ reason_required: 'If reasonable preference is "Yes", a reason must be given'
+ reason_not_required: 'If reasonable preference is "No", no reasons should be given'
underoccupation_benefitcap:
dont_know_required: "must be don’t know if tenant’s main reason for leaving is don’t know"
reservist:
@@ -131,7 +131,6 @@ en:
not_homeless: "Answer cannot be ‘no’ as you already told us the tenant was homeless or about to lose their home"
previous_la_known: "Enter a local authority"
-
tenancy:
length:
fixed_term_not_required: "You must only answer the fixed term tenancy length question if the tenancy type is fixed term"
@@ -145,7 +144,7 @@ en:
soft_validations:
net_income:
- hint_text: "This is based on the tenant’s work situation: %{ecstat1}\nThe household income you have entered is %{earnings}"
+ hint_text: "This is based on the tenant’s work situation: %{ecstat1}
The household income you have entered is %{earnings}"
in_soft_min_range:
message: "Net income is lower than expected based on the main tenant’s working situation. Are you sure this is correct?"
in_soft_max_range:
@@ -160,3 +159,6 @@ en:
code_has_been_sent: "Your security code has been sent."
code_required: "Security code is required"
code_incorrect: "Security code is incorrect"
+
+ test:
+ one_argument: "This is based on the tenant’s work situation: %{ecstat1}"
diff --git a/spec/helpers/interuption_screen_helper_spec.rb b/spec/helpers/interuption_screen_helper_spec.rb
new file mode 100644
index 000000000..df17c30cf
--- /dev/null
+++ b/spec/helpers/interuption_screen_helper_spec.rb
@@ -0,0 +1,65 @@
+require "rails_helper"
+
+RSpec.describe InteruptionScreenHelper do
+ form_handler = FormHandler.instance
+ let(:form) { form_handler.get_form("test_form") }
+ let(:subsection) { form.get_subsection("household_characteristics") }
+ let(:user) { FactoryBot.create(:user) }
+ let(:case_log) do
+ FactoryBot.create(
+ :case_log,
+ :in_progress,
+ ecstat1: 1,
+ earnings: 750,
+ incfreq: 0,
+ owning_organisation: user.organisation,
+ managing_organisation: user.organisation,
+ )
+ end
+
+ describe "display_informative_text" do
+ context "when 2 out of 2 arguments are given" do
+ it "returns correct informative text" do
+ informative_text = {
+ "translation" => "soft_validations.net_income.hint_text",
+ "argument" => %w[ecstat1 earnings],
+ }
+ expect(display_informative_text(informative_text, case_log))
+ .to eq("This is based on the tenant’s work situation: Full-time – 30 hours or more
The household income you have entered is £750.00 every week")
+ end
+ end
+
+ context "when 1 out of 1 arguments is given" do
+ it "returns correct informative text" do
+ informative_text = {
+ "translation" => "test.one_argument",
+ "argument" => %w[ecstat1],
+ }
+ expect(display_informative_text(informative_text, case_log))
+ .to eq("This is based on the tenant’s work situation: Full-time – 30 hours or more")
+ end
+ end
+ end
+
+ context "when 2 out of 1 arguments are given" do
+ it "returns correct informative text" do
+ informative_text = {
+ "translation" => "test.one_argument",
+ "argument" => %w[ecstat1 earnings],
+ }
+ expect(display_informative_text(informative_text, case_log))
+ .to eq("This is based on the tenant’s work situation: Full-time – 30 hours or more")
+ end
+ end
+
+ context "when 1 out of 2 arguments are given" do
+ it "returns an empty string" do
+ informative_text = {
+ "translation" => "soft_validations.net_income.hint_text",
+ "argument" => %w[ecstat1],
+ }
+ expect(display_informative_text(informative_text, case_log))
+ .to eq("")
+ end
+ end
+end