Skip to content

Commit 914d989

Browse files
committed
PPHA-262: Height form created and implemented
1 parent d6ba914 commit 914d989

File tree

18 files changed

+92
-53
lines changed

18 files changed

+92
-53
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ __pycache__
1717
lung_cancer_screening/assets/compiled/*
1818
!lung_cancer_screening/assets/compiled/.gitkeep
1919
.DS_Store
20+
.venv

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file is for you! Please, updated to the versions agreed by your team.
22

3+
python 3.13.8
34
terraform 1.7.0
45
pre-commit 4.3.0
56
vale 3.6.0

.vscode/settings.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@
66
},
77
"cSpell.words": [
88
"dateutil",
9+
"endcall",
10+
"endset",
11+
"fieldset",
12+
"gunicorn",
13+
"jinja",
14+
"makemigrations",
915
"nhsuk",
16+
"novalidate",
17+
"psycopg",
1018
"relativedelta",
1119
"responseset",
12-
"unsubmitted"
20+
"stylesheet",
21+
"toplevel",
22+
"unsubmitted",
23+
"whitenoise"
1324
]
1425
}

lung_cancer_screening/core/form_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def __init__(self, form: forms.Form, field: "ChoiceField", name: str):
252252
def add_conditional_html(self, value, html):
253253
if isinstance(self.field.widget, widgets.Select):
254254
raise ValueError(
255-
"select comonent does not support conditional fields")
255+
"select component does not support conditional fields")
256256

257257
self._conditional_html[value] = html
258258

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{% from "nhsuk/components/input/macro.jinja" import input %}
2+
{% set unbound_field = field.field %}
3+
{% set widget = unbound_field.widget %}
4+
{% if unbound_field.visually_hidden_label_suffix %}
5+
{% set label_html %}
6+
{{ field.label }}<span class="nhsuk-u-visually-hidden">: {{ unbound_field.visually_hidden_label_suffix }}</span>
7+
{% endset %}
8+
{% endif %}
9+
{% set input_params = {
10+
"label": {
11+
"text": field.label,
12+
"html": label_html if label_html,
13+
"classes": unbound_field.label_classes if unbound_field.label_classes
14+
},
15+
"hint": {
16+
"text": unbound_field.hint
17+
} if unbound_field.hint,
18+
"id": field.auto_id,
19+
"name": field.html_name,
20+
"value": field.value() or "",
21+
"classes": unbound_field.classes if unbound_field.classes,
22+
"attributes": widget.attrs,
23+
"type": widget.input_type
24+
} %}
25+
{% if field.errors %}
26+
{% set error_params = {
27+
"errorMessage": {
28+
"text": field.errors | first
29+
}
30+
} %}
31+
{% set input_params = dict(input_params, **error_params) %}
32+
{% endif %}
33+
34+
{{ input(input_params) }}

lung_cancer_screening/core/tests/acceptance/helpers/user_interaction_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def fill_in_and_submit_participant_id(page, participant_id):
55
page.click('text=Start now')
66

77

8-
def fill_in_and_submit_smoking_elligibility(page, smoking_status):
8+
def fill_in_and_submit_smoking_eligibility(page, smoking_status):
99
expect(page.locator("legend")).to_have_text(
1010
"Have you ever smoked?")
1111

@@ -26,6 +26,6 @@ def fill_in_and_submit_date_of_birth(page, age):
2626
def fill_in_and_submit_height(page, height):
2727
expect(page.locator("h1")).to_have_text("What is your height?")
2828

29-
page.get_by_label("Centimeter").fill(str(height))
29+
page.get_by_label("Centimetre").fill(str(height))
3030

3131
page.click("text=Continue")

lung_cancer_screening/core/tests/acceptance/test_cannot_change_answers_after_submission.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from dateutil.relativedelta import relativedelta
66

77
from .helpers.user_interaction_helpers import (
8+
fill_in_and_submit_height,
89
fill_in_and_submit_participant_id,
9-
fill_in_and_submit_smoking_elligibility,
10+
fill_in_and_submit_smoking_eligibility,
1011
fill_in_and_submit_date_of_birth
1112
)
1213

@@ -35,8 +36,9 @@ def test_cannot_change_responses_once_checked_and_submitted(self):
3536
page.goto(f"{self.live_server_url}/start")
3637

3738
fill_in_and_submit_participant_id(page, participant_id)
38-
fill_in_and_submit_smoking_elligibility(page, smoking_status)
39+
fill_in_and_submit_smoking_eligibility(page, smoking_status)
3940
fill_in_and_submit_date_of_birth(page, age)
41+
fill_in_and_submit_height(page, "170")
4042

4143
page.click("text=Submit")
4244

lung_cancer_screening/core/tests/acceptance/test_participant_not_smoker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from .helpers.user_interaction_helpers import (
77
fill_in_and_submit_participant_id,
8-
fill_in_and_submit_smoking_elligibility
8+
fill_in_and_submit_smoking_eligibility
99
)
1010

1111

@@ -31,7 +31,7 @@ def test_participant_not_smoker(self):
3131
page.goto(f"{self.live_server_url}/start")
3232

3333
fill_in_and_submit_participant_id(page, participant_id)
34-
fill_in_and_submit_smoking_elligibility(page, 'No, I have never smoked')
34+
fill_in_and_submit_smoking_eligibility(page, 'No, I have never smoked')
3535

3636
expect(page).to_have_url(f"{self.live_server_url}/non-smoker-exit")
3737

lung_cancer_screening/core/tests/acceptance/test_participant_out_of_age_range.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from .helpers.user_interaction_helpers import (
88
fill_in_and_submit_participant_id,
9-
fill_in_and_submit_smoking_elligibility,
9+
fill_in_and_submit_smoking_eligibility,
1010
fill_in_and_submit_date_of_birth
1111
)
1212

@@ -33,7 +33,7 @@ def test_participant_out_of_age_range(self):
3333
page.goto(f"{self.live_server_url}/start")
3434

3535
fill_in_and_submit_participant_id(page, participant_id)
36-
fill_in_and_submit_smoking_elligibility(page, 'Yes, I used to smoke regularly')
36+
fill_in_and_submit_smoking_eligibility(page, 'Yes, I used to smoke regularly')
3737

3838
age = datetime.now() - relativedelta(years=20)
3939
fill_in_and_submit_date_of_birth(page, age)

lung_cancer_screening/core/tests/acceptance/test_questionnaire.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .helpers.user_interaction_helpers import (
88
fill_in_and_submit_height,
99
fill_in_and_submit_participant_id,
10-
fill_in_and_submit_smoking_elligibility,
10+
fill_in_and_submit_smoking_eligibility,
1111
fill_in_and_submit_date_of_birth
1212
)
1313

@@ -28,7 +28,7 @@ def tearDownClass(cls):
2828
cls.browser.close()
2929
cls.playwright.stop()
3030

31-
def test_full_questionaire_user_journey(self):
31+
def test_full_questionnaire_user_journey(self):
3232
participant_id = '123'
3333
smoking_status = 'Yes, I used to smoke regularly'
3434
age = datetime.now() - relativedelta(years=55)
@@ -42,7 +42,7 @@ def test_full_questionaire_user_journey(self):
4242
expect(page).to_have_url(
4343
f"{self.live_server_url}/have-you-ever-smoked")
4444

45-
fill_in_and_submit_smoking_elligibility(page, smoking_status)
45+
fill_in_and_submit_smoking_eligibility(page, smoking_status)
4646

4747
expect(page).to_have_url(f"{self.live_server_url}/date-of-birth")
4848
expect_back_link_to_have_url(page, "/have-you-ever-smoked")
@@ -55,11 +55,11 @@ def test_full_questionaire_user_journey(self):
5555

5656
expect(page).to_have_url(f"{self.live_server_url}/responses")
5757

58-
response = page.locator(".responses")
58+
responses = page.locator(".responses")
5959
expect(responses).to_contain_text("Have you ever smoked? Yes, I used to smoke regularly")
6060
expect(responses).to_contain_text(
6161
age.strftime("What is your date of birth? %Y-%m-%d"))
62-
expect(responses).to_contain_text(f"Height: {height}")
62+
expect(responses).to_contain_text(f"What is your height? {height}")
6363

6464
page.click("text=Submit")
6565

0 commit comments

Comments
 (0)