Skip to content

Commit

Permalink
GH-182: Use simple question page for change spend to date
Browse files Browse the repository at this point in the history
  • Loading branch information
markhobson committed Jan 31, 2025
1 parent 6008f20 commit ec6d01b
Showing 4 changed files with 29 additions and 28 deletions.
35 changes: 19 additions & 16 deletions schemes/views/templates/scheme/spend_to_date.html
Original file line number Diff line number Diff line change
@@ -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 %}

<h1 class="govuk-heading-l">
<span class="govuk-caption-l">{{ name }}</span>
<span>Change spend to date</span>
</h1>

<p class="govuk-body">
This scheme has {% if funding_allocation -%}
{{ funding_allocation | pounds }} of
{%- else -%}
no
{%- endif %} funding allocation.
</p>

<form method="post" action="{{ url_for('schemes.spend_to_date', scheme_id=id) }}" novalidate aria-label="Change spend to date">
<form method="post" action="{{ url_for('schemes.spend_to_date', scheme_id=id) }}" novalidate aria-label="How much has been spent to date?">
{{ form.csrf_token }}

{% set labelHtml %}
<span class="govuk-caption-l">{{ name }}</span>
<span>How much has been spent to date?</span>
{% 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": "£"
2 changes: 1 addition & 1 deletion tests/e2e/test_scheme_funding.py
Original file line number Diff line number Diff line change
@@ -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 (
10 changes: 4 additions & 6 deletions tests/integration/pages.py
Original file line number Diff line number Diff line change
@@ -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"]

10 changes: 5 additions & 5 deletions tests/integration/test_scheme_funding.py
Original file line number Diff line number Diff line change
@@ -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 (

0 comments on commit ec6d01b

Please sign in to comment.