From 8d16c6f22865c9b028b3b25da256e87046da5c78 Mon Sep 17 00:00:00 2001 From: ColinBruce Date: Tue, 17 Dec 2024 09:39:13 +0000 Subject: [PATCH] AP-5592: Update scope limits on check provider answers >[!IMPORTANT] >Set up a feature test for expected current behaviour > >This changes the proceeding_details partial IDs quite heavily to make testing easier. Running first to see if it affects multiple tests --- .../stylesheets/check-your-answers.scss | 4 ++ .../_proceeding_details.html.erb | 20 ++++++- .../providers/check_provider_answers.feature | 24 ++++++++ .../check_provider_answers_steps.rb | 56 +++++++++++++++++++ features/step_definitions/generic_steps.rb | 4 +- 5 files changed, 103 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/check-your-answers.scss b/app/assets/stylesheets/check-your-answers.scss index ecf2c9feb2..8322a9245c 100644 --- a/app/assets/stylesheets/check-your-answers.scss +++ b/app/assets/stylesheets/check-your-answers.scss @@ -74,3 +74,7 @@ .print-no-break>.govuk-body { word-wrap: break-word; } + +.single-scope-limit-bold-heading { + font-weight: bold; +} diff --git a/app/views/shared/check_answers/_proceeding_details.html.erb b/app/views/shared/check_answers/_proceeding_details.html.erb index 83c1d50c84..c6634c18c7 100644 --- a/app/views/shared/check_answers/_proceeding_details.html.erb +++ b/app/views/shared/check_answers/_proceeding_details.html.erb @@ -8,7 +8,7 @@ end end - card.with_summary_list(actions: false) do |summary_list| + card.with_summary_list(actions: false, html_attributes: { id: "#{proceeding.ccms_code.downcase}-questions" }) do |summary_list| summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_client_involvement_type" }) do |row| row.with_key(text: t(".client_involvement_type_details.question"), classes: "govuk-!-width-one-third") row.with_value { proceeding.client_involvement_type_description } @@ -34,10 +34,17 @@ end end - summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_emergency_scope_limitations_#{proceeding.id}" }) do |row| + summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.ccms_code.downcase}_emergency_scope_limitations" }) do |row| row.with_key(text: t(".scope_limits.emergency.question")) row.with_value { scope_limits(proceeding, "emergency") } end + + # if one_scope_limit_with_hearing_date(proceeding, :emergency) + # summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_emergency_scope_limitations_hearing_date" }) do |row| + # row.with_key(text: t(".scope_limits.hearing_date")) + # row.with_value { one_scope_limit_with_hearing_date(proceeding, :emergency) } + # end + # end end summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_substantive_level_of_service_#{proceeding.id}" }) do |row| @@ -54,10 +61,17 @@ end end - summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_substantive_scope_limitations_#{proceeding.id}" }) do |row| + summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.ccms_code.downcase}_substantive_scope_limitations" }) do |row| row.with_key(text: t(".scope_limits.substantive.question")) row.with_value { scope_limits(proceeding, "substantive") } end + + # if one_scope_limit_with_a_hearing_date(proceeding, :substantive) + # summary_list.with_row(html_attributes: { id: "app-check-your-answers__#{proceeding.name}_emergency_scope_limitations_hearing_date_#{proceeding.id}" }) do |row| + # row.with_key(text: t(".scope_limits.hearing_date")) + # row.with_value { one_scope_limit_with_hearing_date(proceeding, :substantive).strftime("%-d %B %Y") } + # end + # end end end %> <% end %> diff --git a/features/providers/check_provider_answers.feature b/features/providers/check_provider_answers.feature index da46210d36..7bddf32732 100644 --- a/features/providers/check_provider_answers.feature +++ b/features/providers/check_provider_answers.feature @@ -479,3 +479,27 @@ Feature: Checking client details answers backwards and forwards When I choose "No" And I click "Save and continue" Then I should be on a page showing 'Check your answers' + + @javascript @vcr + Scenario: Multiple scope limitations are displayed as expected + Given I have created an application with da004 proceedings with delegated functions + And I view the check provider answers page + + Then the following sections should exist: + | tag | section | + | h2 | Client details | + | h2 | Proceedings | + | h2 | Non-molestation order | + | h2 | What happens next | + + And the "da004" proceeding check your answers section should contain: + | question | answer | + | Client role | Applicant/Claimant/Petitioner | + | Delegated functions | *skip-calculated* | + | Emergency level of service | Full Representation | + | Emergency scope limitations | Interim order inc. return date\nLimited to Family Help (Higher) and to all steps necessary to negotiate and conclude a settlement. To include the issue of proceedings and representation in those proceedings save in relation to or at a contested final hearing. | + | Substantive level of service | Full Representation | + | Substantive scope limitations | Final hearing\nLimited to all steps up to and including final hearing and any action necessary to implement (but not enforce) the order. | + + And the emergency scope limitation Interim order inc. return date heading for da004 should not be bold + And the substantive scope limitation Final hearing heading for da004 should not be bold diff --git a/features/step_definitions/check_provider_answers_steps.rb b/features/step_definitions/check_provider_answers_steps.rb index 09a8127430..dfeee67d96 100644 --- a/features/step_definitions/check_provider_answers_steps.rb +++ b/features/step_definitions/check_provider_answers_steps.rb @@ -9,3 +9,59 @@ Then("the \"Partner details\" check your answers section should contain:") do |table| expect_questions_and_answers_in(selector: "#partner-details-questions", expected: table) end + +Given(/^I have created an application with (.*) proceedings (with|without) delegated functions$/) do |proceedings, df| + proceeding_array = proceedings.split(",").map(&:to_sym) + df_options = df == "with" ? proceeding_array.map { |p| { p.upcase => [10.days.ago, 10.days.ago] } }[0] : {} + applicant = create( + :applicant, + first_name: "Test", + last_name: "Test", + national_insurance_number: "JA123456A", + date_of_birth: "01-01-1970", + email: "test@test.com", + has_partner: false, + ) + create( + :address, + address_line_one: "Transport For London", + address_line_two: "98 Petty France", + city: "London", + postcode: "SW1H 9EA", + lookup_used: true, + applicant:, + ) + @legal_aid_application = create( + :legal_aid_application, + :with_non_passported_state_machine, + :at_entering_applicant_details, + :with_proceedings, + :with_delegated_functions_on_proceedings, + explicit_proceedings: proceeding_array, + set_lead_proceeding: proceeding_array.first, + df_options:, + applicant:, + ) + login_as @legal_aid_application.provider +end + +And("I view the check provider answers page") do + visit(providers_legal_aid_application_check_provider_answers_path(@legal_aid_application)) + steps %(Then I should be on a page showing 'Check your answers') +end + +Then("the {string} proceeding check your answers section should contain:") do |proceeding_code, table| + expect_questions_and_answers_in(selector: "##{proceeding_code}-questions", expected: table) +end + +Then(/^the (emergency|substantive) scope limitation (.*) heading for (.*) should (be|not be) bold$/) do |type, text, proceeding_code, match| + within("##{proceeding_code}-questions") do + within("#app-check-your-answers__#{proceeding_code}_#{type}_scope_limitations") do + if match == "be" + expect(page).to have_css("span.single-scope-limit-heading", text:, visible: :visible) + else + expect(page).to have_no_css("span.single-scope-limit-heading", text:) + end + end + end +end diff --git a/features/step_definitions/generic_steps.rb b/features/step_definitions/generic_steps.rb index 8b549e825a..02ed64a997 100644 --- a/features/step_definitions/generic_steps.rb +++ b/features/step_definitions/generic_steps.rb @@ -71,8 +71,8 @@ def expect_questions_in(expected:, selector:, negate: false) def expect_questions_and_answers_in(expected:, selector:) within(selector) do expected.hashes.each do |row| - expect(page).to have_css("dt", text: row[:question]), "expected to find tag \"dt\" with text: \"#{row[:question]}\"" - expect(page).to have_css("dd", text: row[:answer]), "expected to find tag \"dd\" with text: \"#{row[:answer]}\"" + expect(page).to have_css("dt", text: row[:question]), "expected to find tag \"dt\" with text: \"#{row[:question]}\"" unless row[:question] == "*skip-calculated*" + expect(page).to have_css("dd", text: row[:answer]), "expected to find tag \"dd\" with text: \"#{row[:answer]}\"" unless row[:answer] == "*skip-calculated*" end end end