Skip to content

Commit

Permalink
GH-5: Show message when no schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
markhobson committed Nov 3, 2023
1 parent 2503c37 commit 6944003
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
49 changes: 26 additions & 23 deletions schemes/templates/schemes.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@
{% block content %}
<h1 class="govuk-heading-l">{{ authority_name }}</h1>

{% set rows = [] %}
{% for scheme in schemes %}
{% do rows.append([
{
"text": scheme.reference
},
{
"text": scheme.name
}
]) %}
{% endfor %}

{{ govukTable({
"head": [
{
"text": "Reference"
},
{
"text": "Name"
}
],
"rows": rows
}) }}
{% if schemes %}
{% set rows = [] %}
{% for scheme in schemes %}
{% do rows.append([
{
"text": scheme.reference
},
{
"text": scheme.name
}
]) %}
{% endfor %}
{{ govukTable({
"head": [
{
"text": "Reference"
},
{
"text": "Name"
}
],
"rows": rows
}) }}
{% else %}
<p class="govuk-body">There are no schemes for your authority to update.</p>
{% endif %}

{% endblock %}
10 changes: 7 additions & 3 deletions tests/integration/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ def authority(self) -> str | None:
return heading.string if heading else None

@property
def schemes(self) -> SchemesTableComponent:
def schemes(self) -> SchemesTableComponent | None:
table = self._soup.select_one("main table")
assert table
return SchemesTableComponent(table)
return SchemesTableComponent(table) if table else None

@property
def is_no_schemes_message_visible(self) -> bool:
paragraph = self._soup.select_one("main p")
return paragraph.string == "There are no schemes for your authority to update." if paragraph else False


class ServiceHeaderComponent:
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/test_schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,19 @@ def test_schemes_shows_schemes(schemes: SchemeRepository, client: FlaskClient) -

schemes_page = SchemesPage(client).open()

assert schemes_page.schemes
assert list(schemes_page.schemes) == [
{"reference": "ATE00001", "name": "Wirral Package"},
{"reference": "ATE00002", "name": "School Streets"},
]
assert not schemes_page.is_no_schemes_message_visible


def test_schemes_shows_message_when_no_schemes(client: FlaskClient) -> None:
schemes_page = SchemesPage(client).open()

assert not schemes_page.schemes
assert schemes_page.is_no_schemes_message_visible


class TestApiEnabled:
Expand Down

0 comments on commit 6944003

Please sign in to comment.