Show jobs in basic view

There are some teams who send jobs on a daily/weekly basis. They have
team members who only use Notify for this purpose. So they would
probably benefit from basic view, because they don’t need to see the
dashboard.

This commit:
- adds a new item (uploaded files) to the basic view navigation for
  teams that have sent at least one job
- makes the job pages visible to basic view users

I think we should do this now, rather than as a later enhancement to
basic view. We only have one chance to announce the feature, so teams
who do send jobs may otherwise discount it as not useful for them and
the opportunity to have them use it is lost.
This commit is contained in:
Chris Hill-Scott
2018-07-30 17:40:32 +01:00
parent b35f6e9d5f
commit c551ce9a42
15 changed files with 205 additions and 36 deletions

View File

@@ -70,6 +70,7 @@ def test_can_show_notifications(
service_one,
mock_get_notifications,
mock_get_service_statistics,
mock_has_no_jobs,
user,
extra_args,
expected_update_endpoint,
@@ -193,6 +194,7 @@ def test_link_to_download_notifications(
fake_uuid,
mock_get_notifications,
mock_get_service_statistics,
mock_has_no_jobs,
user,
query_parameters,
expected_download_link,

View File

@@ -8,42 +8,147 @@ from freezegun import freeze_time
from app.main.views.jobs import get_time_left
from tests.conftest import (
SERVICE_ONE_ID,
active_caseworking_user,
active_user_with_permissions,
mock_get_notifications,
normalize_spaces,
)
def test_get_jobs_should_return_list_of_all_real_jobs(
logged_in_client,
@pytest.mark.parametrize('user, expected_rows', [
(active_user_with_permissions, (
(
'File Sending Delivered Failed'
),
(
'export 1/1/2016.xls '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'all email addresses.xlsx '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'applicants.ods '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'thisisatest.csv '
'Sent 12 December at 12:12pm 1 0 0'
),
)),
(active_caseworking_user, (
(
'File Messages to be sent'
),
(
'send_me_later.csv '
'Sending 1 January at 11:09am 1'
),
(
'even_later.csv '
'Sending 1 January at 11:09pm 1'
),
(
'File Sending Delivered Failed'
),
(
'export 1/1/2016.xls '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'all email addresses.xlsx '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'applicants.ods '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'thisisatest.csv '
'Sent 12 December at 12:12pm 1 0 0'
),
)),
])
@freeze_time("2012-12-12 12:12")
def test_jobs_page_shows_scheduled_jobs_in_basic_view(
client_request,
service_one,
active_user_with_permissions,
mock_get_jobs,
mocker,
fake_uuid,
user,
expected_rows,
):
response = logged_in_client.get(url_for('main.view_jobs', service_id=service_one['id']))
client_request.login(user(fake_uuid))
page = client_request.get('main.view_jobs', service_id=service_one['id'])
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page.h1.string == 'Uploaded files'
jobs = [x.text for x in page.tbody.find_all('a', {'class': 'file-list-filename'})]
assert len(jobs) == 4
for index, row in enumerate(expected_rows):
assert normalize_spaces(page.select('tr')[index].text) == row
@pytest.mark.parametrize('user', [
active_user_with_permissions,
active_caseworking_user,
])
def test_get_jobs_shows_page_links(
logged_in_client,
service_one,
client_request,
active_user_with_permissions,
mock_get_jobs,
mocker,
user,
fake_uuid,
):
response = logged_in_client.get(url_for('main.view_jobs', service_id=service_one['id']))
client_request.login(user(fake_uuid))
page = client_request.get('main.view_jobs', service_id=SERVICE_ONE_ID)
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert 'Next page' in page.find('li', {'class': 'next-page'}).text
assert 'Previous page' in page.find('li', {'class': 'previous-page'}).text
@pytest.mark.parametrize('user', [
active_user_with_permissions,
active_caseworking_user,
])
@freeze_time("2012-12-12 12:12")
def test_jobs_page_doesnt_show_scheduled_on_page_2(
client_request,
service_one,
active_user_with_permissions,
mock_get_jobs,
fake_uuid,
user,
):
client_request.login(user(fake_uuid))
page = client_request.get('main.view_jobs', service_id=service_one['id'], page=2)
for index, row in enumerate((
(
'File Sending Delivered Failed'
),
(
'export 1/1/2016.xls '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'all email addresses.xlsx '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'applicants.ods '
'Sent 12 December at 12:12pm 1 0 0'
),
(
'thisisatest.csv '
'Sent 12 December at 12:12pm 1 0 0'
),
)):
assert normalize_spaces(page.select('tr')[index].text) == row
@pytest.mark.parametrize('user', [
active_user_with_permissions,
active_caseworking_user,
])
@pytest.mark.parametrize(
"status_argument, expected_api_call", [
(
@@ -70,8 +175,7 @@ def test_get_jobs_shows_page_links(
)
@freeze_time("2016-01-01 11:09:00.061258")
def test_should_show_page_for_one_job(
logged_in_client,
service_one,
client_request,
active_user_with_permissions,
mock_get_service_template,
mock_get_job,
@@ -80,38 +184,37 @@ def test_should_show_page_for_one_job(
fake_uuid,
status_argument,
expected_api_call,
user,
):
response = logged_in_client.get(url_for(
page = client_request.get(
'main.view_job',
service_id=service_one['id'],
service_id=SERVICE_ONE_ID,
job_id=fake_uuid,
status=status_argument
))
)
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page.h1.text.strip() == 'thisisatest.csv'
assert ' '.join(page.find('tbody').find('tr').text.split()) == (
'07123456789 template content Delivered 1 January at 11:10am'
)
assert page.find('div', {'data-key': 'notifications'})['data-resource'] == url_for(
'main.view_job_updates',
service_id=service_one['id'],
service_id=SERVICE_ONE_ID,
job_id=fake_uuid,
status=status_argument,
)
csv_link = page.select_one('a[download]')
assert csv_link['href'] == url_for(
'main.view_job_csv',
service_id=service_one['id'],
service_id=SERVICE_ONE_ID,
job_id=fake_uuid,
status=status_argument
)
assert csv_link.text == 'Download this report'
assert page.find('span', {'id': 'time-left'}).text == 'Data available for 7 days'
mock_get_notifications.assert_called_with(
service_one['id'],
SERVICE_ONE_ID,
fake_uuid,
status=expected_api_call
)

View File

@@ -33,6 +33,7 @@ from tests.conftest import (
def test_notification_status_page_shows_details(
client_request,
mocker,
mock_has_no_jobs,
service_one,
fake_uuid,
user,

View File

@@ -901,6 +901,7 @@ def test_send_test_doesnt_show_file_contents(
mock_s3_upload,
mock_get_users_by_service,
mock_get_service_statistics,
mock_has_no_jobs,
service_one,
fake_uuid,
user,
@@ -973,6 +974,7 @@ def test_send_test_step_redirects_if_session_not_setup(
logged_in_client,
mock_get_service_statistics,
mock_get_users_by_service,
mock_has_no_jobs,
fake_uuid,
endpoint,
template_mock,
@@ -1080,6 +1082,7 @@ def test_send_one_off_does_not_send_without_the_correct_permissions(
def test_send_one_off_or_test_has_correct_page_titles(
logged_in_client,
service_one,
mock_has_no_jobs,
fake_uuid,
mocker,
template_mock,
@@ -1133,6 +1136,7 @@ def test_send_one_off_has_skip_link(
service_one,
fake_uuid,
mock_get_service_email_template,
mock_has_no_jobs,
mocker,
template_mock,
expected_link_text,
@@ -1171,6 +1175,7 @@ def test_skip_link_will_not_show_on_sms_one_off_if_service_has_no_mobile_number(
service_one,
fake_uuid,
mock_get_service_template,
mock_has_no_jobs,
mocker,
user,
):
@@ -1204,6 +1209,7 @@ def test_skip_link_will_not_show_on_sms_one_off_if_service_has_no_mobile_number(
])
def test_send_test_redirects_to_end_if_step_out_of_bounds(
logged_in_client,
mock_has_no_jobs,
service_one,
fake_uuid,
endpoint,
@@ -1250,6 +1256,7 @@ def test_send_test_redirects_to_start_if_you_skip_steps(
mock_s3_upload,
mock_get_users_by_service,
mock_get_service_statistics,
mock_has_no_jobs,
mocker,
endpoint,
expected_redirect,
@@ -1292,6 +1299,7 @@ def test_send_test_redirects_to_start_if_index_out_of_bounds_and_some_placeholde
mock_s3_download,
mock_get_users_by_service,
mock_get_service_statistics,
mock_has_no_jobs,
endpoint,
expected_redirect,
mocker,
@@ -1364,6 +1372,7 @@ def test_send_test_email_message_without_placeholders_redirects_to_check_page(
mock_s3_upload,
mock_get_users_by_service,
mock_get_service_statistics,
mock_has_no_jobs,
fake_uuid,
user,
):
@@ -1392,6 +1401,7 @@ def test_send_test_sms_message_with_placeholders_shows_first_field(
mock_login,
mock_get_service,
mock_get_service_template_with_placeholders,
mock_has_no_jobs,
fake_uuid,
user,
expected_back_link_endpoint,

View File

@@ -2451,6 +2451,7 @@ def test_update_basic_view(
def test_preview_basic_view(
client_request,
mock_get_service_templates,
mock_has_no_jobs,
):
page = client_request.get(
"main.preview_basic_view",
@@ -2486,6 +2487,7 @@ def test_preview_basic_view(
def test_cant_preview_basic_view_for_another_service(
client_request,
mock_get_service_templates,
mock_has_no_jobs,
fake_uuid,
):
client_request.get(

View File

@@ -94,6 +94,7 @@ from tests.conftest import single_letter_contact_block
def test_should_show_page_for_choosing_a_template(
client_request,
mock_get_service_templates,
mock_has_no_jobs,
extra_args,
expected_nav_links,
expected_templates,