diff --git a/README.md b/README.md index 43a24fc..c524372 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ The following table shows the version of Digital Marketplace Frontend Jinja that | Digital Marketplace Frontend Jinja Version | Target CCS Digital Marketplace GOV.UK Frontend Version | | ----------------------------- | ------------------------------ | +| [2.0.0](https://github.com/tim-s-ccs/ccs-digitalmarketplace-frontend-jinja/releases/tag/2.0.0) | [6.0.0](https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-govuk-frontend/releases/tag/6.0.0) | | [1.4.1](https://github.com/tim-s-ccs/ccs-digitalmarketplace-frontend-jinja/releases/tag/1.4.1) | [5.5.0](https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-govuk-frontend/releases/tag/5.5.0) | | [1.4.0](https://github.com/tim-s-ccs/ccs-digitalmarketplace-frontend-jinja/releases/tag/1.4.0) | [5.5.0](https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-govuk-frontend/releases/tag/5.5.0) | | [1.3.3](https://github.com/tim-s-ccs/ccs-digitalmarketplace-frontend-jinja/releases/tag/1.3.3) | [5.4.3](https://github.com/Crown-Commercial-Service/ccs-digitalmarketplace-govuk-frontend/releases/tag/5.4.3) | diff --git a/digitalmarketplace_frontend_jinja/__init__.py b/digitalmarketplace_frontend_jinja/__init__.py index 8e3c933..afced14 100644 --- a/digitalmarketplace_frontend_jinja/__init__.py +++ b/digitalmarketplace_frontend_jinja/__init__.py @@ -1 +1 @@ -__version__ = '1.4.1' +__version__ = '2.0.0' diff --git a/digitalmarketplace_frontend_jinja/templates/components/character-count-from-form/macro.html b/digitalmarketplace_frontend_jinja/templates/components/character-count-from-form/macro.html index 79d007e..8aa4245 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/character-count-from-form/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/character-count-from-form/macro.html @@ -16,7 +16,7 @@ {% set _ = params.__setitem__("maxwords", params.form.widget.max_length_in_words) %} {% set _ = params.__setitem__("value", params.form.data) if params.form.data %} -{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint %} +{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint and "hint" not in params %} {% set _ = params.__setitem__("errorMessage", { "text": params.form.errors[0] }) if params.form.errors %} {{ govukCharacterCount(params) }} diff --git a/digitalmarketplace_frontend_jinja/templates/components/checkboxes-from-form/macro.html b/digitalmarketplace_frontend_jinja/templates/components/checkboxes-from-form/macro.html index 7d83a0f..ea0a7fb 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/checkboxes-from-form/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/checkboxes-from-form/macro.html @@ -44,7 +44,7 @@ {% set _ = params.__setitem__("name", name) %} {% set _ = params.__setitem__("idPrefix", "input-" + name) %} -{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint %} +{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint and "hint" not in params %} {% set _ = params.__setitem__("errorMessage", { "text": params.form.errors[0] }) if params.form.errors %} {{ govukCheckboxes(params) }} diff --git a/digitalmarketplace_frontend_jinja/templates/components/file-upload-from-form/macro.html b/digitalmarketplace_frontend_jinja/templates/components/file-upload-from-form/macro.html index ab138d9..ba20d28 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/file-upload-from-form/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/file-upload-from-form/macro.html @@ -12,7 +12,7 @@ {% set _ = params.__setitem__("id", "input-" + name) %} {% set _ = params.__setitem__("value", params.form.data) if params.form.data %} -{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint %} +{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint and "hint" not in params %} {% set _ = params.__setitem__("errorMessage", { "text": params.form.errors[0] }) if params.form.errors %} {{ govukFileUpload(params) }} diff --git a/digitalmarketplace_frontend_jinja/templates/components/input-from-form/macro.html b/digitalmarketplace_frontend_jinja/templates/components/input-from-form/macro.html index 749a737..5b5315e 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/input-from-form/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/input-from-form/macro.html @@ -15,7 +15,7 @@ {% set _ = params.__setitem__("id", "input-" + name) %} {% set _ = params.__setitem__("value", params.form.data) if params.form.data %} -{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint %} +{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint and "hint" not in params %} {% set _ = params.__setitem__("errorMessage", { "text": params.form.errors[0] }) if params.form.errors %} {{ govukInput(params) }} diff --git a/digitalmarketplace_frontend_jinja/templates/components/question/macros/pricing/macro.html b/digitalmarketplace_frontend_jinja/templates/components/question/macros/pricing/macro.html index 31a3292..3c9192c 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/question/macros/pricing/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/question/macros/pricing/macro.html @@ -1,8 +1,8 @@ {% macro digitalmarketplaceQuestionPricing(params) %} {%- from "govuk_frontend_jinja/components/fieldset/macro.html" import govukFieldset -%} {%- from "govuk_frontend_jinja/components/input/macro.html" import govukInput -%} -{%- from "govuk_frontend_jinja/components/select/macro.html" import govukSelect -%} {%- from "govuk_frontend_jinja/components/error-message/macro.html" import govukErrorMessage -%} +{%- from "digitalmarketplace_frontend_jinja/components/select/macro.html" import govukSelect -%} {% set name = params.question.id %} {% set errorMessage = params.errors[name] if params.errors %} diff --git a/digitalmarketplace_frontend_jinja/templates/components/radios-from-form/macro.html b/digitalmarketplace_frontend_jinja/templates/components/radios-from-form/macro.html index 91a5e46..6026085 100644 --- a/digitalmarketplace_frontend_jinja/templates/components/radios-from-form/macro.html +++ b/digitalmarketplace_frontend_jinja/templates/components/radios-from-form/macro.html @@ -44,7 +44,7 @@ {% set _ = params.__setitem__("name", name) %} {% set _ = params.__setitem__("idPrefix", "input-" + name) %} -{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint %} +{% set _ = params.__setitem__("hint", { "text": params.form.hint }) if params.form.hint and "hint" not in params %} {% set _ = params.__setitem__("errorMessage", { "text": params.form.errors[0] }) if params.form.errors %} {{ govukRadios(params) }} diff --git a/package-lock.json b/package-lock.json index ce4dfb4..ba17a3e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,68 +9,26 @@ "version": "0.0.0", "license": "MIT", "devDependencies": { - "ccs-digitalmarketplace-govuk-frontend": "^5.5.0" - } - }, - "node_modules/accessible-autocomplete": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/accessible-autocomplete/-/accessible-autocomplete-2.0.4.tgz", - "integrity": "sha512-2p0txrSpvs5wXFUeQJHMheDPTZVSEmiUHWlEPb7vJnv2Dd1xPfoLnBQQMfNbTSit2pL/9sSQYESuD2Yyohd4Yw==", - "dev": true, - "peer": true, - "dependencies": { - "preact": "^8.3.1" + "ccs-digitalmarketplace-govuk-frontend": "^6.0.0" } }, "node_modules/ccs-digitalmarketplace-govuk-frontend": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/ccs-digitalmarketplace-govuk-frontend/-/ccs-digitalmarketplace-govuk-frontend-5.5.0.tgz", - "integrity": "sha512-1D3oTSJNlYpcCEugDp1YjkKwHzgNi8bZLHXwDlVUVxCiE40dtknuvUlfGOGi6rYPARK3eoRHxx3tM97uuMcXqA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/ccs-digitalmarketplace-govuk-frontend/-/ccs-digitalmarketplace-govuk-frontend-6.0.0.tgz", + "integrity": "sha512-Yps7qtPdclp8nf5eMIerHkT/PHxX0xBSSjd95tM+TDMLFX1A8rwZh4kdgb77sIirGDBFOkBJNUOANwJ4Fs9HRg==", "dev": true, "engines": { "node": ">= 20.9.0" }, "peerDependencies": { - "govuk-country-and-territory-autocomplete": "^1.0.2", - "govuk-frontend": "^4.8.0", + "govuk-frontend": "^5.1.0", "jquery": "^3.x" } }, - "node_modules/core-js": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.2.1.tgz", - "integrity": "sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw==", - "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", - "dev": true, - "hasInstallScript": true, - "peer": true - }, - "node_modules/corejs-typeahead": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/corejs-typeahead/-/corejs-typeahead-1.3.4.tgz", - "integrity": "sha512-4SAc1UWszc05IyG9te1JHSeLas5WUWKmKAB8m9E6AAmHCpYhdSaySkblVSIUwQG2FR5uAsaeHbKM+pkEP7SiNw==", - "dev": true, - "peer": true, - "dependencies": { - "jquery": ">=1.11" - } - }, - "node_modules/govuk-country-and-territory-autocomplete": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/govuk-country-and-territory-autocomplete/-/govuk-country-and-territory-autocomplete-1.0.2.tgz", - "integrity": "sha512-jQ0EQ51hRx8aVEEA6ARiFWiJ64HBU4jWX2CG+xqmfxP79LVkL20oiUo/uA6xpuELFkfWZA5Lpu/ADTK/9N/LyQ==", - "dev": true, - "peer": true, - "dependencies": { - "accessible-autocomplete": "^2.0.4", - "core-js": "3.2.1", - "openregister-picker-engine": "^1.2.1" - } - }, "node_modules/govuk-frontend": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-4.8.0.tgz", - "integrity": "sha512-NOmPJxL8IYq1HSNHYKx9XY2LLTxuwb+IFASiGQO4sgJ8K7AG66SlSeqARrcetevV8zOf+i1z+MbJJ2O7//OxAw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-5.1.0.tgz", + "integrity": "sha512-Dc3J+uOI4i2VR3BVyfxbf6qVjTT4n4bBqbD0/Io6feP8pt/4IfKdP1vWimZf+BwMKKMXacw10hmdy5UcD6Cr8w==", "dev": true, "peer": true, "engines": { @@ -83,32 +41,6 @@ "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", "dev": true, "peer": true - }, - "node_modules/openregister-picker-engine": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/openregister-picker-engine/-/openregister-picker-engine-1.2.1.tgz", - "integrity": "sha512-8sbJY+iX6rW28seEri8tVTpAS2VBLNckbFDbVqNXy/kRn48Uii2IvaH6uJXKFJxXOOKB6RVcmnigIm1qA07v/Q==", - "dev": true, - "peer": true, - "dependencies": { - "corejs-typeahead": "^1.1.1", - "whatwg-fetch": "^2.0.3" - } - }, - "node_modules/preact": { - "version": "8.5.3", - "resolved": "https://registry.npmjs.org/preact/-/preact-8.5.3.tgz", - "integrity": "sha512-O3kKP+1YdgqHOFsZF2a9JVdtqD+RPzCQc3rP+Ualf7V6rmRDchZ9MJbiGTT7LuyqFKZqlHSOyO/oMFmI2lVTsw==", - "dev": true, - "hasInstallScript": true, - "peer": true - }, - "node_modules/whatwg-fetch": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", - "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==", - "dev": true, - "peer": true } } } diff --git a/package.json b/package.json index f63f28d..bd92d10 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,6 @@ "author": "CCS", "license": "MIT", "devDependencies": { - "ccs-digitalmarketplace-govuk-frontend": "^5.5.0" + "ccs-digitalmarketplace-govuk-frontend": "^6.0.0" } } diff --git a/requirements-dev.txt b/requirements-dev.txt index 7f2beb6..82adcb6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -30,7 +30,7 @@ ccs-digitalmarketplace-apiclient==25.0.0 ccs-digitalmarketplace-utils==65.8.0 # via # -r requirements.txt - # sanitized-package + # ccs-digitalmarketplace-frontend-jinja certifi==2023.11.17 # via # -r requirements.txt @@ -100,10 +100,10 @@ govuk-country-register==0.5.0 # via # -r requirements.txt # ccs-digitalmarketplace-utils -govuk-frontend-jinja==2.8.0 +govuk-frontend-jinja==3.0.0 # via # -r requirements.txt - # sanitized-package + # ccs-digitalmarketplace-frontend-jinja idna==3.6 # via # -r requirements.txt @@ -118,9 +118,9 @@ itsdangerous==2.1.2 jinja2==3.1.3 # via # -r requirements.txt + # ccs-digitalmarketplace-frontend-jinja # flask # govuk-frontend-jinja - # sanitized-package jmespath==1.0.1 # via # -r requirements.txt diff --git a/requirements.txt b/requirements.txt index 81271e2..66e888e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,7 @@ cachelib==0.10.2 ccs-digitalmarketplace-apiclient==25.0.0 # via ccs-digitalmarketplace-utils ccs-digitalmarketplace-utils==65.8.0 - # via sanitized-package + # via ccs-digitalmarketplace-frontend-jinja certifi==2023.11.17 # via requests cffi==1.16.0 @@ -55,8 +55,8 @@ fleep==1.0.1 # via ccs-digitalmarketplace-utils govuk-country-register==0.5.0 # via ccs-digitalmarketplace-utils -govuk-frontend-jinja==2.8.0 - # via sanitized-package +govuk-frontend-jinja==3.0.0 + # via ccs-digitalmarketplace-frontend-jinja idna==3.6 # via requests itsdangerous==2.1.2 @@ -65,9 +65,9 @@ itsdangerous==2.1.2 # flask-wtf jinja2==3.1.3 # via + # ccs-digitalmarketplace-frontend-jinja # flask # govuk-frontend-jinja - # sanitized-package jmespath==1.0.1 # via # boto3 diff --git a/setup.py b/setup.py index dddfc2c..f6bd46d 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ include_package_data=True, install_requires=[ 'jinja2>3', - 'govuk-frontend-jinja>=2.8.0,<3', + 'govuk-frontend-jinja>=3,<4', 'ccs-digitalmarketplace-utils>=65.0.0', ], python_requires=">=3.9,<3.12", diff --git a/tests/test_components.py b/tests/test_components.py index 8c41678..9ef2228 100644 --- a/tests/test_components.py +++ b/tests/test_components.py @@ -90,6 +90,13 @@ def html_to_one_line(html: str): return html +def assert_generated_html_matches_fixture(response, component_name, fixture_name, fixture_html): + assert response.status_code == 200 + assert ( + html_to_one_line(response.get_data().decode("utf-8")) == html_to_one_line(fixture_html) + ), f"Did not match for '{component_name}' component with example: '{fixture_name}'" + + @pytest.fixture(scope="session") def component_fixtures(): return get_component_fixtures() @@ -111,10 +118,12 @@ def test_render_component(client, component_fixtures, component_name, fixture_na 'params': fixture_options }) ) - assert response.status_code == 200 - assert ( - html_to_one_line(response.get_data().decode("utf-8")) == html_to_one_line(fixture_html) - ), f"Did not match for '{component_name}' component with example: '{fixture_name}'" + assert_generated_html_matches_fixture( + response, + component_name, + fixture_name, + fixture_html + ) def test_all_jinja_templates_exist(): @@ -139,10 +148,12 @@ def test_all_jinja_templates_exist(): # 'params': fixture_options # }) # ) -# assert response.status_code == 200 -# assert ( -# html_to_one_line(response.get_data().decode("utf-8")) == html_to_one_line(fixture_html) -# ), f"Did not match for '{component_name}' component with example: '{fixture_name}'" +# assert_generated_html_matches_fixture( +# response, +# component_name, +# fixture_name, +# fixture_html +# ) # # Debugging test case for testing one component example @@ -164,6 +175,9 @@ def test_all_jinja_templates_exist(): # print('---TEST---') # print(html_to_one_line(fixture_html)) # print(html_to_one_line(response.get_data().decode("utf-8"))) -# assert ( -# html_to_one_line(response.get_data().decode("utf-8")) == html_to_one_line(fixture_html) -# ), f"Did not match for '{component_name}' component with example: '{fixture_name}'" +# assert_generated_html_matches_fixture( +# response, +# component_name, +# fixture_name, +# fixture_html +# )