Browse Source

Update test & code - failing last new expectation

pull/338/head
MadeTech Dushan 3 years ago
parent
commit
62f84385fc
  1. 3
      app/models/form/page.rb
  2. 4
      app/views/form/_interruption_screen_question.html.erb
  3. 2
      app/views/form/page.html.erb
  4. 4
      spec/features/form/validations_spec.rb
  5. 58
      spec/fixtures/forms/2021_2022.json

3
app/models/form/page.rb

@ -1,6 +1,6 @@
class Form::Page
attr_accessor :id, :header, :description, :questions, :soft_validations,
:depends_on, :title_text, :subsection, :hide_subsection_label
:depends_on, :title_text, :informative_text, :subsection, :hide_subsection_label
def initialize(id, hsh, subsection)
@id = id
@ -9,6 +9,7 @@ class Form::Page
@questions = hsh["questions"].map { |q_id, q| Form::Question.new(q_id, q, self) }
@depends_on = hsh["depends_on"]
@title_text = hsh["title_text"]
@informative_text = hsh["informative_text"]
@hide_subsection_label = hsh["hide_subsection_label"]
@soft_validations = hsh["soft_validations"]&.map { |sv_id, s| Form::Question.new(sv_id, s, self) }
@subsection = subsection

4
app/views/form/_interruption_screen_question.html.erb

@ -2,10 +2,12 @@
title_text: title_text,
classes: 'app-panel--interruption',
) do %>
<% translation_question = case_log.form.get_question(informative_text["argument"]) %>
<% binding.pry %>
<%= I18n.t(informative_text["translation"], informative_text["argument"].to_sym => translation_question.answer_label(case_log)) %>
<%= f.govuk_radio_buttons_fieldset question.id.to_sym,
legend: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe } do %>
<% question.answer_options.map do |key, options| %>
<% if key.starts_with?("divider") %>
<%= f.govuk_radio_divider %>

2
app/views/form/page.html.erb

@ -39,7 +39,7 @@
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m">
<% end %>
<% if question.type == "interruption_screen" %>
<%= render partial: "form/#{question.type}_question", locals: { question: question, caption_text: @subsection.label, page_header: @page.header, case_log: @case_log, title_text: @page.title_text, f: f, conditional: false } %>
<%= render partial: "form/#{question.type}_question", locals: { question: question, caption_text: @subsection.label, page_header: @page.header, case_log: @case_log, title_text: @page.title_text, informative_text: @page.informative_text, form: @form, f: f, conditional: false } %>
<% else %>
<%= render partial: "form/#{question.type}_question", locals: { question: question, caption_text: @subsection.label, page_header: @page.header, case_log: @case_log, f: f, conditional: false } %>
<% end %>

4
spec/features/form/validations_spec.rb

@ -130,7 +130,9 @@ 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 value outside expected range")
expect(page).to have_content("Net income is higher than expected based on the main tenant’s working situation")
expect(page).to have_content("This is based on the tenant’s work situation: Full-time – 30 hours or more")
expect(page).to have_content("The household income you have entered is £750 every week")
choose("case-log-net-income-value-check-0-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{case_log.id}/net-income-uc-proportion")

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

@ -64,6 +64,56 @@
}
}
},
"person_1_working_situation": {
"header": "",
"description": "",
"questions": {
"ecstat1": {
"check_answer_label": "Lead tenant’s working situation",
"header": "Which of these best describes the lead tenant’s working situation?",
"hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
"type": "radio",
"answer_options": {
"0": {
"value": "Part-time – Less than 30 hours"
},
"1": {
"value": "Full-time – 30 hours or more"
},
"2": {
"value": "Full-time student"
},
"3": {
"value": "In government training into work, such as New Deal"
},
"4": {
"value": "Jobseeker"
},
"5": {
"value": "Not seeking work"
},
"6": {
"value": "Unable to work because of long term sick or disability"
},
"7": {
"value": "Retired"
},
"8": {
"value": "Child under 16"
},
"9": {
"value": "Other"
},
"divider": {
"value": true
},
"10": {
"value": "Tenant prefers not to say"
}
}
}
}
},
"household_number_of_other_members": {
"questions": {
"other_hhmemb": {
@ -489,12 +539,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"
},
"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": {

Loading…
Cancel
Save