From a517d3588b6c94fd08afdf8c168a575e6525471b Mon Sep 17 00:00:00 2001 From: Evangelos Giataganas Date: Fri, 17 Jan 2025 18:24:45 +0200 Subject: [PATCH] Add comments for sitemap corrects on consistency checklist --- .../consistency_checklists_controller.rb | 1 + .../_site_map_correct.html.erb | 22 +- config/locales/en.yml | 2 +- ...rrect_comment_to_consistency_checklists.rb | 7 + db/schema.rb | 3 +- .../assessing/checking_consistency_spec.rb | 216 +++++++++++++++++- 6 files changed, 239 insertions(+), 12 deletions(-) create mode 100644 db/migrate/20250120122725_add_site_map_correct_comment_to_consistency_checklists.rb diff --git a/app/controllers/planning_applications/assessment/consistency_checklists_controller.rb b/app/controllers/planning_applications/assessment/consistency_checklists_controller.rb index 02f1188ce3..d697facf4f 100644 --- a/app/controllers/planning_applications/assessment/consistency_checklists_controller.rb +++ b/app/controllers/planning_applications/assessment/consistency_checklists_controller.rb @@ -66,6 +66,7 @@ def permitted_params :proposal_details_match_documents, :proposal_details_match_documents_comment, :site_map_correct, + :site_map_correct_comment, :proposal_measurements_match_documents, {proposal_measurement: %i[eaves_height max_height depth]} ] diff --git a/app/views/planning_applications/assessment/consistency_checklists/_site_map_correct.html.erb b/app/views/planning_applications/assessment/consistency_checklists/_site_map_correct.html.erb index 5df518d996..c4dced0312 100644 --- a/app/views/planning_applications/assessment/consistency_checklists/_site_map_correct.html.erb +++ b/app/views/planning_applications/assessment/consistency_checklists/_site_map_correct.html.erb @@ -2,6 +2,8 @@ :site_map_correct, legend: {text: t(".is_the_red"), size: "s"} ) do %> + <%= render "shared/location_map", locals: {in_accordion: true, geojson: @planning_application.boundary_geojson} %> +
<% if can_edit %> <%= form.govuk_radio_button( :site_map_correct, @@ -16,12 +18,14 @@ label: {text: t(".no")}, checked: form.object.default_site_map_correct_to_no? ) do %> - <% unless form.object.open_red_line_boundary_change_requests? %> - <%= govuk_link_to t(".request_red_line_boundary_change"), new_planning_application_validation_validation_request_path( - planning_application, - type: "red_line_boundary_change" - ) %> - <% end %> + <% if planning_application.pre_application? %> + <%= form.govuk_text_area :site_map_correct_comment, label: {text: "Add a comment"} %> + <% elsif !form.object.open_red_line_boundary_change_requests? && !planning_application.pre_application? %> + <%= govuk_link_to t(".request_red_line_boundary_change"), new_planning_application_validation_validation_request_path( + planning_application, + type: "red_line_boundary_change" + ) %> + <% end %> <% end %> <% else %> <%= form.govuk_radio_button( @@ -39,3 +43,9 @@ } ) %> <% end %> +<% if !can_edit && consistency_checklist.site_map_correct_comment %> +

Comment

+

+ <%= render(FormattedContentComponent.new(text: consistency_checklist.site_map_correct_comment)) %> +

