From 98629935f5523cd4d821f25f5fc9a6c9b37cbaa4 Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Wed, 29 May 2024 09:58:29 +0100 Subject: [PATCH 1/5] upgrade test requirements --- tests/requirements.in | 8 ++++---- tests/requirements.txt | 32 +++++++++++++++----------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/tests/requirements.in b/tests/requirements.in index 8139509..22c2b22 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -1,7 +1,7 @@ deepmerge==1.1.1 -email_validator==2.1.0.post1 +email_validator==2.1.1 flask-wtf==1.2.1 -flask==3.0.2 -govuk-frontend-jinja>=3.0.0 -pytest-cov==4.1.0 +flask==3.0.3 +govuk-frontend-jinja==3.1.0 +pytest-cov==5.0.0 pyyaml==6.0.1 diff --git a/tests/requirements.txt b/tests/requirements.txt index dd2d2c8..93fdea6 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -4,37 +4,35 @@ # # pip-compile requirements.in # -blinker==1.7.0 +blinker==1.8.2 # via flask click==8.1.7 # via flask -coverage[toml]==7.4.1 - # via - # coverage - # pytest-cov +coverage[toml]==7.5.3 + # via pytest-cov deepmerge==1.1.1 # via -r requirements.in -dnspython==2.5.0 +dnspython==2.6.1 # via email-validator -email-validator==2.1.0.post1 +email-validator==2.1.1 # via -r requirements.in -flask==3.0.2 +flask==3.0.3 # via # -r requirements.in # flask-wtf flask-wtf==1.2.1 # via -r requirements.in -govuk-frontend-jinja==3.0.0 +govuk-frontend-jinja==3.1.0 # via -r requirements.in -idna==3.6 +idna==3.7 # via email-validator iniconfig==2.0.0 # via pytest -itsdangerous==2.1.2 +itsdangerous==2.2.0 # via # flask # flask-wtf -jinja2==3.1.3 +jinja2==3.1.4 # via # flask # govuk-frontend-jinja @@ -43,17 +41,17 @@ markupsafe==2.1.5 # jinja2 # werkzeug # wtforms -packaging==23.2 +packaging==24.0 # via pytest -pluggy==1.4.0 +pluggy==1.5.0 # via pytest -pytest==8.0.0 +pytest==8.2.1 # via pytest-cov -pytest-cov==4.1.0 +pytest-cov==5.0.0 # via -r requirements.in pyyaml==6.0.1 # via -r requirements.in -werkzeug==3.0.1 +werkzeug==3.0.3 # via flask wtforms==3.1.2 # via flask-wtf From 720b820c178c3e0b35105d8734ff7858e08c800f Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Wed, 29 May 2024 10:01:02 +0100 Subject: [PATCH 2/5] 3.1 --- CHANGELOG.md | 11 +++++++++-- README.md | 2 +- setup.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe8d5f2..bd34fd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/LandRegistry/govuk-frontend-wtf/compare/3.0.0..main) +## [Unreleased](https://github.com/LandRegistry/govuk-frontend-wtf/compare/3.1.0..main) + +## [3.1.0](https://github.com/LandRegistry/govuk-frontend-wtf/releases/tag/3.1.0) - xx/xx/2024 + +### Added + +- [GOV.UK Frontend v5.4.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.4.0) support +- Use new GOV.UK password input component for PasswordInput fields ## [3.0.0](https://github.com/LandRegistry/govuk-frontend-wtf/releases/tag/3.0.0) - 13/02/2024 @@ -92,7 +99,7 @@ From [#38](https://github.com/LandRegistry/govuk-frontend-wtf/pull/38), thanks t ### Added -- Support for WTForms v3.0.0 +- Support for WTForms v3.1.0 ### Fixed diff --git a/README.md b/README.md index 5d3eab0..ac2d112 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # GOV.UK Frontend WTForms Widgets [![PyPI version](https://badge.fury.io/py/govuk-frontend-wtf.svg)](https://pypi.org/project/govuk-frontend-wtf/) -![govuk-frontend 5.1.0](https://img.shields.io/badge/govuk--frontend%20version-5.1.0-005EA5?logo=gov.uk&style=flat) +![govuk-frontend 5.4.0](https://img.shields.io/badge/govuk--frontend%20version-5.4.0-005EA5?logo=gov.uk&style=flat) [![Python package](https://github.com/LandRegistry/govuk-frontend-wtf/actions/workflows/python-package.yml/badge.svg)](https://github.com/LandRegistry/govuk-frontend-wtf/actions/workflows/python-package.yml) **GOV.UK Frontend WTForms is a [community tool](https://design-system.service.gov.uk/community/resources-and-tools/) of the [GOV.UK Design System](https://design-system.service.gov.uk/). The Design System team is not responsible for it and cannot support you with using it. Contact the [maintainers](#contributors) directly if you need [help](#support) or you want to request a feature.** diff --git a/setup.py b/setup.py index ede62e3..a8cf2e6 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setuptools.setup( name="govuk-frontend-wtf", - version="3.0.0", + version="3.1.0", author="Matt Shaw", author_email="matthew.shaw@landregistry.gov.uk", description="GOV.UK Frontend WTForms Widgets", From 668f8d89877bf2e955b82bc334b066ebf3f5b2bf Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Wed, 29 May 2024 10:50:49 +0100 Subject: [PATCH 3/5] update expected component html --- tests/fixtures/wtf_widgets_data.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/fixtures/wtf_widgets_data.yaml b/tests/fixtures/wtf_widgets_data.yaml index 958ae00..f6d2e61 100644 --- a/tests/fixtures/wtf_widgets_data.yaml +++ b/tests/fixtures/wtf_widgets_data.yaml @@ -4,7 +4,7 @@ TestStringField: tests: test_empty_get: expected_output: - - + - - -
\s*StringFieldHint\s*
test_output_sanitized: @@ -42,7 +42,7 @@ TestStringFieldId: tests: test_empty_get: expected_output: - - + - - -
\s*StringFieldHint\s*
test_output_sanitized: @@ -157,7 +157,7 @@ TestEmailField: expected_output: -
\s*EmailFieldHint\s*
- - - + - test_output_sanitized: request: method: post @@ -193,7 +193,7 @@ TestFloatField: tests: test_empty_get: expected_output: - - + - - -
\s*FloatFieldHint\s*
test_output_sanitized: @@ -231,7 +231,7 @@ TestIntegerField: tests: test_empty_get: expected_output: - - + - - -
\s*IntegerFieldHint\s*
test_output_sanitized: @@ -269,7 +269,7 @@ TestDecimalField: tests: test_empty_get: expected_output: - - + - - -
\s*DecimalFieldHint\s*
test_output_sanitized: @@ -381,7 +381,7 @@ TestCharacterCountField: - - -

