Browse Source

Update content and add more tests for previous page

pull/434/head
Kat 3 years ago
parent
commit
7a98ccbd4d
  1. 2
      config/forms/2021_2022.json
  2. 6
      config/locales/en.yml
  3. 4
      spec/features/form/validations_spec.rb
  4. 2
      spec/fixtures/forms/2021_2022.json
  5. 2
      spec/helpers/interuption_screen_helper_spec.rb
  6. 42
      spec/models/form_spec.rb
  7. 2
      spec/models/validations/household_validations_spec.rb

2
config/forms/2021_2022.json

@ -4575,7 +4575,7 @@
},
"net_income_value_check": {
"depends_on": [{ "net_income_soft_validation_triggered?": true }],
"title_text": "Net income is outside the expected range based on the main tenant’s working situation",
"title_text": "Net income is outside the expected range based on the lead tenant’s working situation",
"informative_text": {
"translation": "soft_validations.net_income.hint_text",
"argument": {"ecstat1": "question", "earnings": "question"}

6
config/locales/en.yml

@ -219,11 +219,11 @@ en:
soft_validations:
net_income:
hint_text: "<p>You told us the main tenant’s working situation is: <strong>%{ecstat1}</strong></p><p>The household income you have entered is <strong>%{earnings}</strong></p>"
hint_text: "<p>You told us the lead tenant’s working situation is: <strong>%{ecstat1}</strong></p><p>The household income you have entered is <strong>%{earnings}</strong></p>"
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?"
message: "Net income is lower than expected based on the lead tenant’s working situation. Are you sure this is correct?"
in_soft_max_range:
message: "Net income is higher than expected based on the main tenant’s working situation. Are you sure this is correct?"
message: "Net income is higher than expected based on the lead tenant’s working situation. Are you sure this is correct?"
rent:
min:
hint_text: "<p>The minimum rent for a property in %{la} is £%{soft_min} every week.</p><p>You entered <strong>%{brent}</strong></p>"

4
spec/features/form/validations_spec.rb

@ -130,8 +130,8 @@ RSpec.describe "validations" do
choose("case-log-incfreq-0-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{case_log.id}/net-income-value-check")
expect(page).to have_content("Net income is outside the expected range based on the main tenant’s working situation")
expect(page).to have_content("You told us the main tenant’s working situation is: Full-time – 30 hours or more")
expect(page).to have_content("Net income is outside the expected range based on the lead tenant’s working situation")
expect(page).to have_content("You told us the lead tenant’s working situation is: Full-time – 30 hours or more")
expect(page).to have_content("The household income you have entered is £750.00 every week")
choose("case-log-net-income-value-check-0-field", allow_label_click: true)
click_button("Save and continue")

2
spec/fixtures/forms/2021_2022.json vendored

@ -559,7 +559,7 @@
},
"net_income_value_check": {
"depends_on": [{ "net_income_soft_validation_triggered?": true }],
"title_text": "Net income is outside the expected range based on the main tenant’s working situation",
"title_text": "Net income is outside the expected range based on the lead tenant’s working situation",
"informative_text": {
"translation": "soft_validations.net_income.hint_text",
"argument": {"ecstat1": "question", "earnings": "question"}

2
spec/helpers/interuption_screen_helper_spec.rb

@ -25,7 +25,7 @@ RSpec.describe InteruptionScreenHelper do
"argument" => { "ecstat1": "question", "earnings": "question" },
}
expect(display_informative_text(informative_text, case_log))
.to eq("<p>You told us the main tenant’s working situation is: <strong>Full-time – 30 hours or more</strong></p><p>The household income you have entered is <strong>£750.00 every week</strong></p>")
.to eq("<p>You told us the lead tenant’s working situation is: <strong>Full-time – 30 hours or more</strong></p><p>The household income you have entered is <strong>£750.00 every week</strong></p>")
end
end

42
spec/models/form_spec.rb

@ -14,13 +14,43 @@ RSpec.describe Form, type: :model do
expect(form.next_page(previous_page, case_log)).to eq("person_1_gender")
end
it "returns the previuos page if the current page is a value check page with a `No` answer and the page is routed to" do
case_log.net_income_value_check = 1
case_log.incfreq = 0
case_log.earnings = 140
case_log.ecstat1 = 1
context "when the current page is a value check page" do
before do
case_log.incfreq = 0
case_log.earnings = 140
case_log.ecstat1 = 1
end
it "returns the previous page if answer is `No` and the page is routed to" do
case_log.net_income_value_check = 1
expect(form.next_page(value_check_previous_page, case_log)).to eq("net_income")
end
it "returns the next page if answer is `Yes` answer and the page is routed to" do
case_log.net_income_value_check = 0
expect(form.next_page(value_check_previous_page, case_log)).to eq("net_income_uc_proportion")
end
end
end
expect(form.next_page(value_check_previous_page, case_log)).to eq("net_income")
describe ".previous_page" do
context "when the current page is not a value check page" do
let!(:subsection) { form.get_subsection("conditional_question") }
let!(:page_ids) { subsection.pages.map(&:id) }
before do
case_log.preg_occ = 1
end
it "returns the previous page if the page is routed to" do
page_index = page_ids.index("conditional_question_no_second_page")
expect(form.previous_page(page_ids, page_index, case_log)).to eq("conditional_question_no_page")
end
it "returns the page before the previous one if the previous page is not routed to" do
page_index = page_ids.index("conditional_question_no_page")
expect(form.previous_page(page_ids, page_index, case_log)).to eq("conditional_question")
end
end
end

2
spec/models/validations/household_validations_spec.rb

@ -86,7 +86,7 @@ RSpec.describe Validations::HouseholdValidations do
end
end
context "and they are the main tenant and under 51" do
context "and they are the lead tenant and under 51" do
it "pregnancy can be yes" do
record.preg_occ = 0
record.sex1 = "F"

Loading…
Cancel
Save