Skip to content

Commit 80c8a2f

Browse files
authored
Merge pull request #215 from NHSDigital/PPHA-482-check-if-you-need-appointment-page
PPHA-482: Check if you need an appointment page
2 parents 1d20575 + 77e9d54 commit 80c8a2f

25 files changed

Lines changed: 529 additions & 39 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ lung_cancer_screening/assets/compiled/*
2121
.devcontainer/ca.crt
2222
tests/TEST-*.xml
2323
node_modules
24+
screenshots
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@CheckNeedAppointment
2+
Feature: Check if you need an appointment page
3+
Scenario: The page is accessible
4+
Given I am logged in
5+
When I go to "/check-if-you-need-an-appointment"
6+
Then there are no accessibility violations
7+
8+
Scenario: Form errors
9+
Given I am logged in
10+
When I go to "/check-if-you-need-an-appointment"
11+
And I click "Continue"
12+
Then I am on "/check-if-you-need-an-appointment"
13+
And I see a form error "Select if you can continue online"
14+
And there are no accessibility violations
15+
16+
Scenario: Eligibility exit if needs face to face appointment
17+
Given I am logged in
18+
When I go to "/check-if-you-need-an-appointment"
19+
Then I see a back link to "/date-of-birth"
20+
When I check "Yes, one or more of these things applies to me and I need a face-to-face appointment" and submit
21+
Then I am on "/call-us-to-book-an-appointment"
22+
23+
Scenario: Navigating backwards and forwards
24+
Given I am logged in
25+
When I go to "/check-if-you-need-an-appointment"
26+
Then I see a back link to "/date-of-birth"
27+
When I check "No, I can continue online" and submit
28+
Then I am on "/height"
29+
30+

features/date_of_birth_page.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ Feature: Date of birth page
3434
When I go to "/date-of-birth"
3535
Then I see a back link to "/have-you-ever-smoked"
3636
When I fill in and submit my date of birth as 55 years ago
37-
Then I am on "/height"
37+
Then I am on "/check-if-you-need-an-appointment"

features/environment.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
behave-django handles test database setup automatically.
44
We just need to add live server and Playwright setup.
55
"""
6+
from datetime import datetime
67
import os
78
from django.contrib.staticfiles.testing import StaticLiveServerTestCase # noqa: E402
89
from playwright.sync_api import sync_playwright # noqa: E402
@@ -63,3 +64,8 @@ def after_scenario(context, _scenario):
6364
del context.page
6465

6566
# behave-django automatically rolls back database transactions
67+
68+
def after_step(context, step):
69+
if step.status == "failed":
70+
print(f"Error on step: {step.name}")
71+
context.page.screenshot(full_page=True, path=f"screenshots/{datetime.now()}-screenshot.png")

features/height.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Feature: Height page
4040
Scenario: Navigating backwards and forwards
4141
Given I am logged in
4242
When I go to "/height"
43-
Then I see a back link to "/date-of-birth"
43+
Then I see a back link to "/check-if-you-need-an-appointment"
4444
When I fill in and submit my height with "170"
4545
Then I am on "/weight"
4646
When I click "Back"

features/questionnaire.feature

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,23 @@ Feature: Questionnaire
33
Given I am logged in
44
And I have already submitted my responses
55
When I go to "/start"
6-
And I click "Start"
6+
And I click "Start now"
77
Then I am on "/start"
88

99
Scenario: The user can complete the full questionnaire
1010
Given I am logged in
1111
When I go to "/start"
12-
And I click "Start"
12+
And I click "Start now"
1313

1414
Then I am on "/have-you-ever-smoked"
1515
When I fill in and submit my smoking status with "Yes, I used to smoke"
1616

1717
Then I am on "/date-of-birth"
1818
When I fill in and submit my date of birth as 55 years ago
1919

20+
Then I am on "/check-if-you-need-an-appointment"
21+
When I check "No, I can continue online" and submit
22+
2023
Then I am on "/height"
2124
When I click "Switch to feet and inches"
2225
And I fill in and submit my height with "5" feet and "7" inches

features/steps/form_steps.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
from datetime import datetime
33
from dateutil.relativedelta import relativedelta
44

5+
from features.steps.navigation_steps import when_i_click
6+
7+
@when('I check "{value}" and submit')
8+
def when_i_check_value_and_submit(context, value):
9+
context.page.get_by_label(value, exact=True).check()
10+
when_i_submit_the_form(context)
11+
12+
@when("I take a screenshot")
13+
@when("I take a screenshot {value}")
14+
def screenshot(context, value=""):
15+
context.page.screenshot(full_page=True, path=f"screenshots/{datetime.now()}-{value}-screenshot.png")
516

617
@when('I fill in and submit my smoking status with "{smoking_status}"')
718
def when_i_fill_in_and_submit_my_smoking_status(context, smoking_status):
@@ -91,4 +102,4 @@ def when_i_fill_in_and_submit_my_cancer_diagnosis(context, relatives_age_when_di
91102

92103
@when('I submit the form')
93104
def when_i_submit_the_form(context):
94-
context.page.click("text=Continue")
105+
when_i_click(context, "Continue")

features/steps/navigation_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def given_i_go_to(context, path):
88

99
@when('I click "{text}"')
1010
def when_i_click(context, text):
11-
context.page.click(f"text={text}")
11+
context.page.get_by_text(text, exact=True).click()
1212

1313
@then('I am on "{path}"')
1414
def then_i_am_on(context, path):
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from django import forms
2+
from ...nhsuk_forms.typed_choice_field import TypedChoiceField
3+
from ..models.check_need_appointment_response import CheckNeedAppointmentResponse
4+
5+
6+
class CheckNeedAppointmentForm(forms.ModelForm):
7+
def __init__(self, *args, **kwargs):
8+
super().__init__(*args, **kwargs)
9+
10+
self.fields["value"] = TypedChoiceField(
11+
choices=[
12+
(True, 'Yes, one or more of these things applies to me and I need a face-to-face appointment'),
13+
(False, 'No, I can continue online')
14+
],
15+
widget=forms.RadioSelect,
16+
label="Do you need to leave the online service and ask for a face-to-face appointment?",
17+
label_classes="nhsuk-fieldset__legend--m",
18+
coerce=do_coerce,
19+
error_messages={
20+
'required': 'Select if you can continue online'
21+
}
22+
)
23+
24+
class Meta:
25+
model = CheckNeedAppointmentResponse
26+
fields = ['value']
27+
28+
def do_coerce(value) :
29+
return value == "True"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{% extends 'layout.jinja' %}
2+
{% from 'nhsuk/components/back-link/macro.jinja' import backLink %}
3+
4+
{% block beforeContent %}
5+
<nav>
6+
{{
7+
backLink({
8+
"href": url("questions:check_need_appointment"),
9+
"text": "Back"
10+
})
11+
}}
12+
</nav>
13+
{% endblock beforeContent %}
14+
15+
{% block content %}
16+
<div class="nhsuk-grid-row">
17+
<div class="nhsuk-grid-column-two-thirds">
18+
<h1 class="nhsuk-heading-l">Call us to book an appointment</h1>
19+
20+
<p>A healthcare professional will check if you need a lung scan at your appointment.</p>
21+
<p>They will take your height and weight measurements to calculate your body mass index (BMI).</p>
22+
<p>Call us on 020 0000 0000 to book an appointment. If we do not hear from you in 2 weeks we will call you.</p>
23+
24+
{% include '_speak_to_a_gp_if.jinja' %}
25+
</div>
26+
</div>
27+
{% endblock %}

0 commit comments

Comments
 (0)