diff --git a/lung_cancer_screening/core/tests/acceptance/helpers/user_interaction_helpers.py b/lung_cancer_screening/core/tests/acceptance/helpers/user_interaction_helpers.py index 86beaceb..1bf7b468 100644 --- a/lung_cancer_screening/core/tests/acceptance/helpers/user_interaction_helpers.py +++ b/lung_cancer_screening/core/tests/acceptance/helpers/user_interaction_helpers.py @@ -76,3 +76,11 @@ def fill_in_and_submit_ethnicity(page, ethnicity): page.get_by_label(ethnicity, exact=True).check() page.click("text=Continue") + +def fill_in_and_submit_asbestos_exposure(page, answer): + expect(page.locator("legend")).to_have_text( + "Have you ever worked in a job where you might have been exposed to asbestos?") + + page.get_by_label(answer, exact=True).check() + + page.click("text=Continue") diff --git a/lung_cancer_screening/core/tests/acceptance/test_cannot_change_answers_after_submission.py b/lung_cancer_screening/core/tests/acceptance/test_cannot_change_answers_after_submission.py index 01493b3e..b91d0224 100644 --- a/lung_cancer_screening/core/tests/acceptance/test_cannot_change_answers_after_submission.py +++ b/lung_cancer_screening/core/tests/acceptance/test_cannot_change_answers_after_submission.py @@ -12,7 +12,8 @@ fill_in_and_submit_date_of_birth, fill_in_and_submit_sex_at_birth, fill_in_and_submit_gender, - fill_in_and_submit_ethnicity + fill_in_and_submit_ethnicity, + fill_in_and_submit_asbestos_exposure ) class TestQuestionnaire(StaticLiveServerTestCase): @@ -46,6 +47,7 @@ def test_cannot_change_responses_once_checked_and_submitted(self): fill_in_and_submit_sex_at_birth(page, "Male") fill_in_and_submit_gender(page, "Male") fill_in_and_submit_ethnicity(page, "White") + fill_in_and_submit_asbestos_exposure(page, "No") page.click("text=Submit") diff --git a/lung_cancer_screening/core/tests/acceptance/test_questionnaire.py b/lung_cancer_screening/core/tests/acceptance/test_questionnaire.py index b26c10f0..bef1e1bb 100644 --- a/lung_cancer_screening/core/tests/acceptance/test_questionnaire.py +++ b/lung_cancer_screening/core/tests/acceptance/test_questionnaire.py @@ -14,7 +14,8 @@ fill_in_and_submit_weight_imperial, fill_in_and_submit_sex_at_birth, fill_in_and_submit_gender, - fill_in_and_submit_ethnicity + fill_in_and_submit_ethnicity, + fill_in_and_submit_asbestos_exposure ) from .helpers.assertion_helpers import expect_back_link_to_have_url @@ -90,9 +91,14 @@ def test_full_questionnaire_user_journey(self): fill_in_and_submit_ethnicity(page, "White") - expect(page).to_have_url(f"{self.live_server_url}/responses") + expect(page).to_have_url(f"{self.live_server_url}/asbestos-exposure") expect_back_link_to_have_url(page, "/ethnicity") + fill_in_and_submit_asbestos_exposure(page, "No") + + expect(page).to_have_url(f"{self.live_server_url}/responses") + expect_back_link_to_have_url(page, "/asbestos-exposure") + responses = page.locator(".responses") expect(responses).to_contain_text("Have you ever smoked? Yes, I used to smoke regularly") expect(responses).to_contain_text( @@ -102,6 +108,7 @@ def test_full_questionnaire_user_journey(self): expect(responses).to_contain_text("What was your sex at birth? Male") expect(responses).to_contain_text("Which of these best describes you? Male") expect(responses).to_contain_text("What is your ethnic background? White") + expect(responses).to_contain_text("Have you ever worked in a job where you might have been exposed to asbestos? No") page.click("text=Submit") diff --git a/lung_cancer_screening/questions/forms/asbestos_exposure_form.py b/lung_cancer_screening/questions/forms/asbestos_exposure_form.py new file mode 100644 index 00000000..80f27e28 --- /dev/null +++ b/lung_cancer_screening/questions/forms/asbestos_exposure_form.py @@ -0,0 +1,25 @@ +from django import forms +from ...nhsuk_forms.typed_choice_field import TypedChoiceField +from ..models.response_set import ResponseSet + + +class AsbestosExposureForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + self.participant = kwargs.pop('participant') + super().__init__(*args, **kwargs) + self.instance.participant = self.participant + + self.fields["asbestos_exposure"] = TypedChoiceField( + choices=[(True, 'Yes'), (False, 'No')], + widget=forms.RadioSelect, + label="Have you ever worked in a job where you might have been exposed to asbestos?", + label_classes="nhsuk-fieldset__legend--m", + coerce=lambda x: x == 'True', + error_messages={ + 'required': 'Select if you have been exposed to asbestos.' + } + ) + + class Meta: + model = ResponseSet + fields = ['asbestos_exposure'] diff --git a/lung_cancer_screening/questions/jinja2/asbestos_exposure.jinja b/lung_cancer_screening/questions/jinja2/asbestos_exposure.jinja new file mode 100644 index 00000000..25e3a84c --- /dev/null +++ b/lung_cancer_screening/questions/jinja2/asbestos_exposure.jinja @@ -0,0 +1,61 @@ +{% extends 'layout.jinja' %} +{% from 'nhsuk/components/button/macro.jinja' import button %} +{% from 'nhsuk/components/back-link/macro.jinja' import backLink %} +{% from 'nhsuk/components/details/macro.jinja' import details %} + +{% block beforeContent %} + {{ + backLink({ + "href": url("questions:ethnicity"), + "text": "Back" + }) + }} +{% endblock beforeContent %} + +{% block page_content %} +
You may have been exposed to asbestos if you worked in an industry such as building or construction, particularly from the 1950s to the 1990s.
+ +You could be exposed to asbestos today if your job involves working in certain roles in old buildings.
+ +Examples include:
+You may have come into contact with asbestos from existing asbestos-containing materials in buildings and products. If they are intact or undamaged, they pose very little risk.
+ + {{ + details({ + "summaryText": "What is asbestos?", + "html": "Asbestos was used in a number of building materials and products. For example:
+If you worked in an industry such as building or construction you are more likely to have come into contact with damaged asbestos materials and products.
" + }) + }} + + +