Skip to content

Commit

Permalink
LGA-3571: Referral page (#158)
Browse files Browse the repository at this point in the history
* Add next steps alternate help page

* Update unit and functional tests

* Temporarily enable staging deployment for demo

* Remove old referral page

* Add immigration and asylum article category name

* Revert "Remove old referral page"

This reverts commit acd3ca2.

* Add additional functionality tests

* Open ECF link in a new tab

* Remove staging deployment

* Update unit tests to assert correct immigration help organisations are called

* Update functional tests for new education category

* Add exceptional-case-funding component to reduce duplication

* Replace 2x br with margin bottom on the body
  • Loading branch information
BenMillar-MOJ authored Mar 3, 2025
1 parent c564d81 commit ddaeae9
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 34 deletions.
3 changes: 2 additions & 1 deletion app/categories/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def __str__(self):
description=_("Help if your child has SEND."),
article_category_name="Education",
chs_code="education",
code="education",
code="send",
children={
"child_young_person": Category(
title=_("Help with a child or young person's SEND"),
Expand Down Expand Up @@ -394,6 +394,7 @@ def __str__(self):
),
chs_code="immigration",
code="asylum_and_immigration",
article_category_name="Immigration and asylum",
children={
"apply": Category(
title=_("Applying for asylum"),
Expand Down
2 changes: 1 addition & 1 deletion app/categories/results/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"/next-steps",
view_func=NextStepsPage.as_view(
"next_steps",
get_help_organisations=True,
get_help_organisations=False,
),
)
8 changes: 4 additions & 4 deletions app/categories/results/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def get_context(self, category: Category = None):
else []
)
return {
"category_name": category.referrer_text
if isinstance(category, Category)
else None,
"category": category if isinstance(category, Category) else None,
"organisations": organisations,
"fala_category_code": get_fala_category_code(article_category_name),
}
Expand Down Expand Up @@ -79,5 +77,7 @@ def get_context(self, *args, **kwargs):
class NextStepsPage(OutOfScopePage):
template: str = "categories/next-steps.html"

def __init__(self, *args, **kwargs):
def __init__(self, *args, get_help_organisations: bool = True, **kwargs):
if get_help_organisations:
self.template = "categories/next-steps-alternate-help.html"
super().__init__(*args, self.template, **kwargs)
4 changes: 1 addition & 3 deletions app/templates/categories/cannot-find-problem.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">{{ title }}</h1>

<p class="govuk-body">If you cannot find your problem, it’s probably not covered by legal aid.</p>

<br>
<p class="govuk-body govuk-!-margin-bottom-9">If you cannot find your problem, it’s probably not covered by legal aid.</p>

{{ govukButton({
"text": _("Next steps to get help"),
Expand Down
15 changes: 15 additions & 0 deletions app/templates/categories/components/exceptional-case-funding.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% macro exceptionalCaseFundingSidebar(category) %}
<aside class="sidebar">
<h2 class="govuk-heading-m">{% trans %}Exceptional cases{% endtrans %}</h2>
{% if category == 'education' %}
<p class="govuk-body">{% trans %}In exceptional cases or if your case is going to a judicial review, legal aid may still be available.{% endtrans %}</p>
{% else %}
<p class="govuk-body">{% trans %}In exceptional cases, legal aid may still be available.{% endtrans %}</p>
{% endif %}
{% set fala_url = url_for("find-a-legal-adviser.search", category=fala_category_code.lower() if fala_category_code else None) %}
{% set fala_link %}<a class='govuk-link' href={{ fala_url }}>{% trans %}ask a legal adviser{% endtrans %}</a> {% endset %}
<p class="govuk-body">{% trans fala_link=fala_link %}You can {{fala_link}} if an application might succeed in your case and how to apply.{% endtrans %}</p>
{% set ecf_link %}<a href='https://www.gov.uk/legal-aid-apply-for-exceptional-case-funding' rel='external' class='govuk-link' target="_blank">{% trans %}apply directly{% endtrans %}</a>{% endset %}
<p class="govuk-body">{% trans ecf_link=ecf_link %}You can also {{ ecf_link }} to the Legal Aid Agency.{% endtrans %}</p>
</aside>
{% endmacro %}
1 change: 0 additions & 1 deletion app/templates/categories/in-scope.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">{% trans %}Legal aid is available for this type of problem{% endtrans %}</h1>
<p>{{ category }}</p>

<p class="govuk-body-lead">{% trans %}However, you may need to also qualify financially.{% endtrans %}</p>

Expand Down
2 changes: 1 addition & 1 deletion app/templates/categories/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h2 class="govuk-heading-m">{% trans %}More problems{% endtrans %}</h2>
{% set other_text = "" %}
{% elif category.code == "housing" %}
{% set other_text = "housing" %}
{% elif category.code == "education" %}
{% elif category.code == "send" %}
{% set other_text = "SEND" %}
{% endif %}
{{ cannot_find_your_problem(other_text, routing_map.other|category_url_for)}}
Expand Down
70 changes: 70 additions & 0 deletions app/templates/categories/next-steps-alternate-help.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{% extends 'base.html' %}
{%- from 'components/back_link.html' import govukBackLink -%}
{%- from 'govuk_frontend_jinja/components/button/macro.html' import govukButton %}
{%- from 'categories/components/help-organisations.html' import helpOrganisationsList %}
{%- from 'categories/components/exceptional-case-funding.html' import exceptionalCaseFundingSidebar %}

{% block beforeContent %}
{{ super() }}
{{ govukBackLink() }}
{% endblock %}

{% set title = _("Next steps to get help") %}
{% block pageTitle %}{{ title }} - GOV.UK{% endblock %}


{% set alternate_help_intro_text %}
{% if category.code == "domestic_abuse" %}
{{ _("These organisations give free, independent advice for problems about domestic abuse.") }}
{% elif category.code == "public_law" %}
{{ _("These organisations give free, independent advice for problems with police and public organisations.") }}
{% elif category.code == "mental_health" %}
{{ _("These organisations give free, independent advice for problems about mental health and mental capacity.") }}
{% elif category.code == "asylum_and_immigration" %}
{{ _("These organisations give free, independent advice for problems about asylum and immigration.") }}
{% elif category.code == "community_care" %}
{{ _("These organisations give free, independent advice for problems about disability and old age (social care).") }}
{% elif category.code == "benefits" %}
{{ _("These organisations give free, independent advice for problems about benefits.") }}
{% elif category.code == "family" %}
{{ _("These organisations give free, independent advice for problems about children, families and relationships.") }}
{% elif category.code == "housing" %}
{{ _("These organisations give free, independent advice for problems about housing.") }}
{% elif category.code == "discrimination" %}
{{ _("These organisations give free, independent advice for problems about discrimination.") }}
{% elif category.code == "send" %}
{{ _("These organisations give free, independent advice for problems about special educational needs (SEND).") }}
{% else %}
{{ _("These organisations give free, independent advice.") }}
{% endif %}
{% endset %}

{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">{{ title }}</h1>

<h2 class="govuk-heading-l">{% trans %}Find other free or low-cost legal help{% endtrans %}</h2>

{% set citizens_advice_link %}<a class="govuk-link" href="https://www.citizensadvice.org.uk/law-and-courts/legal-system/finding-free-or-affordable-legal-help/" target="_blank">{% trans %}free or affordable legal help (opens new tab).{% endtrans %}</a>{% endset %}
<p class="govuk-body">{% trans %}The Citizen’s Advice website explains how to find {% endtrans %}{{ citizens_advice_link }}</p>


{% set survey_link %}<a class="govuk-link" href="https://www.gov.uk/done/check-if-civil-legal-advice-can-help-you" target="_blank">What did you think of this service?</a>{% endset %}
<p class="govuk-body">{{ survey_link }} (takes 30 seconds)</p>

<h2 class="govuk-heading-l">{% trans %}Speak to an advice organisation{% endtrans %}</h2>

{% if organisations %}
{# We use lowercase_category_name rather than lower, to not convert acronyms to lowercase #}
<p class="govuk-body">{{ alternate_help_intro_text }}</p>
{{ helpOrganisationsList(organisations, truncate=5) }}
{% endif %}


</div>
<div class="govuk-grid-column-one-third">
{{ exceptionalCaseFundingSidebar(category) }}
</div>
</div>
{% endblock %}
17 changes: 2 additions & 15 deletions app/templates/categories/refer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{%- from 'components/back_link.html' import govukBackLink -%}
{%- from 'govuk_frontend_jinja/components/button/macro.html' import govukButton -%}
{%- from 'categories/components/help-organisations.html' import helpOrganisationsList %}
{%- from 'categories/components/exceptional-case-funding.html' import exceptionalCaseFundingSidebar %}

{% set fala_url = url_for("find-a-legal-adviser.search", category=fala_category_code.lower() if fala_category_code else None) %}

Expand Down Expand Up @@ -45,21 +46,7 @@ <h2 class="govuk-heading-l">{% trans category_name=_(category_name) | lowercase_
{% endif %}
</div>
<div class="govuk-grid-column-one-third">
<aside class="sidebar">
<h2 class="govuk-heading-m">{% trans %}Exceptional cases{% endtrans %}</h2>
{% if category == 'education' %}
<p class="govuk-body">{% trans %}In exceptional cases or if your case is going to a judicial review, legal aid may still be available.{% endtrans %}</p>
{% else %}
<p class="govuk-body">{% trans %}In exceptional cases, legal aid may still be available.{% endtrans %}</p>
{% endif %}

{% set fala_link %}<a class='govuk-link' href={{ fala_url }}>{% trans %}ask a legal adviser{% endtrans %}</a> {% endset %}

<p class="govuk-body">{% trans fala_link=fala_link %}You can {{fala_link}} if an application might succeed in your case and how to apply.{% endtrans %}</p>

{% set ecf_link %}<a href='https://www.gov.uk/legal-aid-apply-for-exceptional-case-funding' rel='external' class='govuk-link'>{% trans %}apply directly{% endtrans %}</a>{% endset %}
<p class="govuk-body">{% trans ecf_link=ecf_link %}You can also {{ ecf_link }} to the Legal Aid Agency.{% endtrans %}</p>
</aside>
{{ exceptionalCaseFundingSidebar(category) }}
</div>
</div>
{% endblock %}
79 changes: 79 additions & 0 deletions tests/functional_tests/categories/test_next_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import pytest
from playwright.sync_api import Page, expect


@pytest.mark.usefixtures("live_server")
@pytest.mark.parametrize(
"category_name, expected_text",
[
pytest.param(
"Children, families, relationships",
"These organisations give free, independent advice for problems about children, families and relationships.",
id="family-category",
),
pytest.param(
"Police and public organisations",
"These organisations give free, independent advice for problems with police and public organisations.",
id="public-law-category",
),
pytest.param(
"Mental capacity, mental health",
"These organisations give free, independent advice for problems about mental health and mental capacity.",
id="mental-health-category",
),
pytest.param(
"Asylum and immigration",
"These organisations give free, independent advice for problems about asylum and immigration.",
id="asylum-immigration-category",
),
pytest.param(
"Care needs for disability and old age (social care)",
"These organisations give free, independent advice for problems about disability and old age (social care).",
id="community-care-category",
),
pytest.param(
"Housing, homelessness, losing your home",
"These organisations give free, independent advice for problems about housing.",
id="housing-category",
),
pytest.param(
"Special educational needs and disability (SEND)",
"These organisations give free, independent advice for problems about special educational needs (SEND).",
id="send-category",
),
],
)
def test_category_next_steps_page(page: Page, category_name: str, expected_text: str):
page.get_by_role("link", name=category_name).click()
page.get_by_role("link", name="Next steps to get help").click()
page.get_by_role("button", name="Next steps to get help").click()
expect(page.get_by_role("heading", name="Next steps to get help")).to_be_visible()
expect(page.get_by_text(expected_text)).to_be_visible()


def test_discrimination_next_steps_page(page: Page):
page.get_by_role("link", name="Discrimination").click()
page.get_by_role("checkbox", name="School, college, university").check()
page.get_by_role("button", name="Continue").click()
page.get_by_role("checkbox", name="None of these").check()
page.get_by_role("button", name="Continue").click()
page.get_by_role("button", name="Next steps to get help").click()
expect(page.get_by_role("heading", name="Next steps to get help")).to_be_visible()
expect(
page.get_by_text(
"These organisations give free, independent advice for problems about discrimination."
)
).to_be_visible()


def test_benefits_next_steps_page(page: Page):
page.get_by_role("link", name="Benefits").click()
page.get_by_role("radio", name="None of these").check()
page.get_by_role("button", name="Continue").click()
page.get_by_role("button", name="Next steps to get help").click()
expect(page.get_by_role("heading", name="Next steps to get help")).to_be_visible()
expect(
page.get_by_text(
"These organisations give free, independent advice for problems about benefits."
)
).to_be_visible()
2 changes: 1 addition & 1 deletion tests/functional_tests/categories/test_out_of_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_mental_capacity(page: Page):
@pytest.mark.usefixtures("live_server")
@pytest.mark.parametrize("onward_link_text, expected_title", onward_links)
def test_onward_links(page: Page, onward_link_text, expected_title):
page.get_by_role("link", name="Mental capacity, mental health").click()
page.get_by_role("link", name="More problems covered by legal aid").click()
page.get_by_role("link", name="Next steps to get help").click()
page.get_by_role("button", name="Next steps to get help").click()
with page.expect_popup() as popup_info:
Expand Down
11 changes: 6 additions & 5 deletions tests/unit_tests/categories/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_get_context_with_housing_category(mock_organisations):
view = ResultPage(template="categories/results/housing.html")
result = view.get_context(category=HOUSING)

assert result["category_name"] == "Housing, homelessness, losing your home"
assert result["category"].title == "Housing, homelessness, losing your home"
assert result["organisations"] == mock_organisations
assert result["fala_category_code"] == "HOU"

Expand All @@ -46,11 +46,12 @@ def test_get_context_with_immigration_category():
view = ResultPage(template="")
result = view.get_context(category=ASYLUM_AND_IMMIGRATION)

assert result["category_name"] == "Asylum and immigration"
assert result["category"].title == "Asylum and immigration"
assert result["organisations"] == []
assert result["fala_category_code"] == "IMMAS"

mock_get_orgs.assert_not_called()
# Verify correct article_category_name was used
mock_get_orgs.assert_called_once_with("Immigration and asylum")


def test_get_context_with_no_category():
Expand All @@ -65,7 +66,7 @@ def test_get_context_with_no_category():
result = view.get_context()

# Assertions
assert result["category_name"] is None
assert result["category"] is None
assert result["organisations"] == []
assert result["fala_category_code"] is None

Expand All @@ -84,7 +85,7 @@ def test_get_context_with_invalid_category():
view = ResultPage(template="")
result = view.get_context(category="not_a_category_object")

assert result["category_name"] is None
assert result["category"] is None
assert result["organisations"] == []
assert result["fala_category_code"] is None

Expand Down
8 changes: 6 additions & 2 deletions tests/unit_tests/categories/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ def test_get_context(self):
class TestNextStepsPage:
def test_init(self):
page = NextStepsPage()
assert page.template == "categories/next-steps.html"
assert page.template == "categories/next-steps-alternate-help.html"

def test_init_with_category(self):
page = NextStepsPage(category=FAMILY)
assert page.template == "categories/next-steps.html"
assert page.template == "categories/next-steps-alternate-help.html"
assert page.category == FAMILY

def test_init_with_no_help_organisations(self):
page = NextStepsPage(get_help_organisations=False)
assert page.template == "categories/next-steps.html"

0 comments on commit ddaeae9

Please sign in to comment.