mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Validate length of broadcast content
Depends on: - [ ] https://github.com/alphagov/notifications-utils/pull/826/files Adds error messages for when the content of a broadcast template is too long. The error message is explicit when this is cause by non-GSM characters. We may not want to expose this complexity to our users, but it’s useful for now while we’re testing things out.
This commit is contained in:
@@ -1865,6 +1865,37 @@ def test_should_not_update_too_big_template(
|
||||
assert "Content has a character count greater than the limit of 459" in page.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize('content, expected_error', (
|
||||
(("ŴŶ" * 308), (
|
||||
'Content must be 615 characters or fewer because it contains Ŵ and Ŷ'
|
||||
)),
|
||||
(("ab" * 698), (
|
||||
'Content must be 1,395 characters or fewer'
|
||||
)),
|
||||
))
|
||||
def test_should_not_create_too_big_template_for_broadcasts(
|
||||
client_request,
|
||||
service_one,
|
||||
content,
|
||||
expected_error,
|
||||
):
|
||||
service_one['permissions'] = ['broadcast']
|
||||
page = client_request.post(
|
||||
'.add_service_template',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_type='broadcast',
|
||||
_data={
|
||||
'name': 'New name',
|
||||
'template_content': content,
|
||||
'template_type': 'broadcast',
|
||||
'service': SERVICE_ONE_ID,
|
||||
'process_type': 'normal'
|
||||
},
|
||||
_expected_status=200,
|
||||
)
|
||||
assert normalize_spaces(page.select_one('.error-message').text) == expected_error
|
||||
|
||||
|
||||
def test_should_redirect_when_saving_a_template_email(
|
||||
client_request,
|
||||
mock_get_service_email_template,
|
||||
|
||||
Reference in New Issue
Block a user