mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Group uploaded letters by day of printing
Some teams have started uploading quite a lot of letters (in the hundreds per week). They’re also uploading CSVs of emails. This means the uploads page ends up quite jumbled. This is because: - there’s just a lot of items to scan through - conceptually it’s a bit odd to have batches of things displayed alongside individual things on the same page So instead we’re going to start grouping together uploaded letters. This will be by the date on which we ‘start’ printing them, or in other words the time at which they can no longer be cancelled. This feels like a natural grouping, and it matches what we know about people’s mental models of ‘batches’ and ‘runs’ when talking about printing. This grouping will be done in the API, so all this commit need to do is: - be ready to display this new type of pseudo-job - link to the page that displays all the uploaded letters for a given print day
This commit is contained in:
@@ -91,6 +91,7 @@ def test_get_upload_hub_with_no_uploads(
|
||||
assert not page.select('.file-list-filename')
|
||||
|
||||
|
||||
@freeze_time('2017-10-10 10:10:10')
|
||||
def test_get_upload_hub_page(
|
||||
mocker,
|
||||
client_request,
|
||||
@@ -108,28 +109,41 @@ def test_get_upload_hub_page(
|
||||
|
||||
uploads = page.select('tbody tr')
|
||||
|
||||
assert len(uploads) == 3
|
||||
|
||||
assert normalize_spaces(uploads[0].text.strip()) == (
|
||||
'Uploaded letters '
|
||||
'Printing today at 5:30pm '
|
||||
'33 letters'
|
||||
)
|
||||
assert uploads[0].select_one('a.file-list-filename-large')['href'] == url_for(
|
||||
'main.uploaded_letters',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
letter_print_day='2017-10-10',
|
||||
)
|
||||
|
||||
assert normalize_spaces(uploads[1].text.strip()) == (
|
||||
'some.csv '
|
||||
'Sent 1 January 2016 at 11:09am '
|
||||
'0 sending 8 delivered 2 failed'
|
||||
)
|
||||
assert uploads[0].select_one('a.file-list-filename-large')['href'] == (
|
||||
assert uploads[1].select_one('a.file-list-filename-large')['href'] == (
|
||||
'/services/{}/jobs/job_id_1'.format(SERVICE_ONE_ID)
|
||||
)
|
||||
|
||||
assert normalize_spaces(uploads[1].text.strip()) == (
|
||||
assert normalize_spaces(uploads[2].text.strip()) == (
|
||||
'some.pdf '
|
||||
'Sent 1 January 2016 at 11:09am '
|
||||
'Firstname Lastname '
|
||||
'123 Example Street'
|
||||
)
|
||||
assert normalize_spaces(str(uploads[1].select_one('.govuk-body'))) == (
|
||||
assert normalize_spaces(str(uploads[2].select_one('.govuk-body'))) == (
|
||||
'<p class="govuk-body letter-recipient-summary"> '
|
||||
'Firstname Lastname<br/> '
|
||||
'123 Example Street<br/> '
|
||||
'</p>'
|
||||
)
|
||||
assert uploads[1].select_one('a.file-list-filename-large')['href'] == (
|
||||
assert uploads[2].select_one('a.file-list-filename-large')['href'] == (
|
||||
'/services/{}/notification/letter_id_1'.format(SERVICE_ONE_ID)
|
||||
)
|
||||
|
||||
|
||||
@@ -353,27 +353,27 @@ def test_format_datetime_relative(time, human_readable_datetime):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('utc_datetime', [
|
||||
'2018-08-01 23:00',
|
||||
'2018-08-01 16:29',
|
||||
'2018-11-01 00:00',
|
||||
'2018-11-01 10:00',
|
||||
'2018-11-01 17:29',
|
||||
'2018-08-01T23:00:00+00:00',
|
||||
'2018-08-01T16:29:00+00:00',
|
||||
'2018-11-01T00:00:00+00:00',
|
||||
'2018-11-01T10:00:00+00:00',
|
||||
'2018-11-01T17:29:00+00:00',
|
||||
])
|
||||
def test_printing_today_or_tomorrow_returns_today(utc_datetime):
|
||||
with freeze_time(utc_datetime):
|
||||
assert printing_today_or_tomorrow() == 'today'
|
||||
assert printing_today_or_tomorrow(utc_datetime) == 'today'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('datetime', [
|
||||
'2018-08-01 22:59',
|
||||
'2018-08-01 16:30',
|
||||
'2018-11-01 17:30',
|
||||
'2018-11-01 21:00',
|
||||
'2018-11-01 23:59',
|
||||
@pytest.mark.parametrize('utc_datetime', [
|
||||
'2018-08-01T22:59:00+00:00',
|
||||
'2018-08-01T16:30:00+00:00',
|
||||
'2018-11-01T17:30:00+00:00',
|
||||
'2018-11-01T21:00:00+00:00',
|
||||
'2018-11-01T23:59:00+00:00',
|
||||
])
|
||||
def test_printing_today_or_tomorrow_returns_tomorrow(datetime):
|
||||
with freeze_time(datetime):
|
||||
assert printing_today_or_tomorrow() == 'tomorrow'
|
||||
def test_printing_today_or_tomorrow_returns_tomorrow(utc_datetime):
|
||||
with freeze_time(utc_datetime):
|
||||
assert printing_today_or_tomorrow(utc_datetime) == 'tomorrow'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('created_at, current_datetime', [
|
||||
|
||||
@@ -1795,28 +1795,46 @@ def mock_get_jobs(mocker, api_user_active):
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_uploads(mocker, api_user_active):
|
||||
def _get_uploads(service_id, limit_days=None, statuses=None, page=1):
|
||||
uploads = [{'id': 'job_id_1',
|
||||
'original_file_name': 'some.csv',
|
||||
'notification_count': 10,
|
||||
'created_at': '2016-01-01 11:09:00.061258',
|
||||
'statistics': [{'count': 8, 'status': 'delivered'}, {'count': 2, 'status': 'temporary-failure'}],
|
||||
'upload_type': 'job',
|
||||
'template_type': 'sms',
|
||||
'recipient': None},
|
||||
{'id': 'letter_id_1',
|
||||
'original_file_name': 'some.pdf',
|
||||
'notification_count': 1,
|
||||
'created_at': '2016-01-01 11:09:00.061258',
|
||||
'statistics': [{'count': 1, 'status': 'delivered'}],
|
||||
'upload_type': 'letter',
|
||||
'template_type': None,
|
||||
'recipient': (
|
||||
'Firstname Lastname\n'
|
||||
'123 Example Street\n'
|
||||
'City of Town\n'
|
||||
'XM4 5QQ'
|
||||
)}
|
||||
]
|
||||
uploads = [
|
||||
{
|
||||
'id': None,
|
||||
'original_file_name': 'Uploaded letters',
|
||||
'recipient': None,
|
||||
'notification_count': 33,
|
||||
'template_type': 'letter',
|
||||
'created_at': '2017-10-10 16:30:00',
|
||||
'statistics': [],
|
||||
'upload_type': 'letter_day',
|
||||
},
|
||||
{
|
||||
'id': 'job_id_1',
|
||||
'original_file_name': 'some.csv',
|
||||
'notification_count': 10,
|
||||
'created_at': '2016-01-01 11:09:00.061258',
|
||||
'statistics': [
|
||||
{'count': 8, 'status': 'delivered'},
|
||||
{'count': 2, 'status': 'temporary-failure'}
|
||||
],
|
||||
'upload_type': 'job',
|
||||
'template_type': 'sms',
|
||||
'recipient': None,
|
||||
},
|
||||
{
|
||||
'id': 'letter_id_1',
|
||||
'original_file_name': 'some.pdf',
|
||||
'notification_count': 1,
|
||||
'created_at': '2016-01-01 11:09:00.061258',
|
||||
'statistics': [{'count': 1, 'status': 'delivered'}],
|
||||
'upload_type': 'letter',
|
||||
'template_type': None,
|
||||
'recipient': (
|
||||
'Firstname Lastname\n'
|
||||
'123 Example Street\n'
|
||||
'City of Town\n'
|
||||
'XM4 5QQ'
|
||||
),
|
||||
},
|
||||
]
|
||||
return {
|
||||
'data': uploads,
|
||||
'links': {
|
||||
|
||||
Reference in New Issue
Block a user