mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Add some summaries of letter validation errors
We show letter validation errors in two places: 1. In response to a user uploading a PDF Here we use the error banner pattern because the problem is as a direct consequence of a user’s action, and is blocking them from continuing. 2. Once a PDF provided through the API has been validated We use a less prominent pattern of red text with no border because the message is reporting on something that’s already happened, and which wasn’t a direct consequence of the user clicking something Because the context and patterns used are different we need slightly different content in each of these situations. Previously we tried to reuse the same content to make the code cleaner and less repetitive. But ultimately a clear interface trumps clear code.
This commit is contained in:
@@ -413,24 +413,57 @@ def test_get_letter_validation_error_for_unknown_error():
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('error_message, expected_title, expected_content', [
|
||||
('letter-not-a4-portrait-oriented', 'Your letter is not A4 portrait size',
|
||||
'You need to change the size or orientation of page 2. <br>Files must meet our '
|
||||
'<a href="https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.4.pdf" '
|
||||
'target="_blank">letter specification</a>.'),
|
||||
('content-outside-printable-area', 'Your content is outside the printable area',
|
||||
'You need to edit page 2.<br>Files must meet our '
|
||||
'<a href="https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.4.pdf" '
|
||||
'target="_blank">letter specification</a>.'),
|
||||
('letter-too-long', 'Your letter is too long',
|
||||
'Letters must be 10 pages or less. <br>Your letter is 13 pages long.')
|
||||
@pytest.mark.parametrize('error_message, expected_title, expected_content, expected_summary', [
|
||||
(
|
||||
'letter-not-a4-portrait-oriented',
|
||||
'Your letter is not A4 portrait size',
|
||||
(
|
||||
'You need to change the size or orientation of page 2. <br>Files must meet our '
|
||||
'<a href="https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.4.pdf" '
|
||||
'target="_blank">letter specification</a>.'
|
||||
),
|
||||
(
|
||||
'Validation failed because page 2 is not A4 portrait size.<br>'
|
||||
'Files must meet our <a href="https://docs.notifications.service.gov.uk/'
|
||||
'documentation/images/notify-pdf-letter-spec-v2.4.pdf" target="_blank">'
|
||||
'letter specification</a>.'
|
||||
),
|
||||
),
|
||||
(
|
||||
'content-outside-printable-area',
|
||||
'Your content is outside the printable area',
|
||||
(
|
||||
'You need to edit page 2.<br>Files must meet our '
|
||||
'<a href="https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.4.pdf" '
|
||||
'target="_blank">letter specification</a>.'
|
||||
),
|
||||
(
|
||||
'Validation failed because content is outside the printable area '
|
||||
'on page 2.<br>Files must meet our <a href="https://docs.notifications.service.gov.uk/'
|
||||
'documentation/images/notify-pdf-letter-spec-v2.4.pdf" target="_blank">'
|
||||
'letter specification</a>.'
|
||||
),
|
||||
),
|
||||
(
|
||||
'letter-too-long',
|
||||
'Your letter is too long',
|
||||
(
|
||||
'Letters must be 10 pages or less. <br>Your letter is 13 pages long.'
|
||||
),
|
||||
(
|
||||
'Validation failed because this letter is 13 pages long.<br>'
|
||||
'Letters must be 10 pages or less.'
|
||||
),
|
||||
),
|
||||
])
|
||||
def test_get_letter_validation_error_for_known_errors(
|
||||
error_message,
|
||||
expected_title,
|
||||
expected_content,
|
||||
expected_summary,
|
||||
):
|
||||
error = get_letter_validation_error(error_message, invalid_pages=[2], page_count=13)
|
||||
|
||||
assert error['title'] == expected_title
|
||||
assert expected_content in error['detail']
|
||||
assert error['summary'] == expected_summary
|
||||
|
||||
Reference in New Issue
Block a user