From 6c841affc840cc4b3ae58843bcc807da58b6e1c8 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 25 Oct 2019 15:34:01 +0100 Subject: [PATCH] Always show letter counts on dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We hid letters originally because it wasn’t a mature feature. We rolled it out by letting teams choose to use it (#1803) and then automatically giving it to new teams (notifications-api/#1600). This commit doesn’t change who has access to letters, but it does make it more discoverable by revealing it in the UI. This is the same thing we do for emails/texts, where even if you switch them off they still show up on the dashboard and usage page. --- app/main/views/dashboard.py | 7 +-- app/templates/views/dashboard/_totals.html | 26 +++++---- tests/app/main/views/test_dashboard.py | 62 ++++------------------ 3 files changed, 23 insertions(+), 72 deletions(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 60f7a8e8b..8fadf10c6 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -290,11 +290,8 @@ def get_dashboard_partials(service_id): ] stats = aggregate_notifications_stats(all_statistics) - column_width, max_notifiction_count = get_column_properties( - number_of_columns=( - 3 if current_service.has_permission('letter') else 2 - ) - ) + column_width, max_notifiction_count = get_column_properties(3) + dashboard_totals = get_dashboard_totals(stats), highest_notification_count = max( sum( diff --git a/app/templates/views/dashboard/_totals.html b/app/templates/views/dashboard/_totals.html index a7a9de599..778862a4c 100644 --- a/app/templates/views/dashboard/_totals.html +++ b/app/templates/views/dashboard/_totals.html @@ -27,19 +27,17 @@ smaller=smaller_font_size ) }} - {% if current_service.has_permission('letter') %} -
- {{ big_number_with_status( - statistics['letter']['requested'], - message_count_label(statistics['letter']['requested'], 'letter', suffix='sent'), - statistics['letter']['failed'], - statistics['letter']['failed_percentage'], - statistics['letter']['show_warning'], - failure_link=url_for(".view_notifications", service_id=service_id, message_type='letter', status='failed'), - link=url_for(".view_notifications", service_id=service_id, message_type='letter', status=''), - smaller=smaller_font_size - ) }} -
- {% endif %} +
+ {{ big_number_with_status( + statistics['letter']['requested'], + message_count_label(statistics['letter']['requested'], 'letter', suffix='sent'), + statistics['letter']['failed'], + statistics['letter']['failed_percentage'], + statistics['letter']['show_warning'], + failure_link=url_for(".view_notifications", service_id=service_id, message_type='letter', status='failed'), + link=url_for(".view_notifications", service_id=service_id, message_type='letter', status=''), + smaller=smaller_font_size + ) }} +
diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 932b9065e..39d21d79e 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -645,71 +645,26 @@ def test_should_show_upcoming_jobs_on_dashboard( assert table_rows[1].find_all('td')[0].text.strip() == '1' -@pytest.mark.parametrize('permissions, column_name, expected_column_count', [ - (['email', 'sms'], '.column-half', 2), - (['email', 'letter'], '.column-third', 3), - (['email', 'sms', 'letter'], '.column-third', 3) -]) -def test_correct_columns_display_on_dashboard( - client_request, - mock_get_service_templates, - mock_get_template_statistics, - mock_get_service_statistics, - mock_get_jobs, - service_one, - permissions, - expected_column_count, - column_name -): - - service_one['permissions'] = permissions - - page = client_request.get( - 'main.service_dashboard', - service_id=service_one['id'] - ) - - assert len(page.select(column_name)) == expected_column_count - - -@pytest.mark.parametrize('permissions, totals, big_number_class, expected_column_count', [ +@pytest.mark.parametrize('permissions', ( + ['email', 'sms'], + ['email', 'sms', 'letter'], +)) +@pytest.mark.parametrize('totals, big_number_class', [ ( - ['email', 'sms'], - { - 'email': {'requested': 0, 'delivered': 0, 'failed': 0}, - 'sms': {'requested': 999999999, 'delivered': 0, 'failed': 0} - }, - '.big-number', - 2, - ), - ( - ['email', 'sms'], - { - 'email': {'requested': 1000000000, 'delivered': 0, 'failed': 0}, - 'sms': {'requested': 1000000, 'delivered': 0, 'failed': 0} - }, - '.big-number-smaller', - 2, - ), - ( - ['email', 'sms', 'letter'], { 'email': {'requested': 0, 'delivered': 0, 'failed': 0}, 'sms': {'requested': 99999, 'delivered': 0, 'failed': 0}, 'letter': {'requested': 99999, 'delivered': 0, 'failed': 0} }, '.big-number', - 3, ), ( - ['email', 'sms', 'letter'], { 'email': {'requested': 0, 'delivered': 0, 'failed': 0}, 'sms': {'requested': 0, 'delivered': 0, 'failed': 0}, 'letter': {'requested': 100000, 'delivered': 0, 'failed': 0}, }, '.big-number-smaller', - 3, ), ]) def test_correct_font_size_for_big_numbers( @@ -723,7 +678,6 @@ def test_correct_font_size_for_big_numbers( permissions, totals, big_number_class, - expected_column_count, ): service_one['permissions'] = permissions @@ -738,9 +692,11 @@ def test_correct_font_size_for_big_numbers( service_id=service_one['id'], ) - assert expected_column_count == len( + assert len(page.select('.column-third')) == 3 + + assert len( page.select('.big-number-with-status {}'.format(big_number_class)) - ) + ) == 3 @freeze_time("2016-01-01 11:09:00.061258")