mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 10:28:41 -04:00
Merge pull request #1743 from alphagov/all-pages-letter
Show all pages of a sent letter
This commit is contained in:
@@ -14,7 +14,7 @@ from app import (
|
|||||||
current_service
|
current_service
|
||||||
)
|
)
|
||||||
from app.main import main
|
from app.main import main
|
||||||
from app.template_previews import TemplatePreview
|
from app.template_previews import TemplatePreview, get_page_count_for_letter
|
||||||
from app.utils import (
|
from app.utils import (
|
||||||
user_has_permissions,
|
user_has_permissions,
|
||||||
get_help_argument,
|
get_help_argument,
|
||||||
@@ -40,6 +40,7 @@ def view_notification(service_id, notification_id):
|
|||||||
notification_id=notification_id,
|
notification_id=notification_id,
|
||||||
filetype='png',
|
filetype='png',
|
||||||
),
|
),
|
||||||
|
page_count=get_page_count_for_letter(notification['template']),
|
||||||
show_recipient=True,
|
show_recipient=True,
|
||||||
redact_missing_personalisation=True,
|
redact_missing_personalisation=True,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -109,13 +109,19 @@ def test_notification_page_doesnt_link_to_template_in_tour(
|
|||||||
|
|
||||||
|
|
||||||
@freeze_time("2016-01-01 01:01")
|
@freeze_time("2016-01-01 01:01")
|
||||||
def test_notification_page_shows_status_of_letter_notification(
|
def test_notification_page_shows_page_for_letter_notification(
|
||||||
client_request,
|
client_request,
|
||||||
mocker,
|
mocker,
|
||||||
fake_uuid,
|
fake_uuid,
|
||||||
):
|
):
|
||||||
|
|
||||||
|
count_of_pages = 3
|
||||||
|
|
||||||
mock_get_notification(mocker, fake_uuid, template_type='letter')
|
mock_get_notification(mocker, fake_uuid, template_type='letter')
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.notifications.get_page_count_for_letter',
|
||||||
|
return_value=count_of_pages
|
||||||
|
)
|
||||||
|
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.view_notification',
|
'main.view_notification',
|
||||||
@@ -131,6 +137,15 @@ def test_notification_page_shows_status_of_letter_notification(
|
|||||||
)
|
)
|
||||||
assert page.select('p.notification-status') == []
|
assert page.select('p.notification-status') == []
|
||||||
|
|
||||||
|
letter_images = page.select('main img')
|
||||||
|
|
||||||
|
assert len(letter_images) == count_of_pages
|
||||||
|
|
||||||
|
for index in range(1, count_of_pages + 1):
|
||||||
|
assert page.select('img')[index]['src'].endswith(
|
||||||
|
'.png?page={}'.format(index)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('filetype', [
|
@pytest.mark.parametrize('filetype', [
|
||||||
'pdf', 'png'
|
'pdf', 'png'
|
||||||
@@ -193,6 +208,10 @@ def test_notification_page_has_link_to_send_another_for_sms(
|
|||||||
|
|
||||||
service_one['permissions'] = service_permissions
|
service_one['permissions'] = service_permissions
|
||||||
mock_get_notification(mocker, fake_uuid, template_type=template_type)
|
mock_get_notification(mocker, fake_uuid, template_type=template_type)
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.notifications.get_page_count_for_letter',
|
||||||
|
return_value=1
|
||||||
|
)
|
||||||
|
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.view_notification',
|
'main.view_notification',
|
||||||
@@ -237,6 +256,10 @@ def test_notification_page_has_link_to_download_letter(
|
|||||||
):
|
):
|
||||||
|
|
||||||
mock_get_notification(mocker, fake_uuid, template_type=template_type)
|
mock_get_notification(mocker, fake_uuid, template_type=template_type)
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.notifications.get_page_count_for_letter',
|
||||||
|
return_value=1
|
||||||
|
)
|
||||||
|
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.view_notification',
|
'main.view_notification',
|
||||||
|
|||||||
Reference in New Issue
Block a user