Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lung_cancer_screening/assets/sass/components/_button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.app-button--link {
@include nhsuk-link-style-default;

& {
display: inline;
align-items: normal;
text-align: left;
font-size: inherit;
-webkit-appearance: none;
appearance: none;
background-color: transparent;
border: none;
cursor: pointer;
text-decoration: underline;
padding: 0;
}
}

.nhsuk-form-group .app-button--link {
display: block;
}
3 changes: 3 additions & 0 deletions lung_cancer_screening/assets/sass/main.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// Import NHS.UK frontend library
@import "nhsuk-frontend/packages/nhsuk";

// Components that are not in the NHS.UK frontend library
// @import "components/button";
5 changes: 0 additions & 5 deletions lung_cancer_screening/core/jinja2/home/index.jinja

This file was deleted.

23 changes: 0 additions & 23 deletions lung_cancer_screening/core/tests/acceptance/test_homepage.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from playwright.sync_api import sync_playwright, expect


class TestParticipantNotSmoker(StaticLiveServerTestCase):

@classmethod
def setUpClass(cls):
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
super().setUpClass()
cls.playwright = sync_playwright().start()
cls.browser = cls.playwright.chromium.launch()

@classmethod
def tearDownClass(cls):
super().tearDownClass()
cls.browser.close()
cls.playwright.stop()

def test_participant_not_smoker(self):
participant_id = '123'

page = self.browser.new_page()
page.goto(f"{self.live_server_url}/start")

page.fill("input[name='participant_id']", participant_id)

page.click('text=Start now')

expect(page).to_have_url(f"{self.live_server_url}/have-you-ever-smoked")

expect(page.locator("legend")).to_have_text(
"Have you ever smoked?")

page.get_by_label('No').check()

page.click("text=Continue")

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

expect(page.locator(".title")).to_have_text(
"You do not need an NHS lung health check")
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from playwright.sync_api import sync_playwright, expect
from datetime import datetime
from dateutil.relativedelta import relativedelta


class TestParticipantOutOfAgeRange(StaticLiveServerTestCase):

@classmethod
def setUpClass(cls):
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
super().setUpClass()
cls.playwright = sync_playwright().start()
cls.browser = cls.playwright.chromium.launch()

@classmethod
def tearDownClass(cls):
super().tearDownClass()
cls.browser.close()
cls.playwright.stop()

def test_participant_out_of_age_range(self):
participant_id = '123'

page = self.browser.new_page()
page.goto(f"{self.live_server_url}/start")

page.fill("input[name='participant_id']", participant_id)

page.click('text=Start now')

expect(page).to_have_url(
f"{self.live_server_url}/have-you-ever-smoked")

expect(page.locator("legend")).to_have_text(
"Have you ever smoked?")

page.get_by_label('Yes').check()

page.click("text=Continue")

expect(page).to_have_url(f"{self.live_server_url}/date-of-birth")

expect(page.locator("legend")).to_have_text(
"What is your date of birth?")

age = datetime.now() - relativedelta(years=20)

page.fill("input[name='day']", str(age.day))
page.fill("input[name='month']", str(age.month))
page.fill("input[name='year']", str(age.year))

page.click("text=Continue")

expect(page).to_have_url(f"{self.live_server_url}/age-range-exit")

expect(page.locator(".title")).to_have_text(
"You do not need an NHS lung health check")
59 changes: 59 additions & 0 deletions lung_cancer_screening/core/tests/acceptance/test_questionnaire.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from playwright.sync_api import sync_playwright, expect
from datetime import datetime
from dateutil.relativedelta import relativedelta

class TestQuestionnaire(StaticLiveServerTestCase):

@classmethod
def setUpClass(cls):
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
super().setUpClass()
cls.playwright = sync_playwright().start()
cls.browser = cls.playwright.chromium.launch()

@classmethod
def tearDownClass(cls):
super().tearDownClass()
cls.browser.close()
cls.playwright.stop()

def test_full_questionaire_user_journey(self):
participant_id = '123'

page = self.browser.new_page()
page.goto(f"{self.live_server_url}/start")

page.fill("input[name='participant_id']", participant_id)

page.click('text=Start now')

expect(page).to_have_url(
f"{self.live_server_url}/have-you-ever-smoked")

expect(page.locator("legend")).to_have_text(
"Have you ever smoked?")

