mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-16 03:10:16 -04:00
Merge pull request #1540 from alphagov/reply-inbound
Let users reply to an inbound message with an existing template
This commit is contained in:
@@ -214,3 +214,75 @@ def test_view_conversation_with_empty_inbound(
|
||||
|
||||
messages = page.select('.sms-message-wrapper')
|
||||
assert len(messages) == 1
|
||||
|
||||
|
||||
def test_conversation_links_to_reply(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_notification,
|
||||
mock_get_notifications,
|
||||
mock_get_inbound_sms,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.conversation',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
)
|
||||
|
||||
assert page.select('main p')[-1].select_one('a')['href'] == (
|
||||
url_for(
|
||||
'.conversation_reply',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_conversation_reply_shows_templates(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_service_templates,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.conversation_reply',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
)
|
||||
|
||||
for index, expected in enumerate([
|
||||
'sms_template_one',
|
||||
'sms_template_two',
|
||||
]):
|
||||
link = page.select('.message-name')[index]
|
||||
assert normalize_spaces(link.text) == expected
|
||||
assert link.select_one('a')['href'].startswith(
|
||||
url_for(
|
||||
'main.conversation_reply_with_template',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
template_id='',
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_conversation_reply_redirects_with_phone_number_from_notification(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_notification,
|
||||
mock_get_service_template,
|
||||
):
|
||||
|
||||
page = client_request.get(
|
||||
'main.conversation_reply_with_template',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
template_id=fake_uuid,
|
||||
_follow_redirects=True,
|
||||
)
|
||||
|
||||
for element, expected_text in [
|
||||
('h1', 'Preview of Two week reminder'),
|
||||
('.sms-message-recipient', 'To: 07123 456789'),
|
||||
('.sms-message-wrapper', 'service one: Template <em>content</em> with & entity'),
|
||||
]:
|
||||
assert normalize_spaces(page.select_one(element).text) == expected_text
|
||||
|
||||
@@ -161,3 +161,45 @@ def test_should_show_image_of_letter_notification(
|
||||
assert response.get_data(as_text=True) == 'foo'
|
||||
assert isinstance(mocked_preview.call_args[0][0], LetterImageTemplate)
|
||||
assert mocked_preview.call_args[0][1] == 'png'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('service_permissions, template_type, link_expected', [
|
||||
([], '', False),
|
||||
(['inbound_sms'], 'email', False),
|
||||
(['inbound_sms'], 'letter', False),
|
||||
(['inbound_sms'], 'sms', True),
|
||||
])
|
||||
def test_notification_page_has_link_to_send_another_for_sms(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
service_one,
|
||||
service_permissions,
|
||||
template_type,
|
||||
link_expected,
|
||||
):
|
||||
|
||||
service_one['permissions'] = service_permissions
|
||||
mock_get_notification(mocker, fake_uuid, template_type=template_type)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_notification',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
)
|
||||
|
||||
last_paragraph = page.select('main p')[-1]
|
||||
|
||||
if link_expected:
|
||||
assert normalize_spaces(last_paragraph.text) == (
|
||||
'See all text messages sent to this phone number'
|
||||
)
|
||||
assert last_paragraph.select_one('a')['href'] == url_for(
|
||||
'.conversation',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
_anchor='n{}'.format(fake_uuid),
|
||||
)
|
||||
else:
|
||||
# covers ‘Delivered’, ‘Expected delivery date’
|
||||
assert 'deliver' in normalize_spaces(last_paragraph.text).lower()
|
||||
|
||||
Reference in New Issue
Block a user