Skip to content

Commit

Permalink
add check for EE result (#1550)
Browse files Browse the repository at this point in the history
add expectation for the contents of EE check answers

add nocov to fix coverage issue, there are tests covering both sides of the branch
  • Loading branch information
willc-work authored Oct 14, 2024
1 parent 9199570 commit 6523d45
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/models/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ def owns_property_outright?
Steps::Logic.owns_property_outright?(session_data)
end

def gross_early_eligibility_exit?
session_data["early_eligibility_selection"] == "gross"
end

def early_ineligible_result?
session_data.dig("early_result", "result") == "ineligible"
end
Expand Down
17 changes: 12 additions & 5 deletions app/services/check_answers/section_lister_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ def call(session_data)
else
pre = [
Sections::Dependants.new(check),
Sections::ClientIncome.new(check),
]
post = [Sections::Outgoings.new(check)]
# Simplecov is showing that check.under_eighteen_assets? is not being covered by a test
# we have tests in spec/flows/under_eighteen_flow_spec.rb that check with and without under_eighteen_assets
# :nocov:
(Sections::ClientIncome.new(check) if !check.under_eighteen? || check.aggregated_means? || check.under_eighteen_regular_income? || check.under_eighteen_assets?),
# :nocov:
].compact

post = check.gross_early_eligibility_exit? ? [] : [Sections::Outgoings.new(check)]
finance_sections = if check.partner?
pre + [Sections::PartnerIncome.new(check)] + post
pre + (check.gross_early_eligibility_exit? ? [] : [Sections::PartnerIncome.new(check)]) + post
else
pre + post
end
non_finance_sections + finance_sections + assets
assets_sections = check.gross_early_eligibility_exit? ? [] : assets

non_finance_sections + finance_sections + assets_sections
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/flows/early_result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@
fill_in_other_income_screen_with_friends_and_family
fill_in_ineligible_gross_income_screen(choice: "Skip remaining questions")
confirm_screen("check_answers")
expect(all(".govuk-summary-card__title").map(&:text))
.to eq(
["Client age",
"Partner and passporting",
"Level of help",
"Type of matter",
"Type of immigration or asylum matter",
"Number of dependants",
"Employment status",
"Client employment income 1",
"Client benefits",
"Client other income"],
)
end

it "back links work as expected" do
Expand Down
48 changes: 48 additions & 0 deletions spec/flows/under_eighteen_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,54 @@
end
end

context "with under 18 changing answers" do
before do
fill_in_client_age_screen(choice: "Under 18")
fill_in_level_of_help_screen(choice: "Civil controlled work or family mediation")
fill_in_under_18_controlled_legal_rep_screen(choice: "No")
fill_in_aggregated_means_screen(choice: "No")
fill_in_regular_income_screen(choice: "No")
fill_in_under_eighteen_assets_screen(choice: "No")
fill_in_forms_until(:check_answers)
end

it "shows correct sections for under 18 no means test" do
expect(all(".govuk-summary-card__title").map(&:text))
.to eq(
[
"Client age",
"Level of help",
"Means tests for under 18s",
],
)
end

it "show correct sections when answers are changed" do
within "#table-under_eighteen_assets" do
find('a[aria-label="Change under 18 assets"]').click
end
fill_in_under_eighteen_assets_screen(choice: "Yes")
fill_in_forms_until(:check_answers)
expect(all(".govuk-summary-card__title").map(&:text))
.to eq(
["Client age",
"Partner and passporting",
"Level of help",
"Means tests for under 18s",
"Type of matter",
"Number of dependants",
"Employment status",
"Client benefits",
"Client other income",
"Client outgoings and deductions",
"Home client lives in",
"Housing costs",
"Client other property",
"Client assets"],
)
end
end

context "with u18 controlled checks with aggregated means" do
before do
fill_in_client_age_screen(choice: "Under 18")
Expand Down

0 comments on commit 6523d45

Please sign in to comment.