mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Merge pull request #3422 from alphagov/fix-sms-preview-activity
Fix preview of text messages on activity page
This commit is contained in:
@@ -16,7 +16,7 @@ from notifications_python_client.errors import HTTPError
|
|||||||
from notifications_utils.template import (
|
from notifications_utils.template import (
|
||||||
EmailPreviewTemplate,
|
EmailPreviewTemplate,
|
||||||
LetterPreviewTemplate,
|
LetterPreviewTemplate,
|
||||||
SMSPreviewTemplate,
|
SMSBodyPreviewTemplate,
|
||||||
)
|
)
|
||||||
|
|
||||||
from app import (
|
from app import (
|
||||||
@@ -421,11 +421,9 @@ def get_preview_of_content(notification):
|
|||||||
return notification['client_reference']
|
return notification['client_reference']
|
||||||
|
|
||||||
if notification['template']['template_type'] == 'sms':
|
if notification['template']['template_type'] == 'sms':
|
||||||
return str(SMSPreviewTemplate(
|
return str(SMSBodyPreviewTemplate(
|
||||||
notification['template'],
|
notification['template'],
|
||||||
notification['personalisation'],
|
notification['personalisation'],
|
||||||
redact_missing_personalisation=True,
|
|
||||||
show_prefix=False,
|
|
||||||
))
|
))
|
||||||
|
|
||||||
if notification['template']['template_type'] == 'email':
|
if notification['template']['template_type'] == 'email':
|
||||||
|
|||||||
@@ -18,10 +18,11 @@ pytz==2019.3
|
|||||||
gunicorn==20.0.4
|
gunicorn==20.0.4
|
||||||
eventlet==0.25.1
|
eventlet==0.25.1
|
||||||
notifications-python-client==5.5.1
|
notifications-python-client==5.5.1
|
||||||
|
WTForms==2.2.1 # Pinned because of breaking change in 2.3.0
|
||||||
|
|
||||||
# PaaS
|
# PaaS
|
||||||
awscli-cwlogs>=1.4,<1.5
|
awscli-cwlogs>=1.4,<1.5
|
||||||
itsdangerous==1.1.0
|
itsdangerous==1.1.0
|
||||||
|
|
||||||
git+https://github.com/alphagov/notifications-utils.git@37.0.0#egg=notifications-utils==37.0.0
|
git+https://github.com/alphagov/notifications-utils.git@37.2.0#egg=notifications-utils==37.2.0
|
||||||
git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha
|
git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha
|
||||||
|
|||||||
@@ -20,19 +20,20 @@ pytz==2019.3
|
|||||||
gunicorn==20.0.4
|
gunicorn==20.0.4
|
||||||
eventlet==0.25.1
|
eventlet==0.25.1
|
||||||
notifications-python-client==5.5.1
|
notifications-python-client==5.5.1
|
||||||
|
WTForms==2.2.1 # Pinned because of breaking change in 2.3.0
|
||||||
|
|
||||||
# PaaS
|
# PaaS
|
||||||
awscli-cwlogs>=1.4,<1.5
|
awscli-cwlogs>=1.4,<1.5
|
||||||
itsdangerous==1.1.0
|
itsdangerous==1.1.0
|
||||||
|
|
||||||
git+https://github.com/alphagov/notifications-utils.git@37.0.0#egg=notifications-utils==37.0.0
|
git+https://github.com/alphagov/notifications-utils.git@37.2.0#egg=notifications-utils==37.2.0
|
||||||
git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha
|
git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha
|
||||||
|
|
||||||
## The following requirements were added by pip freeze:
|
## The following requirements were added by pip freeze:
|
||||||
awscli==1.18.39
|
awscli==1.18.43
|
||||||
bleach==3.1.4
|
bleach==3.1.4
|
||||||
boto3==1.10.38
|
boto3==1.10.38
|
||||||
botocore==1.15.39
|
botocore==1.15.43
|
||||||
certifi==2020.4.5.1
|
certifi==2020.4.5.1
|
||||||
chardet==3.0.4
|
chardet==3.0.4
|
||||||
click==7.1.1
|
click==7.1.1
|
||||||
@@ -71,9 +72,8 @@ six==1.14.0
|
|||||||
smartypants==2.0.1
|
smartypants==2.0.1
|
||||||
statsd==3.3.0
|
statsd==3.3.0
|
||||||
texttable==1.6.2
|
texttable==1.6.2
|
||||||
urllib3==1.25.8
|
urllib3==1.25.9
|
||||||
webencodings==0.5.1
|
webencodings==0.5.1
|
||||||
Werkzeug==1.0.1
|
Werkzeug==1.0.1
|
||||||
WTForms==2.2.1
|
|
||||||
xlrd==1.2.0
|
xlrd==1.2.0
|
||||||
xlwt==1.3.0
|
xlwt==1.3.0
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ from tests.conftest import (
|
|||||||
('test@example.com', 'test@example.com'),
|
('test@example.com', 'test@example.com'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@freeze_time('2020-01-01 01:00')
|
||||||
def test_can_show_notifications(
|
def test_can_show_notifications(
|
||||||
client_request,
|
client_request,
|
||||||
logged_in_client,
|
logged_in_client,
|
||||||
@@ -129,13 +130,34 @@ def test_can_show_notifications(
|
|||||||
page=page_argument,
|
page=page_argument,
|
||||||
**extra_args
|
**extra_args
|
||||||
)
|
)
|
||||||
text_of_first_row = page.select('tbody tr')[0].text
|
first_row = page.select_one('tbody tr')
|
||||||
assert '07123456789' in text_of_first_row
|
assert normalize_spaces(
|
||||||
assert (
|
first_row.select_one('a.file-list-filename.govuk-link').text
|
||||||
'template content' in text_of_first_row or
|
) == (
|
||||||
'template subject' in text_of_first_row
|
# Comes from
|
||||||
|
# https://github.com/alphagov/notifications-admin/blob/8faffad508f9a087b0006989c197741c693cc2e2/tests/__init__.py#L436
|
||||||
|
'07123456789'
|
||||||
)
|
)
|
||||||
assert 'Delivered' in text_of_first_row
|
assert normalize_spaces(
|
||||||
|
# We’re doing str() here not .text to make sure there’s no extra
|
||||||
|
# HTML sneaking in
|
||||||
|
str(first_row.select_one('.file-list-hint'))
|
||||||
|
) == (
|
||||||
|
# Comes from
|
||||||
|
# https://github.com/alphagov/notifications-admin/blob/8faffad508f9a087b0006989c197741c693cc2e2/tests/__init__.py#L271
|
||||||
|
'template content'
|
||||||
|
) or (
|
||||||
|
# Comes from
|
||||||
|
# https://github.com/alphagov/notifications-admin/blob/8faffad508f9a087b0006989c197741c693cc2e2/tests/__init__.py#L273
|
||||||
|
'template subject'
|
||||||
|
)
|
||||||
|
|
||||||
|
assert normalize_spaces(
|
||||||
|
first_row.select_one('.table-field-right-aligned .align-with-message-body').text
|
||||||
|
) == (
|
||||||
|
'Delivered 1 January at 1:01am'
|
||||||
|
)
|
||||||
|
|
||||||
assert page_title in page.h1.text.strip()
|
assert page_title in page.h1.text.strip()
|
||||||
|
|
||||||
path_to_json = page.find("div", {'data-key': 'notifications'})['data-resource']
|
path_to_json = page.find("div", {'data-key': 'notifications'})['data-resource']
|
||||||
|
|||||||
Reference in New Issue
Block a user