mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Show upcoming jobs on the dashboard
On the dashboard: - adds a new ‘in the next 24 hours’ section to the dashboard which lists upcoming jobs - tweaks some spacing on the dashboard so that it doesn’t look like too much of a mess - don’t show scheduled jobs in the table of normal jobs On the jobs page: - don’t show scheduled jobs
This commit is contained in:
@@ -158,7 +158,8 @@ def job_json(
|
||||
notification_count=1,
|
||||
notifications_sent=1,
|
||||
notifications_requested=1,
|
||||
job_status='Delivered'
|
||||
job_status='Delivered',
|
||||
scheduled_for=''
|
||||
):
|
||||
if job_id is None:
|
||||
job_id = str(generate_uuid())
|
||||
@@ -180,8 +181,10 @@ def job_json(
|
||||
'created_by': created_by_json(
|
||||
created_by.id,
|
||||
created_by.name,
|
||||
created_by.email_address)
|
||||
}
|
||||
created_by.email_address
|
||||
),
|
||||
'scheduled_for': scheduled_for
|
||||
}
|
||||
return data
|
||||
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ def test_should_show_recent_templates_on_dashboard(app_,
|
||||
assert 'Test Service' in headers
|
||||
assert 'In the last 7 days' in headers
|
||||
|
||||
table_rows = page.find_all('tbody')[0].find_all('tr')
|
||||
table_rows = page.find_all('tbody')[1].find_all('tr')
|
||||
|
||||
assert len(table_rows) == 2
|
||||
|
||||
@@ -159,20 +159,20 @@ def test_should_show_all_templates_on_template_statistics_page(
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
def test_should_show_recent_jobs_on_dashboard(
|
||||
app_,
|
||||
mocker,
|
||||
api_user_active,
|
||||
mock_get_service,
|
||||
mock_get_service_templates,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
mock_login,
|
||||
mock_get_template_statistics,
|
||||
mock_get_detailed_service,
|
||||
mock_get_jobs,
|
||||
mock_has_permissions,
|
||||
mock_get_usage
|
||||
def test_should_show_upcoming_jobs_on_dashboard(
|
||||
app_,
|
||||
mocker,
|
||||
api_user_active,
|
||||
mock_get_service,
|
||||
mock_get_service_templates,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
mock_login,
|
||||
mock_get_template_statistics,
|
||||
mock_get_detailed_service,
|
||||
mock_get_jobs,
|
||||
mock_has_permissions,
|
||||
mock_get_usage
|
||||
):
|
||||
with app_.test_request_context(), app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
@@ -182,7 +182,40 @@ def test_should_show_recent_jobs_on_dashboard(
|
||||
assert response.status_code == 200
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
table_rows = page.find_all('tbody')[1].find_all('tr')
|
||||
|
||||
table_rows = page.find_all('tbody')[0].find_all('tr')
|
||||
assert len(table_rows) == 1
|
||||
|
||||
assert 'send_me_later.csv' in table_rows[0].find_all('th')[0].text
|
||||
assert 'Sending at 11:09am' in table_rows[0].find_all('th')[0].text
|
||||
assert table_rows[0].find_all('td')[0].text.strip() == '1'
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
def test_should_show_recent_jobs_on_dashboard(
|
||||
app_,
|
||||
mocker,
|
||||
api_user_active,
|
||||
mock_get_service,
|
||||
mock_get_service_templates,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
mock_login,
|
||||
mock_get_template_statistics,
|
||||
mock_get_detailed_service,
|
||||
mock_get_jobs,
|
||||
mock_has_permissions,
|
||||
mock_get_usage
|
||||
):
|
||||
with app_.test_request_context(), app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.service_dashboard', service_id=SERVICE_ONE_ID))
|
||||
|
||||
mock_get_jobs.assert_called_once_with(SERVICE_ONE_ID, limit_days=7)
|
||||
assert response.status_code == 200
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
table_rows = page.find_all('tbody')[2].find_all('tr')
|
||||
|
||||
assert "Test message" not in page.text
|
||||
assert len(table_rows) == 4
|
||||
@@ -194,7 +227,7 @@ def test_should_show_recent_jobs_on_dashboard(
|
||||
"thisisatest.csv",
|
||||
)):
|
||||
assert filename in table_rows[index].find_all('th')[0].text
|
||||
assert 'Uploaded 1 January at 11:09' in table_rows[index].find_all('th')[0].text
|
||||
assert 'Sent 1 January 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)
|
||||
|
||||
|
||||
@@ -874,13 +874,21 @@ def mock_get_job_in_progress(mocker, api_user_active):
|
||||
def mock_get_jobs(mocker, api_user_active):
|
||||
def _get_jobs(service_id, limit_days=None):
|
||||
return {"data": [
|
||||
job_json(service_id, api_user_active, original_file_name=filename)
|
||||
for filename in (
|
||||
"Test message",
|
||||
"export 1/1/2016.xls",
|
||||
"all email addresses.xlsx",
|
||||
"applicants.ods",
|
||||
"thisisatest.csv",
|
||||
job_json(
|
||||
service_id,
|
||||
api_user_active,
|
||||
original_file_name=filename,
|
||||
scheduled_for=scheduled_for,
|
||||
job_status=job_status
|
||||
)
|
||||
for filename, scheduled_for, job_status in (
|
||||
("Test message", '', ''),
|
||||
("Test message", '2016-01-01 11:09:00.061258', 'scheduled'),
|
||||
("export 1/1/2016.xls", '', ''),
|
||||
("all email addresses.xlsx", '', 'pending'),
|
||||
("applicants.ods", '', ''),
|
||||
("thisisatest.csv", '', ''),
|
||||
("send_me_later.csv", '2016-01-01 11:09:00.061258', 'scheduled')
|
||||
)
|
||||
]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user