+<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index b450fe3d32..b49b8ab081 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1259,7 +1259,7 @@ en: reason: 'Reason:' view_and_edit: View and edit request site_map_correct: - is_the_red: Is the red line on the site map correct for the site and proposed works? + is_the_red: Is the site map correct? 'no': 'No' request_red_line_boundary_change: Request a change to the red line boundary 'yes': 'Yes' diff --git a/db/migrate/20250120122725_add_site_map_correct_comment_to_consistency_checklists.rb b/db/migrate/20250120122725_add_site_map_correct_comment_to_consistency_checklists.rb new file mode 100644 index 0000000000..3d591ecd5a --- /dev/null +++ b/db/migrate/20250120122725_add_site_map_correct_comment_to_consistency_checklists.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSiteMapCorrectCommentToConsistencyChecklists < ActiveRecord::Migration[7.2] + def change + add_column :consistency_checklists, :site_map_correct_comment, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 2acf043f9b..162e9b0f67 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_12_19_161821) do +ActiveRecord::Schema[7.2].define(version: 2025_01_20_122725) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "plpgsql" @@ -220,6 +220,7 @@ t.datetime "updated_at", null: false t.integer "site_map_correct", default: 0, null: false t.integer "proposal_measurements_match_documents", default: 0, null: false + t.text "site_map_correct_comment" t.index ["planning_application_id"], name: "ix_consistency_checklists_on_planning_application_id" end diff --git a/spec/system/planning_applications/assessing/checking_consistency_spec.rb b/spec/system/planning_applications/assessing/checking_consistency_spec.rb index 73250ca0d6..f659154b9a 100644 --- a/spec/system/planning_applications/assessing/checking_consistency_spec.rb +++ b/spec/system/planning_applications/assessing/checking_consistency_spec.rb @@ -47,7 +47,7 @@ ) form_group1 = form_group_with_legend( - "Is the red line on the site map correct for the site and proposed works?" + "Is the site map correct?" ) within(form_group1) { choose("Yes") } @@ -154,7 +154,7 @@ ) form_group1 = form_group_with_legend( - "Is the red line on the site map correct for the site and proposed works?" + "Is the site map correct?" ) within(form_group1) { choose("Yes") } @@ -245,6 +245,214 @@ end end + context "when the application is a pre application" do + let(:planning_application) do + create( + :planning_application, + :pre_application, + :in_assessment, + local_authority: + ) + end + + before do + create(:proposal_measurement, planning_application:) + end + + context "lets user save draft or mark as complete" do + it "when site map is correct" do + expect(list_item("Check and assess")).to have_content("Not started") + click_link("Check and assess") + click_link("Check description, documents and proposal details") + click_button("Save and mark as complete") + + expect(page).to have_content( + "Determine whether the description matches the development or use in the plans" + ) + + expect(page).to have_content( + "Determine whether the proposal details are consistent with the plans" + ) + + expect(page).to have_content( + "Determine whether the plans are consistent with each other" + ) + + form_group1 = form_group_with_legend( + "Is the site map correct?" + ) + + within(form_group1) { choose("Yes") } + + form_group2 = form_group_with_legend( + "Does the description match the development or use in the plans?" + ) + + within(form_group2) { choose("Yes") } + + form_group3 = form_group_with_legend( + "Are the plans consistent with each other?" + ) + + within(form_group3) { choose("Yes") } + click_button("Save and come back later") + + expect(page).to have_content("Successfully updated application checklist") + + expect(task_list_item).to have_content("In progress") + + click_link("Check description, documents and proposal details") + + form_group4 = form_group_with_legend( + "Are the proposal details consistent with the plans?" + ) + + within(form_group4) { choose("Yes") } + + click_button("Save and mark as complete") + + expect(page).to have_content("Successfully updated application checklist") + + expect(task_list_item).to have_content("Completed") + + click_link("Check description, documents and proposal details") + + field1 = find_by_id( + "consistency-checklist-description-matches-documents-yes-field" + ) + + field2 = find_by_id("consistency-checklist-documents-consistent-yes-field") + + field3 = find_by_id( + "consistency-checklist-proposal-details-match-documents-yes-field" + ) + + field4 = find_by_id( + "consistency-checklist-site-map-correct-yes-field" + ) + + expect(field1).to be_disabled + expect(field1).to be_checked + expect(field2).to be_disabled + expect(field2).to be_checked + expect(field3).to be_disabled + expect(field3).to be_checked + expect(field4).to be_disabled + expect(field4).to be_checked + + click_link("Application") + + expect(list_item("Check and assess")).to have_content("In progress") + end + + it "when site map is wrong leave a comment" do + expect(list_item("Check and assess")).to have_content("Not started") + click_link("Check and assess") + click_link("Check description, documents and proposal details") + click_button("Save and mark as complete") + + expect(page).to have_content( + "Determine whether the description matches the development or use in the plans" + ) + + expect(page).to have_content( + "Determine whether the proposal details are consistent with the plans" + ) + + expect(page).to have_content( + "Determine whether the plans are consistent with each other" + ) + + form_group1 = form_group_with_legend( + "Is the site map correct?" + ) + + within(form_group1) { choose("No") } + + fill_in( + "Add a comment", + with: "Site map is wrong" + ) + + form_group2 = form_group_with_legend( + "Does the description match the development or use in the plans?" + ) + + within(form_group2) { choose("Yes") } + + form_group3 = form_group_with_legend( + "Are the plans consistent with each other?" + ) + + within(form_group3) { choose("Yes") } + click_button("Save and come back later") + + expect(page).to have_content("Successfully updated application checklist") + + expect(task_list_item).to have_content("In progress") + + click_link("Check description, documents and proposal details") + + form_group4 = form_group_with_legend( + "Are the proposal details consistent with the plans?" + ) + + within(form_group4) { choose("No") } + + fill_in( + "How are the proposal details inconsistent?", + with: "Reason for inconsistencty" + ) + + click_button("Save and mark as complete") + + expect(page).to have_content("Successfully updated application checklist") + + expect(task_list_item).to have_content("Completed") + + click_link("Check description, documents and proposal details") + + field1 = find_by_id( + "consistency-checklist-description-matches-documents-yes-field" + ) + + field2 = find_by_id("consistency-checklist-documents-consistent-yes-field") + + field3 = find_by_id( + "consistency-checklist-proposal-details-match-documents-no-field" + ) + + field4 = find_by_id( + "consistency-checklist-site-map-correct-no-field" + ) + + expect(field1).to be_disabled + expect(field1).to be_checked + expect(field2).to be_disabled + expect(field2).to be_checked + expect(field3).to be_disabled + expect(field3).to be_checked + expect(field4).to be_checked + expect(field4).to be_checked + + expect(page).not_to have_field( + "How are the proposal details inconsistent?", + with: "Reason for inconsistencty" + ) + + expect(page).to have_content("How are the proposal details inconsistent?") + expect(page).to have_content("Reason for inconsistencty") + + expect(page).to have_content("Comment") + expect(page).to have_content("Site map is wrong") + + click_link("Application") + + expect(list_item("Check and assess")).to have_content("In progress") + end + end + end + it "lets the user request a description change" do travel_to(Time.zone.local(2022, 9, 15, 12)) click_link("Check and assess") @@ -444,7 +652,7 @@ click_link("Check description, documents and proposal details") form_group = form_group_with_legend( - "Is the red line on the site map correct for the site and proposed works?" + "Is the site map correct?" ) within(form_group) { choose("No") } @@ -487,7 +695,7 @@ click_link("Check description, documents and proposal details") form_group = form_group_with_legend( - "Is the red line on the site map correct for the site and proposed works?" + "Is the site map correct?" ) within(form_group) { expect(find_field("No")).to be_checked }