Merge pull request #3333 from alphagov/uploads-page-ready

Redesign the uploads page to accommodate different kinds of uploads
This commit is contained in:
Chris Hill-Scott
2020-03-03 13:44:38 +00:00
committed by GitHub
14 changed files with 233 additions and 81 deletions

View File

@@ -937,8 +937,11 @@ def test_should_show_recent_jobs_on_dashboard(
)):
assert filename in table_rows[index].find_all('th')[0].text
assert 'Sent today at 11:09' in table_rows[index].find_all('th')[0].text
for column_index, count in enumerate((1, 0, 0)):
assert table_rows[index].find_all('td')[column_index].text.strip() == str(count)
assert normalize_spaces(
table_rows[index].select_one('td').text
) == (
'1 sending 0 delivered 0 failed'
)
@pytest.mark.parametrize('extra_permissions', (

View File

@@ -21,23 +21,23 @@ from tests.conftest import (
@pytest.mark.parametrize('user, expected_rows', [
(create_active_user_with_permissions(), (
(
'File Sending Delivered Failed'
'File Status'
),
(
'export 1/1/2016.xls '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'all email addresses.xlsx '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'applicants.ods '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'thisisatest.csv '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
)),
(create_active_caseworking_user(), (
@@ -53,23 +53,23 @@ from tests.conftest import (
'Sending 1 January 2016 at 11:09pm 1'
),
(
'File Sending Delivered Failed'
'File Status'
),
(
'export 1/1/2016.xls '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'all email addresses.xlsx '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'applicants.ods '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'thisisatest.csv '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
)),
])
@@ -123,23 +123,23 @@ def test_jobs_page_doesnt_show_scheduled_on_page_2(
for index, row in enumerate((
(
'File Sending Delivered Failed'
'File Status'
),
(
'export 1/1/2016.xls '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'all email addresses.xlsx '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'applicants.ods '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
(
'thisisatest.csv '
'Sent today at 12:12pm 1 0 0'
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
),
)):
assert normalize_spaces(page.select('tr')[index].text) == row
@@ -398,7 +398,7 @@ def test_should_show_old_job(
def test_should_show_letter_job(
client_request,
mock_get_service_letter_template,
mock_get_job,
mock_get_letter_job,
mock_get_service_data_retention,
fake_uuid,
mocker,
@@ -460,7 +460,7 @@ def test_should_show_letter_job(
def test_should_show_letter_job_with_banner_after_sending_before_1730(
client_request,
mock_get_service_letter_template,
mock_get_job,
mock_get_letter_job,
mock_get_notifications,
mock_get_service_data_retention,
fake_uuid,
@@ -483,7 +483,7 @@ def test_should_show_letter_job_with_banner_after_sending_before_1730(
def test_should_show_letter_job_with_banner_when_there_are_multiple_CSV_rows(
client_request,
mock_get_service_letter_template,
mock_get_job_in_progress,
mock_get_letter_job_in_progress,
mock_get_notifications,
mock_get_service_data_retention,
fake_uuid,
@@ -506,7 +506,7 @@ def test_should_show_letter_job_with_banner_when_there_are_multiple_CSV_rows(
def test_should_show_letter_job_with_banner_after_sending_after_1730(
client_request,
mock_get_service_letter_template,
mock_get_job,
mock_get_letter_job,
mock_get_notifications,
mock_get_service_data_retention,
fake_uuid,
@@ -601,7 +601,8 @@ def test_should_cancel_letter_job(
active_user_with_permissions,
job_id=job_id,
created_at="2019-06-20T15:30:00.000001+00:00",
job_status="finished"
job_status="finished",
template_type="letter",
)
mocker.patch('app.job_api_client.get_job', side_effect=[{"data": job}])
notifications_json = notification_json(SERVICE_ONE_ID, job=job, status="created", template_type="letter")
@@ -819,7 +820,7 @@ def test_time_left(job_created_at, expected_message):
def test_should_show_letter_job_with_first_class_if_notifications_are_first_class(
client_request,
mock_get_service_letter_template,
mock_get_job,
mock_get_letter_job,
mock_get_service_data_retention,
fake_uuid,
mocker,
@@ -840,7 +841,7 @@ def test_should_show_letter_job_with_first_class_if_notifications_are_first_clas
def test_should_show_letter_job_with_first_class_if_no_notifications(
client_request,
service_one,
mock_get_job,
mock_get_letter_job,
fake_uuid,
mock_get_notifications_with_no_notifications,
mock_get_service_data_retention,

View File

@@ -39,10 +39,13 @@ def test_no_upload_letters_button_without_permission(
@pytest.mark.parametrize('extra_permissions, expected_empty_message', (
(['letter'], (
'You have not uploaded any files yet'
'You have not uploaded any files yet. '
'To upload a list of contact details, first choose a template.'
)),
(['letter', 'upload_letters'], (
'Upload a letter and Notify will print, pack and post it for you.'
'You have not uploaded any files yet. '
'Upload a letter and Notify will print, pack and post it for you. '
'To upload a list of contact details, first choose a template.'
)),
))
def test_get_upload_hub_with_no_uploads(
@@ -56,9 +59,9 @@ def test_get_upload_hub_with_no_uploads(
mocker.patch('app.job_api_client.get_jobs', return_value={'data': []})
service_one['permissions'] += extra_permissions
page = client_request.get('main.uploads', service_id=SERVICE_ONE_ID)
assert normalize_spaces(
page.select_one('.table-empty-message').text
) == expected_empty_message
assert normalize_spaces(' '.join(
paragraph.text for paragraph in page.select('main p')
)) == expected_empty_message
assert not page.select('.file-list-filename')
@@ -76,13 +79,32 @@ def test_get_upload_hub_page(
'main.upload_letter', service_id=SERVICE_ONE_ID
)
assert page.find_all(
'a', {'class': 'file-list-filename'}
)[0].attrs['href'] == '/services/{}/jobs/job_id_1'.format(SERVICE_ONE_ID)
uploads = page.select('tbody tr')
assert page.find_all(
'a', {'class': 'file-list-filename'}
)[1].attrs['href'] == '/services/{}/notification/letter_id_1'.format(SERVICE_ONE_ID)
assert normalize_spaces(uploads[0].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'] == (
'/services/{}/jobs/job_id_1'.format(SERVICE_ONE_ID)
)
assert normalize_spaces(uploads[1].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'))) == (
'<p class="govuk-body govuk-!-margin-bottom-1"> '
'Firstname Lastname<br/> '
'123 Example Street<br/> '
'</p>'
)
assert uploads[1].select_one('a.file-list-filename-large')['href'] == (
'/services/{}/notification/letter_id_1'.format(SERVICE_ONE_ID)
)
def test_get_upload_letter(client_request):
@@ -643,15 +665,35 @@ def test_uploads_page_shows_scheduled_jobs(
normalize_spaces(row.text) for row in page.select('tr')
] == [
(
'File Messages to be sent'
'File Status'
),
(
'send_me_later.csv '
'Sending 1 January 2016 at 11:09am 1'
'Sending 1 January 2016 at 11:09am '
'1 text message waiting to send'
),
(
'even_later.csv '
'Sending 1 January 2016 at 11:09pm 1'
'Sending 1 January 2016 at 11:09pm '
'1 text message waiting to send'
),
]
assert not page.select('.table-empty-message')
def test_get_uploads_shows_pagination(
client_request,
active_user_with_permissions,
mock_get_jobs,
mock_get_uploads,
):
page = client_request.get('main.uploads', service_id=SERVICE_ONE_ID)
assert normalize_spaces(page.select_one('.next-page').text) == (
'Next page '
'page 2'
)
assert normalize_spaces(page.select_one('.previous-page').text) == (
'Previous page '
'page 0'
)