From ec6d01b53f192bfe8f83a565f0ba231f82f4e272 Mon Sep 17 00:00:00 2001 From: Mark Hobson Date: Tue, 28 Jan 2025 17:42:59 +0000 Subject: [PATCH] GH-182: Use simple question page for change spend to date --- .../views/templates/scheme/spend_to_date.html | 35 ++++++++++--------- tests/e2e/test_scheme_funding.py | 2 +- tests/integration/pages.py | 10 +++--- tests/integration/test_scheme_funding.py | 10 +++--- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/schemes/views/templates/scheme/spend_to_date.html b/schemes/views/templates/scheme/spend_to_date.html index a93d3a0e..d250be64 100644 --- a/schemes/views/templates/scheme/spend_to_date.html +++ b/schemes/views/templates/scheme/spend_to_date.html @@ -6,7 +6,7 @@ {% from "govuk_frontend_jinja/components/notification-banner/macro.html" import govukNotificationBanner %} {% block pageTitle -%} - {% if form.errors %}Error: {% endif %}Change spend to date - {{ super() }} + {% if form.errors %}Error: {% endif %}How much has been spent to date? - {{ super() }} {%- endblock %} {% block beforeContent %} @@ -31,25 +31,28 @@ {% endif %} {% endwith %} -

- {{ name }} - Change spend to date -

- -

- This scheme has {% if funding_allocation -%} - {{ funding_allocation | pounds }} of - {%- else -%} - no - {%- endif %} funding allocation. -

- -
+ {{ form.csrf_token }} + {% set labelHtml %} + {{ name }} + How much has been spent to date? + {% endset %} + {% set hint %} + This scheme has {% if funding_allocation -%} + {{ funding_allocation | pounds }} of + {%- else -%} + no + {%- endif %} funding allocation + {% endset %} {{ form.amount(params={ "label": { - "text": "How much has been spent to date?" + "classes": "govuk-label--l", + "html": labelHtml, + "isPageHeading": true + }, + "hint": { + "text": hint }, "prefix": { "text": "£" diff --git a/tests/e2e/test_scheme_funding.py b/tests/e2e/test_scheme_funding.py index eb059427..ac251513 100644 --- a/tests/e2e/test_scheme_funding.py +++ b/tests/e2e/test_scheme_funding.py @@ -156,7 +156,7 @@ def test_cannot_change_spend_to_date_when_error(app_client: AppClient, oidc_clie assert ( change_spend_to_date_page.title - == "Error: Change spend to date - Update your capital schemes - Active Travel England - GOV.UK" + == "Error: How much has been spent to date? - Update your capital schemes - Active Travel England - GOV.UK" ) assert list(change_spend_to_date_page.errors) == ["Enter spend to date"] assert ( diff --git a/tests/integration/pages.py b/tests/integration/pages.py index 0fcb049f..f36dc328 100644 --- a/tests/integration/pages.py +++ b/tests/integration/pages.py @@ -377,17 +377,13 @@ def __init__(self, response: TestResponse): self.errors = ErrorSummaryComponent(alert) if alert else None self.important_notification = NotificationBannerComponent.for_important(self._soup) heading_tag = self._soup.select_one("main h1") - self.heading = HeadingComponent(heading_tag) if heading_tag else None - self.is_visible = self.heading.text == "Change spend to date" if self.heading else False + heading = HeadingComponent(heading_tag) if heading_tag else None + self.is_visible = heading.text == "How much has been spent to date?" if heading else False @property def back_url(self) -> str: return str(one(self._soup.select("a.govuk-back-link"))["href"]) - @property - def funding_summary(self) -> str: - return (one(self._soup.select("main h1 ~ p")).string or "").strip() - @property def form(self) -> ChangeSpendToDateFormComponent: return ChangeSpendToDateFormComponent(one(self._soup.select("form"))) @@ -469,6 +465,8 @@ class ChangeSpendToDateFormComponent: def __init__(self, form: Tag): self._form = form self.confirm_url = form["action"] + self.heading = HeadingComponent(one(self._form.select("h1"))) + self.funding_summary = (one(self._form.select(".govuk-hint")).string or "").strip() self.amount = TextComponent(one(form.select("input[name='amount']"))) self.cancel_url = one(self._form.select("a"))["href"] diff --git a/tests/integration/test_scheme_funding.py b/tests/integration/test_scheme_funding.py index 7d149134..d4cd9bc0 100644 --- a/tests/integration/test_scheme_funding.py +++ b/tests/integration/test_scheme_funding.py @@ -107,7 +107,7 @@ def test_spend_to_date_form_shows_title(self, schemes: SchemeRepository, client: assert ( change_spend_to_date_page.title - == "Change spend to date - Update your capital schemes - Active Travel England - GOV.UK" + == "How much has been spent to date? - Update your capital schemes - Active Travel England - GOV.UK" ) def test_spend_to_date_form_shows_back(self, schemes: SchemeRepository, client: FlaskClient) -> None: @@ -122,7 +122,7 @@ def test_spend_to_date_form_shows_scheme(self, schemes: SchemeRepository, client change_spend_to_date_page = ChangeSpendToDatePage.open(client, id_=1) - assert change_spend_to_date_page.heading and change_spend_to_date_page.heading.caption == "Wirral Package" + assert change_spend_to_date_page.form.heading.caption == "Wirral Package" def test_spend_to_date_form_shows_funding_summary(self, schemes: SchemeRepository, client: FlaskClient) -> None: scheme = build_scheme(id_=1, reference="ATE00001", name="Wirral Package", authority_id=1) @@ -139,7 +139,7 @@ def test_spend_to_date_form_shows_funding_summary(self, schemes: SchemeRepositor change_spend_to_date_page = ChangeSpendToDatePage.open(client, id_=1) - assert change_spend_to_date_page.funding_summary == "This scheme has £100,000 of funding allocation." + assert change_spend_to_date_page.form.funding_summary == "This scheme has £100,000 of funding allocation" def test_spend_to_date_form_shows_minimal_funding_summary( self, schemes: SchemeRepository, client: FlaskClient @@ -148,7 +148,7 @@ def test_spend_to_date_form_shows_minimal_funding_summary( change_spend_to_date_page = ChangeSpendToDatePage.open(client, id_=1) - assert change_spend_to_date_page.funding_summary == "This scheme has no funding allocation." + assert change_spend_to_date_page.form.funding_summary == "This scheme has no funding allocation" def test_spend_to_date_form_shows_amount(self, schemes: SchemeRepository, client: FlaskClient) -> None: scheme = build_scheme(id_=1, reference="ATE00001", name="Wirral Package", authority_id=1) @@ -317,7 +317,7 @@ def test_cannot_spend_to_date_when_error( assert ( change_spend_to_date_page.title - == "Error: Change spend to date - Update your capital schemes - Active Travel England - GOV.UK" + == "Error: How much has been spent to date? - Update your capital schemes - Active Travel England - GOV.UK" ) assert change_spend_to_date_page.errors and list(change_spend_to_date_page.errors) == ["Enter spend to date"] assert (