mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Show jobs on contact list
It’s a bit unintuitive that starting a job from a contact list makes a copy of the file, which has no relationship to the list it was copied from. This is more of an implementation detail, rather than something that comes from people’s mental models of what is going on. Or at least that’s what I hypothesise. I think it’s clearer to show jobs that come from contact lists within the lists that they were created from. By naming the jobs by template this gives a clearer view of what messages have been sent to the group over time.
This commit is contained in:
@@ -361,6 +361,7 @@ def job_json(
|
||||
template_id=None,
|
||||
template_version=1,
|
||||
template_type='sms',
|
||||
template_name='Example template',
|
||||
created_at=None,
|
||||
bucket_name='',
|
||||
original_file_name="thisisatest.csv",
|
||||
@@ -381,6 +382,7 @@ def job_json(
|
||||
'id': job_id,
|
||||
'service': service_id,
|
||||
'template': template_id,
|
||||
'template_name': template_name,
|
||||
'template_version': template_version,
|
||||
'template_type': template_type,
|
||||
'original_file_name': original_file_name,
|
||||
|
||||
@@ -457,6 +457,64 @@ def test_view_contact_list(
|
||||
mocker,
|
||||
client_request,
|
||||
mock_get_contact_list,
|
||||
mock_get_no_jobs,
|
||||
mock_get_service_data_retention,
|
||||
fake_uuid,
|
||||
):
|
||||
mocker.patch('app.models.contact_list.s3download', return_value='\n'.join(
|
||||
['email address'] + [
|
||||
f'test-{i}@example.com' for i in range(51)
|
||||
]
|
||||
))
|
||||
page = client_request.get(
|
||||
'main.contact_list',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
contact_list_id=fake_uuid,
|
||||
)
|
||||
assert normalize_spaces(page.select_one('h1').text) == (
|
||||
'EmergencyContactList.xls'
|
||||
)
|
||||
assert normalize_spaces(page.select('main p')[0].text) == (
|
||||
'Uploaded by Test User today at 10:59am.'
|
||||
)
|
||||
assert normalize_spaces(page.select('main p')[1].text) == (
|
||||
'Not used yet.'
|
||||
)
|
||||
assert normalize_spaces(page.select_one('main h2').text) == (
|
||||
'51 saved email addresses'
|
||||
)
|
||||
assert page.select_one('.js-stick-at-bottom-when-scrolling a[download]')['href'] == url_for(
|
||||
'main.download_contact_list',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
contact_list_id=fake_uuid,
|
||||
)
|
||||
assert len(page.select('tbody tr')) == 50
|
||||
assert [
|
||||
normalize_spaces(page.select('tbody tr')[0].text),
|
||||
normalize_spaces(page.select('tbody tr')[1].text),
|
||||
|
||||
normalize_spaces(page.select('tbody tr')[48].text),
|
||||
normalize_spaces(page.select('tbody tr')[49].text),
|
||||
] == [
|
||||
'test-0@example.com',
|
||||
'test-1@example.com',
|
||||
|
||||
'test-48@example.com',
|
||||
'test-49@example.com',
|
||||
]
|
||||
assert 'test-50@example.com' not in page.select_one('tbody').text
|
||||
assert normalize_spaces(page.select_one('.table-show-more-link').text) == (
|
||||
'Only showing the first 50 rows'
|
||||
)
|
||||
|
||||
|
||||
@freeze_time('2015-12-31 16:51:56')
|
||||
def test_view_jobs_for_contact_list(
|
||||
mocker,
|
||||
client_request,
|
||||
mock_get_contact_list,
|
||||
mock_get_jobs,
|
||||
mock_get_service_data_retention,
|
||||
fake_uuid,
|
||||
):
|
||||
mocker.patch('app.models.contact_list.s3download', return_value='\n'.join(
|
||||
@@ -471,28 +529,51 @@ def test_view_contact_list(
|
||||
'EmergencyContactList.xls'
|
||||
)
|
||||
assert normalize_spaces(page.select('main p')[0].text) == (
|
||||
'Uploaded by Test User today at 10:59am'
|
||||
'Uploaded by Test User on 13 March 2020 at 10:59am.'
|
||||
)
|
||||
assert normalize_spaces(page.select('main p')[1].text) == (
|
||||
'Download this list 51 email addresses'
|
||||
'Used 6 times in the last 7 days.'
|
||||
)
|
||||
assert page.select_one('a[download]')['href'] == url_for(
|
||||
'main.download_contact_list',
|
||||
assert [
|
||||
normalize_spaces(row.text)
|
||||
for row in page.select_one('table').select('tr')
|
||||
] == [
|
||||
'Template Status',
|
||||
(
|
||||
'Template Y '
|
||||
'Sending tomorrow at 11:09pm '
|
||||
'1 text message waiting to send'
|
||||
),
|
||||
(
|
||||
'Template Z '
|
||||
'Sending tomorrow at 11:09am '
|
||||
'1 text message waiting to send'
|
||||
),
|
||||
(
|
||||
'Template A '
|
||||
'Sent today at 4:51pm '
|
||||
'1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'Template B '
|
||||
'Sent today at 4:51pm '
|
||||
'1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'Template C '
|
||||
'Sent today at 4:51pm '
|
||||
'1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'Template D '
|
||||
'Sent today at 4:51pm '
|
||||
'1 sending 0 delivered 0 failed'
|
||||
),
|
||||
]
|
||||
assert page.select_one('table a')['href'] == url_for(
|
||||
'main.view_job',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
contact_list_id=fake_uuid,
|
||||
)
|
||||
assert normalize_spaces(page.select_one('table').text).startswith(
|
||||
'Email addresses '
|
||||
'1 email address '
|
||||
'2 test@example.com '
|
||||
'3 test@example.com '
|
||||
)
|
||||
assert normalize_spaces(page.select_one('table').text).endswith(
|
||||
'50 test@example.com '
|
||||
'51 test@example.com'
|
||||
)
|
||||
assert normalize_spaces(page.select_one('.table-show-more-link').text) == (
|
||||
'Only showing the first 50 rows'
|
||||
job_id=fake_uuid,
|
||||
)
|
||||
|
||||
|
||||
@@ -543,6 +624,8 @@ def test_confirm_delete_contact_list(
|
||||
mocker,
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_jobs,
|
||||
mock_get_service_data_retention,
|
||||
mock_get_contact_list,
|
||||
):
|
||||
mocker.patch(
|
||||
|
||||
@@ -20,6 +20,7 @@ def test_get_jobs(mock_get_jobs):
|
||||
'finished',
|
||||
'sending limits exceeded',
|
||||
'ready to send',
|
||||
'scheduled',
|
||||
'sent to dvla',
|
||||
'pending',
|
||||
'in progress',
|
||||
|
||||
@@ -1807,7 +1807,7 @@ def mock_has_no_jobs(mocker):
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_jobs(mocker, api_user_active):
|
||||
def mock_get_jobs(mocker, api_user_active, fake_uuid):
|
||||
def _get_jobs(service_id, limit_days=None, statuses=None, contact_list_id=None, page=1):
|
||||
if statuses is None:
|
||||
statuses = ['', 'scheduled', 'pending', 'cancelled', 'finished']
|
||||
@@ -1816,19 +1816,21 @@ def mock_get_jobs(mocker, api_user_active):
|
||||
job_json(
|
||||
service_id,
|
||||
api_user_active,
|
||||
job_id=fake_uuid,
|
||||
original_file_name=filename,
|
||||
scheduled_for=scheduled_for,
|
||||
job_status=job_status,
|
||||
template_version=template_version,
|
||||
template_name=template_name,
|
||||
)
|
||||
for filename, scheduled_for, job_status, template_version in (
|
||||
('export 1/1/2016.xls', '', 'finished', 1),
|
||||
('all email addresses.xlsx', '', 'pending', 1),
|
||||
('applicants.ods', '', 'finished', 1),
|
||||
('thisisatest.csv', '', 'finished', 2),
|
||||
('send_me_later.csv', '2016-01-01 11:09:00.061258', 'scheduled', 1),
|
||||
('even_later.csv', '2016-01-01 23:09:00.061258', 'scheduled', 1),
|
||||
('full_of_regret.csv', '2016-01-01 23:09:00.061258', 'cancelled', 1)
|
||||
for filename, scheduled_for, job_status, template_name, template_version in (
|
||||
('full_of_regret.csv', '2016-01-01 23:09:00.061258', 'cancelled', 'Template X', 1),
|
||||
('even_later.csv', '2016-01-01 23:09:00.061258', 'scheduled', 'Template Y', 1),
|
||||
('send_me_later.csv', '2016-01-01 11:09:00.061258', 'scheduled', 'Template Z', 1),
|
||||
('export 1/1/2016.xls', '', 'finished', 'Template A', 1),
|
||||
('all email addresses.xlsx', '', 'pending', 'Template B', 1),
|
||||
('applicants.ods', '', 'finished', 'Template C', 1),
|
||||
('thisisatest.csv', '', 'finished', 'Template D', 2),
|
||||
)
|
||||
]
|
||||
return {
|
||||
@@ -2030,6 +2032,17 @@ def mock_get_no_uploads(mocker, api_user_active):
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_no_jobs(mocker, api_user_active):
|
||||
mocker.patch(
|
||||
'app.models.job.PaginatedJobs.client_method',
|
||||
return_value={
|
||||
'data': [],
|
||||
'links': {},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_create_contact_list(mocker, api_user_active):
|
||||
def _create(
|
||||
|
||||
Reference in New Issue
Block a user