mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-17 04:59:37 -04:00
When replying to inbound sms show templates in all user's folders
This commit is contained in:
@@ -10,10 +10,14 @@ from notifications_python_client.errors import HTTPError
|
||||
from app.main.views.conversation import get_user_number
|
||||
from tests.conftest import (
|
||||
SERVICE_ONE_ID,
|
||||
_template,
|
||||
mock_get_notifications,
|
||||
normalize_spaces,
|
||||
)
|
||||
|
||||
INV_PARENT_FOLDER_ID = '7e979e79-d970-43a5-ac69-b625a8d147b0'
|
||||
VIS_PARENT_FOLDER_ID = 'bbbb222b-2b22-2b22-222b-b222b22b2222'
|
||||
|
||||
|
||||
def test_get_user_phone_number_when_only_inbound_exists(mocker):
|
||||
|
||||
@@ -255,6 +259,7 @@ def test_conversation_reply_shows_link_to_add_templates_if_service_has_no_templa
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_service_templates_when_no_templates_exist,
|
||||
mock_get_template_folders,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.conversation_reply',
|
||||
@@ -275,8 +280,32 @@ def test_conversation_reply_shows_link_to_add_templates_if_service_has_no_templa
|
||||
def test_conversation_reply_shows_templates(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_service_templates,
|
||||
mocker,
|
||||
mock_get_template_folders,
|
||||
active_user_with_permissions
|
||||
):
|
||||
|
||||
all_templates = {'data': [
|
||||
_template('sms', 'sms_template_one', parent=INV_PARENT_FOLDER_ID),
|
||||
_template('sms', 'sms_template_two'),
|
||||
_template('sms', 'sms_template_three', parent=VIS_PARENT_FOLDER_ID),
|
||||
_template('letter', 'letter_template_one')
|
||||
]}
|
||||
mocker.patch('app.service_api_client.get_service_templates', return_value=all_templates)
|
||||
mock_get_template_folders.return_value = [
|
||||
{
|
||||
'name': "Parent 1 - invisible",
|
||||
'id': INV_PARENT_FOLDER_ID,
|
||||
'parent_id': None,
|
||||
'users_with_permission': []
|
||||
},
|
||||
{
|
||||
'name': "Parent 2 - visible",
|
||||
'id': VIS_PARENT_FOLDER_ID,
|
||||
'parent_id': None,
|
||||
'users_with_permission': [active_user_with_permissions.id]
|
||||
},
|
||||
]
|
||||
page = client_request.get(
|
||||
'main.conversation_reply',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
@@ -284,8 +313,8 @@ def test_conversation_reply_shows_templates(
|
||||
)
|
||||
|
||||
for index, expected in enumerate([
|
||||
'sms_template_one',
|
||||
'sms_template_two',
|
||||
'sms_template_three'
|
||||
]):
|
||||
link = page.select('.message-name')[index]
|
||||
assert normalize_spaces(link.text) == expected
|
||||
@@ -303,6 +332,7 @@ def test_conversation_reply_shows_live_search_if_list_of_templates_taller_than_s
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_more_service_templates_than_can_fit_onscreen,
|
||||
mock_get_template_folders,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.conversation_reply',
|
||||
@@ -317,6 +347,7 @@ def test_conversation_reply_shows_live_search_if_list_of_templates_fits_onscreen
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_service_templates,
|
||||
mock_get_template_folders,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.conversation_reply',
|
||||
|
||||
@@ -7,6 +7,7 @@ from notifications_python_client.errors import HTTPError
|
||||
from tests.conftest import (
|
||||
SERVICE_ONE_ID,
|
||||
TEMPLATE_ONE_ID,
|
||||
_template,
|
||||
active_caseworking_user,
|
||||
active_user_view_permissions,
|
||||
active_user_with_permissions,
|
||||
@@ -31,15 +32,6 @@ def _folder(name, folder_id=None, parent=None, users_with_permission=None):
|
||||
}
|
||||
|
||||
|
||||
def _template(template_type, name, parent=None, template_id=None):
|
||||
return {
|
||||
'id': template_id or str(uuid.uuid4()),
|
||||
'name': name,
|
||||
'template_type': template_type,
|
||||
'folder': parent,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
(
|
||||
'expected_title_tag,'
|
||||
|
||||
Reference in New Issue
Block a user