Skip to content

Commit 0211242

Browse files
committed
Test date of birth question structure
1 parent 3a22aad commit 0211242

34 files changed

+619
-40
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.app-button--link {
2+
@include nhsuk-link-style-default;
3+
4+
& {
5+
display: inline;
6+
align-items: normal;
7+
text-align: left;
8+
font-size: inherit;
9+
-webkit-appearance: none;
10+
appearance: none;
11+
background-color: transparent;
12+
border: none;
13+
cursor: pointer;
14+
text-decoration: underline;
15+
padding: 0;
16+
}
17+
}
18+
19+
.nhsuk-form-group .app-button--link {
20+
display: block;
21+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
// Import NHS.UK frontend library
22
@import "nhsuk-frontend/packages/nhsuk";
3+
4+
// Components that are not in the NHS.UK frontend library
5+
// @import "components/button";

lung_cancer_screening/core/jinja2/home/index.jinja

Lines changed: 0 additions & 5 deletions
This file was deleted.

lung_cancer_screening/core/tests/acceptance/test_homepage.py

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os
2+
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
3+
from playwright.sync_api import sync_playwright, expect
4+
5+
6+
class TestQuestionnaire(StaticLiveServerTestCase):
7+
8+
@classmethod
9+
def setUpClass(cls):
10+
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
11+
super().setUpClass()
12+
cls.playwright = sync_playwright().start()
13+
cls.browser = cls.playwright.chromium.launch()
14+
15+
@classmethod
16+
def tearDownClass(cls):
17+
super().tearDownClass()
18+
cls.browser.close()
19+
cls.playwright.stop()
20+
21+
def test_full_questionaire_user_journey(self):
22+
participant_id = '123'
23+
24+
page = self.browser.new_page()
25+
page.goto(f"{self.live_server_url}/start")
26+
27+
page.fill("input[name='participant_id']", participant_id)
28+
29+
page.click('text=Start now')
30+
31+
expect(page).to_have_url(f"{self.live_server_url}/date-of-birth")
32+
33+
expect(page.locator("legend")).to_have_text(
34+
"What is your date of birth?")
35+
36+
page.fill("input[name='day']", "8")
37+
page.fill("input[name='month']", "9")
38+
page.fill("input[name='year']", "2000")
39+
40+
page.click("text=Continue")
41+
42+
expect(page).to_have_url(f"{self.live_server_url}/responses")
43+
44+
expect(page.locator(".responses")).to_have_text("2000-09-08")

lung_cancer_screening/questions/__init__.py

Whitespace-only changes.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{% extends 'layout.jinja' %}
2+
3+
{% from 'date-input/macro.jinja' import dateInput %}
4+
{% from 'button/macro.jinja' import button %}
5+
6+
{% block content %}
7+
<div class="nhsuk-grid-row">
8+
<div class="nhsuk-grid-column-two-thirds">
9+
<form action="{{ request.path }}" method="POST">
10+
{{ csrf_input }}
11+
{{ dateInput({
12+
"fieldset": {
13+
"legend": {
14+
"text": "What is your date of birth?",
15+
"classes": "nhsuk-label--l",
16+
"isPageHeading": true
17+
}
18+
},
19+
"hint": {
20+
"text": "For example, 15 3 1984"
21+
},
22+
"items": [
23+
{
24+
"name": "day",
25+
"classes": "nhsuk-input--width-2"
26+
},
27+
{
28+
"name": "month",
29+
"classes": "nhsuk-input--width-2"
30+
},
31+
{
32+
"name": "year",
33+
"classes": "nhsuk-input--width-4"
34+
}
35+
]
36+
}) }}
37+
38+
<input type="hidden" name="participant_id" value="{{ participant_id }}">
39+
40+
{{ button({
41+
"text": "Continue"
42+
}) }}
43+
</form>
44+
</div>
45+
</div>
46+
{% endblock %}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% extends 'layout.jinja' %}
2+
3+
4+
{% block content %}
5+
<div class="nhsuk-grid-row">
6+
<div class="nhsuk-grid-column-two-thirds">
7+
<h1 class="nhsuk-heading-l">Responses</h1>
8+
<ul class="responses">
9+
{% for questionnaire_response in questionnaire_responses %}
10+
<li>{{ questionnaire_response.value }}</li>
11+
{% endfor %}
12+
</ul>
13+
</div>
14+
</div>
15+
{% endblock %}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{% extends 'layout.jinja' %}
2+
{% from 'button/macro.jinja' import button %}
3+
{% from 'input/macro.jinja' import input %}
4+
5+
{% block content %}
6+
<div class="nhsuk-grid-row">
7+
<div class="nhsuk-grid-column-two-thirds">
8+
<form action="{{ request.path }}" method="POST">
9+
{{ csrf_input }}
10+
11+
{{ input({
12+
"label": {
13+
"text": "Enter your unique participant ID"
14+
},
15+
"id": "participant_id",
16+
"name": "participant_id"
17+
}) }}
18+
19+
{{ button({
20+
"text": "Start now"
21+
}) }}
22+
</form>
23+
</div>
24+
</div>
25+
{% endblock %}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Generated by Django 5.2.4 on 2025-09-03 11:05
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
initial = True
10+
11+
dependencies = [
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='Participant',
17+
fields=[
18+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19+
('unique_id', models.CharField(max_length=255, unique=True)),
20+
('created_at', models.DateTimeField(auto_now_add=True)),
21+
('updated_at', models.DateTimeField(auto_now=True)),
22+
],
23+
),
24+
migrations.CreateModel(
25+
name='QuestionnaireResponse',
26+
fields=[
27+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
28+
('value', models.DateField()),
29+
('created_at', models.DateTimeField(auto_now_add=True)),
30+
('updated_at', models.DateTimeField(auto_now=True)),
31+
('participant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='questions.participant')),
32+
],
33+
),
34+
]

0 commit comments

Comments
 (0)