diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py
index 29e2a4c62..252ae2927 100644
--- a/app/main/views/notifications.py
+++ b/app/main/views/notifications.py
@@ -25,6 +25,7 @@ from app import (
notification_api_client,
)
from app.main import main
+from app.notify_client.api_key_api_client import KEY_TYPE_TEST
from app.template_previews import get_page_count_for_letter
from app.utils import (
DELIVERED_STATUSES,
@@ -144,7 +145,10 @@ def get_single_notification_partials(notification):
),
'status': render_template(
'partials/notifications/status.html',
- notification=notification
+ notification=notification,
+ sent_with_test_key=(
+ notification.get('key_type') == KEY_TYPE_TEST
+ ),
),
}
diff --git a/app/templates/partials/notifications/status.html b/app/templates/partials/notifications/status.html
index 780445799..0886ca352 100644
--- a/app/templates/partials/notifications/status.html
+++ b/app/templates/partials/notifications/status.html
@@ -9,5 +9,8 @@
{% if notification.status|format_notification_status_as_url %}
{% endif %}
+ {% if sent_with_test_key %}
+ (test)
+ {% endif %}
diff --git a/app/templates/views/api/index.html b/app/templates/views/api/index.html
index ebd5781f1..274e24bcf 100644
--- a/app/templates/views/api/index.html
+++ b/app/templates/views/api/index.html
@@ -2,6 +2,7 @@
{% from "components/table.html" import list_table, field, hidden_field_heading %}
{% from "components/api-key.html" import api_key %}
{% from "components/banner.html" import banner_wrapper %}
+{% from "components/message-count-label.html" import message_count_label %}
{% block service_page_title %}
API integration
@@ -73,8 +74,8 @@
{{ notification[key] }}
{% endif %}
{% endfor %}
- {% if notification['notification_type'] == 'letter' and notification.status not in ('pending-virus-check', 'virus-scan-failed') %}
- View letter
+ {% if notification.status not in ('pending-virus-check', 'virus-scan-failed') %}
+ View {{ message_count_label(1, notification.template.template_type, suffix='') }}
{% endif %}
diff --git a/tests/app/main/views/test_api_integration.py b/tests/app/main/views/test_api_integration.py
index 5662e5139..3cf0718b3 100644
--- a/tests/app/main/views/test_api_integration.py
+++ b/tests/app/main/views/test_api_integration.py
@@ -70,27 +70,26 @@ def test_should_show_api_page_with_no_notifications(
assert 'When you send messages via the API they’ll appear here.' in rows[len(rows) - 1].text.strip()
-@pytest.mark.parametrize('template_type, has_links', [
- ('sms', False),
- ('letter', True),
+@pytest.mark.parametrize('template_type, link_text', [
+ ('sms', 'View text message'),
+ ('letter', 'View letter'),
+ ('email', 'View email'),
])
def test_letter_notifications_should_have_link_to_view_letter(
client_request,
api_user_active,
- fake_uuid,
mock_has_permissions,
mocker,
template_type,
- has_links
+ link_text,
):
mock_get_notifications(mocker, api_user_active, diff_template_type=template_type)
-
page = client_request.get(
'main.api_integration',
- service_id=fake_uuid,
+ service_id=SERVICE_ONE_ID,
)
- assert (page.select_one('details a') is not None) == has_links
+ assert page.select_one('details a').text.strip() == link_text
@pytest.mark.parametrize('status', [
diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py
index 04de7bcb6..e5a81088e 100644
--- a/tests/app/main/views/test_jobs.py
+++ b/tests/app/main/views/test_jobs.py
@@ -285,7 +285,7 @@ def test_should_show_letter_job(
)
assert page.select('.banner-default-with-tick') == []
assert normalize_spaces(page.select('tbody tr')[0].text) == (
- '1 Example Street template content 1 January at 11:09am'
+ '1 Example Street template subject 1 January at 11:09am'
)
assert normalize_spaces(page.select('.keyline-block')[0].text) == (
'1 Letter'
diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py
index 383a3ae30..a0c133ea9 100644
--- a/tests/app/main/views/test_notifications.py
+++ b/tests/app/main/views/test_notifications.py
@@ -16,14 +16,19 @@ from tests.conftest import (
)
-@pytest.mark.parametrize('notification_status, expected_status', [
- ('created', 'Sending'),
- ('sending', 'Sending'),
- ('delivered', 'Delivered'),
- ('failed', 'Failed'),
- ('temporary-failure', 'Phone not accepting messages right now'),
- ('permanent-failure', 'Phone number doesn’t exist'),
- ('technical-failure', 'Technical failure'),
+@pytest.mark.parametrize('key_type, notification_status, expected_status', [
+ (None, 'created', 'Sending'),
+ (None, 'sending', 'Sending'),
+ (None, 'delivered', 'Delivered'),
+ (None, 'failed', 'Failed'),
+ (None, 'temporary-failure', 'Phone not accepting messages right now'),
+ (None, 'permanent-failure', 'Phone number doesn’t exist'),
+ (None, 'technical-failure', 'Technical failure'),
+ ('team', 'delivered', 'Delivered'),
+ ('live', 'delivered', 'Delivered'),
+ ('test', 'sending', 'Sending (test)'),
+ ('test', 'delivered', 'Delivered (test)'),
+ ('test', 'permanent-failure', 'Phone number doesn’t exist (test)'),
])
@pytest.mark.parametrize('user', [
active_user_with_permissions,
@@ -37,6 +42,7 @@ def test_notification_status_page_shows_details(
service_one,
fake_uuid,
user,
+ key_type,
notification_status,
expected_status,
):
@@ -46,7 +52,8 @@ def test_notification_status_page_shows_details(
_mock_get_notification = mock_get_notification(
mocker,
fake_uuid,
- notification_status=notification_status
+ notification_status=notification_status,
+ key_type=key_type,
)
page = client_request.get(
diff --git a/tests/conftest.py b/tests/conftest.py
index 366ef556c..1f7c024d5 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1856,7 +1856,7 @@ def mock_get_notifications(
job = None
if job_id is not None:
job = job_json(service_id, api_user_active, job_id=job_id)
- if template_type:
+ if diff_template_type or template_type:
template = template_json(
service_id,
id_=str(generate_uuid()),
@@ -2640,7 +2640,8 @@ def mock_get_notification(
redact_personalisation=False,
template_type=None,
template_name='sample template',
- is_precompiled_letter=False
+ is_precompiled_letter=False,
+ key_type=None,
):
def _get_notification(
service_id,
@@ -2670,6 +2671,8 @@ def mock_get_notification(
is_precompiled_letter=is_precompiled_letter,
name=template_name
)
+ if key_type:
+ noti['key_type'] = key_type
return noti
return mocker.patch(