\s*\s*Error:\s*\s*CharacterCountField is required\s*

- -
+ -
-
\s*CharacterCountFieldHint\s*
-
\s*You can enter up to 200 characters\s*
@@ -696,7 +696,7 @@ TestNestedForm: expected_output: -
- - - + - -
\s*StringFieldHint\s*
test_output_sanitized: request: From f8837acfdd76aa5bbe8f286a53e24186abb64ca2 Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Wed, 29 May 2024 13:47:11 +0100 Subject: [PATCH 4/5] add password template and tests --- govuk_frontend_wtf/templates/password.html | 2 ++ govuk_frontend_wtf/wtforms_widgets.py | 12 +++----- tests/fixtures/wtf_widgets_data.yaml | 32 +++++++++++++--------- 3 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 govuk_frontend_wtf/templates/password.html diff --git a/govuk_frontend_wtf/templates/password.html b/govuk_frontend_wtf/templates/password.html new file mode 100644 index 0000000..2904a63 --- /dev/null +++ b/govuk_frontend_wtf/templates/password.html @@ -0,0 +1,2 @@ +{% from 'govuk_frontend_jinja/components/password-input/macro.html' import govukPasswordInput %} +{{ govukPasswordInput(params) }} \ No newline at end of file diff --git a/govuk_frontend_wtf/wtforms_widgets.py b/govuk_frontend_wtf/wtforms_widgets.py index eb283df..e8e312c 100644 --- a/govuk_frontend_wtf/wtforms_widgets.py +++ b/govuk_frontend_wtf/wtforms_widgets.py @@ -37,17 +37,13 @@ class GovTextInput(GovInput, TextInput): input_type = "text" -class GovPasswordInput(GovInput, PasswordInput): - """Render a password input. +class GovPasswordInput(GovFormBase, PasswordInput): + """Render a password input.""" - For security purposes, this field will not reproduce the value on a form - submit by default. To have the value filled in, set `hide_value` to - `False`. - """ + template = "govuk_frontend_wtf/password.html" def __call__(self, field, **kwargs): - if self.hide_value: - kwargs["value"] = "" + kwargs.setdefault("id", field.id) return super().__call__(field, **kwargs) diff --git a/tests/fixtures/wtf_widgets_data.yaml b/tests/fixtures/wtf_widgets_data.yaml index f6d2e61..d74cfbc 100644 --- a/tests/fixtures/wtf_widgets_data.yaml +++ b/tests/fixtures/wtf_widgets_data.yaml @@ -720,14 +720,16 @@ TestSubmitButton: - test_output_sanitized: request: method: post @@ -735,10 +737,12 @@ TestPasswordField: password_field: password_retype_field: expected_output: - # No error here - the data will merely have been accepted as a valid password - # But we still want to ensure the value hasn't made it into the html unsanitized - - + -
+ - -
\s*PasswordFieldHint\s*
+ -
+ - + - not_expected_output: - test_valid_post: @@ -748,11 +752,12 @@ TestPasswordField: password_field: foo password_retype_field: foo expected_output: - -
+ -
- - # Ensure that passwords are not represented in the output for security reasons - - -
\s*PasswordFieldHint\s*
+ -
+ - + - test_invalid_post: request: method: post @@ -760,12 +765,13 @@ TestPasswordField: password_field: foo password_retype_field: bar expected_output: - -
+ -
- - -

\s*\s*Error:\s*\s*Please ensure both password fields match\s*

- # Ensure that passwords are not represented in the output for security reasons - - input class="govuk-input govuk-input--error" id="password_field" name="password_field" type="password" spellcheck="false" aria-describedby="password_field-hint password_field-error" required="required"> -
\s*PasswordFieldHint\s*
+ -

\s*\s*Error:\s*\s*Please ensure both password fields match\s*

+ -
+ - + - TestErrorSummary: template: > From 7aa62c2bbf8145a90c545af35c40299e55e6d7b7 Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Wed, 29 May 2024 14:05:37 +0100 Subject: [PATCH 5/5] correction --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd34fd8..322ebbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,7 +99,7 @@ From [#38](https://github.com/LandRegistry/govuk-frontend-wtf/pull/38), thanks t ### Added -- Support for WTForms v3.1.0 +- Support for WTForms v3.0.0 ### Fixed