Skip to content

Commit

Permalink
Add comments for sitemap corrects on consistency checklist
Browse files Browse the repository at this point in the history
  • Loading branch information
EGiataganas committed Jan 23, 2025
1 parent 90d6b63 commit a517d35
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} %>
<br>
<% if can_edit %>
<%= form.govuk_radio_button(
:site_map_correct,
Expand All @@ -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(
Expand All @@ -39,3 +43,9 @@
}
) %>
<% end %>
<% if !can_edit && consistency_checklist.site_map_correct_comment %>
<h4 class="govuk-heading-s">Comment</h4>
<p class="govuk-body">
<%= render(FormattedContentComponent.new(text: consistency_checklist.site_map_correct_comment)) %>
<p>
<% end %>
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down Expand Up @@ -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") }
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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") }
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit a517d35

Please sign in to comment.