-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ask user for school if location isn't confirmed
When giving consent, if a parent says that their child does not attend the session's school, we should display a form that allows them to choose a different school. We save this location to `@consent_form.location_id`, allowing us to use it later to disambiguate which session the child is meant to be a part of.
- Loading branch information
Showing
7 changed files
with
135 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/views/parent_interface/consent_forms/edit/school.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<% content_for :before_main do %> | ||
<%= render AppBacklinkComponent.new( | ||
href: backlink_path, | ||
name: "previous page", | ||
) %> | ||
<% end %> | ||
<%= form_with model: @consent_form, url: wizard_path, method: :put do |f| %> | ||
<%= f.govuk_error_summary %> | ||
<%= h1 "What school does your child go to?" %> | ||
|
||
<p> | ||
You can only use this service if your child's school is listed here. | ||
If it's not, contact <%= mail_to @session.team.email %>. | ||
If you've moved recently, it's important to mention this. | ||
</p> | ||
|
||
<%= render DfE::Autocomplete::View.new( | ||
f, | ||
attribute_name: :location_id, | ||
form_field: f.govuk_select( | ||
:location_id, | ||
options_for_select( | ||
dfe_autocomplete_options( | ||
@consent_form.eligible_schools.map { | ||
OpenStruct.new(name: _1.name, value: _1.id) | ||
} | ||
), | ||
f.object.id, | ||
), | ||
label: { text: "Select a school" }, | ||
), | ||
) %> | ||
<%= f.govuk_submit "Continue" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# frozen_string_literal: true | ||
|
||
describe "Parental consent school" do | ||
before { Flipper.enable(:consent_form_choose_school) } | ||
|
||
scenario "Child attends a different school" do | ||
given_an_hpv_programme_is_underway | ||
when_i_go_to_the_consent_form | ||
when_i_fill_in_my_childs_name_and_birthday | ||
|
||
when_i_do_not_confirm_they_attend_the_pilot_school | ||
then_i_see_a_page_asking_for_the_childs_school | ||
|
||
when_i_click_continue | ||
then_i_see_an_error | ||
|
||
when_i_choose_a_school | ||
then_i_see_the_parent_step | ||
end | ||
|
||
def given_an_hpv_programme_is_underway | ||
@team = create(:team, :with_one_nurse) | ||
programme = create(:programme, :hpv, team: @team) | ||
location = create(:location, :school, team: @team, name: "Pilot School") | ||
@session = create(:session, :scheduled, team: @team, programme:, location:) | ||
@child = create(:patient, session: @session) | ||
end | ||
|
||
def when_i_go_to_the_consent_form | ||
visit start_session_parent_interface_consent_forms_path(@session) | ||
end | ||
|
||
def when_i_fill_in_my_childs_name_and_birthday | ||
click_on "Start now" | ||
|
||
expect(page).to have_content("What is your child’s name?") | ||
fill_in "First name", with: @child.first_name | ||
fill_in "Last name", with: @child.last_name | ||
choose "No" # Do they use a different name in school? | ||
click_on "Continue" | ||
|
||
expect(page).to have_content("What is your child’s date of birth?") | ||
fill_in "Day", with: @child.date_of_birth.day | ||
fill_in "Month", with: @child.date_of_birth.month | ||
fill_in "Year", with: @child.date_of_birth.year | ||
click_on "Continue" | ||
end | ||
|
||
def when_i_do_not_confirm_they_attend_the_pilot_school | ||
choose "No, they go to a different school" | ||
click_on "Continue" | ||
end | ||
|
||
def then_i_see_a_page_asking_for_the_childs_school | ||
expect(page).to have_heading("What school does your child go to?") | ||
end | ||
|
||
def when_i_click_continue | ||
click_on "Continue" | ||
end | ||
|
||
def then_i_see_an_error | ||
expect(page).to have_heading "There is a problem" | ||
end | ||
|
||
def when_i_choose_a_school | ||
select "Pilot School" | ||
click_on "Continue" | ||
end | ||
|
||
def then_i_see_the_parent_step | ||
expect(page).to have_heading "About you" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters