From ccfaea34391ef2b14b94eedbd248f70ed5a28da7 Mon Sep 17 00:00:00 2001 From: Gurdeep Atwal Date: Wed, 15 Jan 2025 14:36:49 +0000 Subject: [PATCH] fix date component --- exporter/applications/forms/export_details.py | 2 +- lite_forms/templates/components.html | 4 +- lite_forms/templates/components/date.html | 118 ++++++++++-------- .../views/test_exporter_details.py | 47 +++++++ 4 files changed, 113 insertions(+), 58 deletions(-) create mode 100644 unit_tests/exporter/applications/views/test_exporter_details.py diff --git a/exporter/applications/forms/export_details.py b/exporter/applications/forms/export_details.py index 78a623d31a..e21236704a 100644 --- a/exporter/applications/forms/export_details.py +++ b/exporter/applications/forms/export_details.py @@ -135,7 +135,7 @@ def proposed_product_return_date_form(): title=TemporaryExportDetails.PROPOSED_RETURN_DATE, questions=[ DateInput( - title="", + title="Return to the UK date", short_title=TemporaryExportDetails.SummaryList.PROPOSED_RETURN_DATE, description=f"For example, 12 11 {datetime.datetime.now().year + 1}", name="proposed_return_date", diff --git a/lite_forms/templates/components.html b/lite_forms/templates/components.html index 7b1a77d23b..0a9cd3c2a3 100644 --- a/lite_forms/templates/components.html +++ b/lite_forms/templates/components.html @@ -7,7 +7,7 @@ govuk-form-group--error {% endif %} {% endif %}"> - {% if question.title %} + {% if question.title and question.input_type != "date" %} {% endif %} - {% if question.description %} + {% if question.description and question.input_type != "date" %} {{ question.description|safe }} diff --git a/lite_forms/templates/components/date.html b/lite_forms/templates/components/date.html index 93a0442dae..91bb394f98 100644 --- a/lite_forms/templates/components/date.html +++ b/lite_forms/templates/components/date.html @@ -1,57 +1,65 @@ -
-
-
- -
- - -
-
-
-
- +
+ +

+ {{ component.title }} +

+
+
+ {{ component.description }} +
+
+
+
+ -
-
-
-
- - -
-
-
-
+
+
+
+
+ + +
+
+
+
+ + +
+
+ diff --git a/unit_tests/exporter/applications/views/test_exporter_details.py b/unit_tests/exporter/applications/views/test_exporter_details.py new file mode 100644 index 0000000000..54ab4ef015 --- /dev/null +++ b/unit_tests/exporter/applications/views/test_exporter_details.py @@ -0,0 +1,47 @@ +import pytest + +from django.urls import reverse + + +@pytest.fixture +def application_pk(data_standard_case): + return data_standard_case["case"]["data"]["id"] + + +@pytest.fixture +def application_export_details_url(application_pk): + return reverse( + "applications:export_details", + kwargs={ + "pk": application_pk, + }, + ) + + +def test_application_export_details_return_date( + authorized_client, + mock_application_get, + application_export_details_url, + requests_mock, + application_pk, + beautiful_soup, +): + + requests_mock.put( + f"/applications/{application_pk}/temporary-export-details/", + json={}, + ) + + response = authorized_client.post( + application_export_details_url, + data={ + "_action": "submit", + "goods_starting_point": "GB", + "export_type": "temporary", + "form_pk": "3", + }, + ) + + soup = beautiful_soup(response.content) + assert soup.find("legend").label.text.strip() == "Proposed date the products will return to the UK" + assert "For example, 12 11" in soup.find(id="return-date-hint").text.strip()