diff --git a/app/categories/send/forms.py b/app/categories/send/forms.py index 927397624..002da0a0b 100644 --- a/app/categories/send/forms.py +++ b/app/categories/send/forms.py @@ -3,4 +3,4 @@ class SendChildInCareQuestionForm(ChildInCareQuestionForm): - category = EDUCATION + category = EDUCATION.sub.tribunals diff --git a/tests/functional_tests/means_test/conftest.py b/tests/functional_tests/means_test/conftest.py index 78201a6c0..0e02e16d9 100644 --- a/tests/functional_tests/means_test/conftest.py +++ b/tests/functional_tests/means_test/conftest.py @@ -12,15 +12,31 @@ def navigate_to_means_test(page: Page): @pytest.fixture def complete_about_you_form( - page: Page, about_you_answers: dict, navigate_to_means_test + page: Page, navigate_to_means_test, about_you_answers: dict ): - for question, answer in about_you_answers.items(): + questions = { + "Do you have a partner?": "No", + "Do you receive any benefits (including Child Benefit)?": "No", + "Do you have any children aged 15 or under?": "No", + "Do you have any dependants aged 16 or over?": "No", + "Do you own any property?": "No", + "Are you employed?": "No", + "Are you self-employed?": "No", + "Are you or your partner (if you have one) aged 60 or over?": "No", + "Do you have any savings or investments?": "No", + "Do you have any valuable items worth over £500 each?": "No", + } + + questions.update(about_you_answers) + for question, answer in questions.items(): form_group = page.get_by_role("group", name=question) if question == "Do you have a partner?": locator = "#has_partner" if answer == "Yes" else "#has_partner-2" form_group.locator(locator).check() elif question == "How many children aged 15 or under?": page.locator("#num_children").fill(answer) + elif question == "How many dependants aged 16 or over?": + page.locator("#num_dependents").fill(answer) else: form_group.get_by_label(answer).first.check() diff --git a/tests/functional_tests/means_test/test_benefits_page.py b/tests/functional_tests/means_test/test_benefits_page.py index 7341e6fde..9fc9979c9 100644 --- a/tests/functional_tests/means_test/test_benefits_page.py +++ b/tests/functional_tests/means_test/test_benefits_page.py @@ -1,7 +1,6 @@ import pytest from flask import url_for from playwright.sync_api import Page, expect -from app.means_test import YES, NO next_page_heading = "Check your answers and confirm" @@ -100,36 +99,32 @@ def test_child_benefits_not_available(page: Page, client): @pytest.mark.usefixtures("live_server") -def test_child_benefits_available_have_children(page: Page, client): - # - with client.session_transaction() as session: - # update the session - session.get_eligibility().add( - "about-you", {"have_children": YES, "have_dependents": NO} - ) - - url = url_for("means_test.benefits", _external=True) - response = client.get(url) - assert response.status_code == 200 # Ensure the response is valid - - # Load the response HTML into the Playwright page - page.set_content(response.data.decode("utf-8")) +@pytest.mark.parametrize( + "about_you_answers", + [ + { + "Do you receive any benefits (including Child Benefit)?": "Yes", + "Do you have any children aged 15 or under?": "Yes", + "How many children aged 15 or under?": "1", + } + ], +) +def test_child_benefits_available_have_children(page: Page, complete_about_you_form): + assert page.title() == "Which benefits do you receive? - GOV.UK" expect(page.get_by_label("Child Benefit")).to_have_count(1) @pytest.mark.usefixtures("live_server") -def test_child_benefits_available_have_dependents(page: Page, client): - # - with client.session_transaction() as session: - # update the session - session.get_eligibility().add( - "about-you", {"have_children": NO, "have_dependents": YES} - ) - - url = url_for("means_test.benefits", _external=True) - response = client.get(url) - assert response.status_code == 200 # Ensure the response is valid - - # Load the response HTML into the Playwright page - page.set_content(response.data.decode("utf-8")) +@pytest.mark.parametrize( + "about_you_answers", + [ + { + "Do you receive any benefits (including Child Benefit)?": "Yes", + "Do you have any dependants aged 16 or over?": "Yes", + "How many dependants aged 16 or over?": "1", + } + ], +) +def test_child_benefits_available_have_dependents(page: Page, complete_about_you_form): + assert page.title() == "Which benefits do you receive? - GOV.UK" expect(page.get_by_label("Child Benefit")).to_have_count(1) diff --git a/tests/functional_tests/means_test/test_income.py b/tests/functional_tests/means_test/test_income.py index 9834f25df..204244048 100644 --- a/tests/functional_tests/means_test/test_income.py +++ b/tests/functional_tests/means_test/test_income.py @@ -111,6 +111,7 @@ def fill_about_form(page: Page, questions: dict) -> None: ], ) @pytest.mark.usefixtures("live_server") +@pytest.mark.usefixtures("navigate_to_means_test") def test_about_form(page: Page, scenario: str, form_inputs: dict, expected: dict): page.goto(url_for("means_test.about-you", _external=True)) diff --git a/tests/functional_tests/means_test/test_savings.py b/tests/functional_tests/means_test/test_savings.py index 7ce6b6d56..d98136c6d 100644 --- a/tests/functional_tests/means_test/test_savings.py +++ b/tests/functional_tests/means_test/test_savings.py @@ -81,6 +81,7 @@ def fill_about_form(page: Page, questions: dict) -> None: ], ) @pytest.mark.usefixtures("live_server") +@pytest.mark.usefixtures("navigate_to_means_test") def test_savings_form(page: Page, scenario: str, form_inputs: dict, expected: dict): page.goto(url_for("means_test.about-you", _external=True)) @@ -196,6 +197,7 @@ def test_savings_form(page: Page, scenario: str, form_inputs: dict, expected: di ], ) @pytest.mark.usefixtures("live_server") +@pytest.mark.usefixtures("navigate_to_means_test") def test_savings_form_validators( page: Page, scenario: str, diff --git a/tests/functional_tests/test_back_link.py b/tests/functional_tests/test_back_link.py index b9dc6a80e..a343547e5 100644 --- a/tests/functional_tests/test_back_link.py +++ b/tests/functional_tests/test_back_link.py @@ -1,6 +1,7 @@ import pytest from flask import url_for from playwright.sync_api import Page, expect +from tests.functional_tests.means_test.conftest import navigate_to_means_test # noqa: F401 @pytest.mark.usefixtures("live_server") @@ -74,6 +75,7 @@ def test_fala_journey(page: Page): @pytest.mark.usefixtures("live_server") +@pytest.mark.usefixtures("navigate_to_means_test") def test_fallback(page: Page): """Test that we go to session expired page if we press back when referred from an external page""" page.goto("https://www.gov.uk")