page.get_by_label('Yes').check()

page.click("text=Continue")

expect(page).to_have_url(f"{self.live_server_url}/date-of-birth")

expect(page.locator("legend")).to_have_text(
"What is your date of birth?")

age = datetime.now() - relativedelta(years=55)

page.fill("input[name='day']", str(age.day))
page.fill("input[name='month']", str(age.month))
page.fill("input[name='year']", str(age.year))

page.click("text=Continue")

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

expect(page.locator(".responses")).to_contain_text(
age.strftime("Have you ever smoked? True"))
expect(page.locator(".responses")).to_contain_text(age.strftime("What is your date of birth? %Y-%m-%d"))
Empty file.
13 changes: 13 additions & 0 deletions lung_cancer_screening/questions/jinja2/age_range_exit.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends 'layout.jinja' %}
{% from 'button/macro.jinja' import button %}
{% from 'input/macro.jinja' import input %}

{% block content %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<h2 class="title">You do not need an NHS lung health check</h2>

<p>The NHS lung health check is for people between the ages of 55 and 74.</p>
</div>
</div>
{% endblock %}
47 changes: 47 additions & 0 deletions lung_cancer_screening/questions/jinja2/date_of_birth.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends 'layout.jinja' %}

{% from 'date-input/macro.jinja' import dateInput %}
{% from 'button/macro.jinja' import button %}

{% block content %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<form action="{{ request.path }}" method="POST">
{{ csrf_input }}

{{ dateInput({
"fieldset": {
"legend": {
"text": "What is your date of birth?",
"classes": "nhsuk-label--l",
"isPageHeading": true
}
},
"hint": {
"text": "For example, 15 3 1984"
},
"items": [
{
"name": "day",
"classes": "nhsuk-input--width-2"
},
{
"name": "month",
"classes": "nhsuk-input--width-2"
},
{
"name": "year",
"classes": "nhsuk-input--width-4"
}
]
}) }}

<input type="hidden" name="participant_id" value="{{ participant_id }}">

{{ button({
"text": "Continue"
}) }}
</form>
</div>
</div>
{% endblock %}
40 changes: 40 additions & 0 deletions lung_cancer_screening/questions/jinja2/have_you_ever_smoked.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends 'layout.jinja' %}
{% from 'button/macro.jinja' import button %}
{% from 'radios/macro.jinja' import radios %}

{% block content %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<form action="{{ request.path }}" method="POST">
{{ csrf_input }}

{{ radios({
"name": "value",
"fieldset": {
"legend": {
"text": "Have you ever smoked?",
"classes": "nhsuk-fieldset__legend--l",
"isPageHeading": true
}
},
"items": [
{
"value": "1",
"text": "Yes"
},
{
"value": "0",
"text": "No"
}
]
}) }}

<input type="hidden" name="participant_id" value="{{ participant_id }}">

{{ button({
"text": "Continue"
}) }}
</form>
</div>
</div>
{% endblock %}
13 changes: 13 additions & 0 deletions lung_cancer_screening/questions/jinja2/non_smoker_exit.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends 'layout.jinja' %}
{% from 'button/macro.jinja' import button %}
{% from 'input/macro.jinja' import input %}

{% block content %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<h2 class="title">You do not need an NHS lung health check</h2>

<p>The NHS lung health check is for people who have smoked or are current smokers.</p>
</div>
</div>
{% endblock %}
15 changes: 15 additions & 0 deletions lung_cancer_screening/questions/jinja2/responses.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends 'layout.jinja' %}


{% block content %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<h1 class="nhsuk-heading-l">Responses</h1>
<ul class="responses">
{% for response in responses %}
<li>{{ response.question }} {{ response.value }}</li>
{% endfor %}
</ul>
</div>
</div>
{% endblock %}
25 changes: 25 additions & 0 deletions lung_cancer_screening/questions/jinja2/start.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% extends 'layout.jinja' %}
{% from 'button/macro.jinja' import button %}
{% from 'input/macro.jinja' import input %}

{% block content %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<form action="{{ request.path }}" method="POST">
{{ csrf_input }}

{{ input({
"label": {
"text": "Enter your unique participant ID"
},
"id": "participant_id",
"name": "participant_id"
}) }}

{{ button({
"text": "Start now"
}) }}
</form>
</div>
</div>
{% endblock %}
Loading
Loading