mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 03:18:25 -04:00
Merge pull request #405 from alphagov/add-date-back-into-template-stats
Add date field back into template stats
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
template_statistics,
|
template_statistics,
|
||||||
caption="Recent templates used",
|
caption="Recent templates used",
|
||||||
empty_message='You haven’t sent any batch messages yet',
|
empty_message='You haven’t sent any batch messages yet',
|
||||||
field_headings=['Template', 'Type', right_aligned_field_heading('Usage')]
|
field_headings=['Template', 'Type', 'Date', right_aligned_field_heading('Usage')]
|
||||||
) %}
|
) %}
|
||||||
{% call field() %}
|
{% call field() %}
|
||||||
<a href="{{ url_for('.edit_service_template', service_id=current_service.id, template_id=item.template.id) }}">
|
<a href="{{ url_for('.edit_service_template', service_id=current_service.id, template_id=item.template.id) }}">
|
||||||
@@ -13,7 +13,10 @@
|
|||||||
{% call field() %}
|
{% call field() %}
|
||||||
{{item.template.template_type}}
|
{{item.template.template_type}}
|
||||||
{% endcall %}
|
{% endcall %}
|
||||||
{% call field(align='right') %}
|
{% call field() %}
|
||||||
|
{{item.day|format_date}}
|
||||||
|
{% endcall %}
|
||||||
|
{% call field(align='right') %}
|
||||||
{{ item.usage_count }}
|
{{ item.usage_count }}
|
||||||
{% endcall %}
|
{% endcall %}
|
||||||
{% endcall %}
|
{% endcall %}
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
from flask import url_for
|
from flask import url_for
|
||||||
|
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from tests import validate_route_permission
|
from tests import validate_route_permission
|
||||||
from tests.conftest import SERVICE_ONE_ID
|
from tests.conftest import SERVICE_ONE_ID
|
||||||
|
|
||||||
|
|
||||||
def test_should_show_recent_jobs_on_dashboard(app_,
|
def test_should_show_recent_templates_on_dashboard(app_,
|
||||||
api_user_active,
|
api_user_active,
|
||||||
mock_get_service,
|
mock_get_service,
|
||||||
mock_get_service_templates,
|
mock_get_service_templates,
|
||||||
mock_get_service_statistics,
|
mock_get_service_statistics,
|
||||||
mock_get_template_statistics,
|
mock_get_template_statistics,
|
||||||
mock_get_user,
|
mock_get_user,
|
||||||
mock_get_user_by_email,
|
mock_get_user_by_email,
|
||||||
mock_login,
|
mock_login,
|
||||||
mock_get_jobs,
|
mock_get_jobs,
|
||||||
mock_has_permissions):
|
mock_has_permissions):
|
||||||
with app_.test_request_context():
|
with app_.test_request_context():
|
||||||
with app_.test_client() as client:
|
with app_.test_client() as client:
|
||||||
client.login(api_user_active)
|
client.login(api_user_active)
|
||||||
@@ -22,10 +24,17 @@ def test_should_show_recent_jobs_on_dashboard(app_,
|
|||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
text = response.get_data(as_text=True)
|
text = response.get_data(as_text=True)
|
||||||
assert 'Test Service' in text
|
|
||||||
mock_get_service_statistics.assert_called_once_with(SERVICE_ONE_ID)
|
mock_get_service_statistics.assert_called_once_with(SERVICE_ONE_ID)
|
||||||
mock_get_template_statistics.assert_called_once_with(SERVICE_ONE_ID)
|
mock_get_template_statistics.assert_called_once_with(SERVICE_ONE_ID)
|
||||||
|
|
||||||
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
|
headers = [header.text.strip() for header in page.find_all('h2')]
|
||||||
|
assert 'Test Service' in headers
|
||||||
|
assert 'Sent today' in headers
|
||||||
|
template_usage_headers = [th.text.strip() for th in page.thead.find_all('th')]
|
||||||
|
for th in ['Template', 'Type', 'Date', 'Usage']:
|
||||||
|
assert th in template_usage_headers
|
||||||
|
|
||||||
|
|
||||||
def _test_dashboard_menu(mocker, app_, usr, service, permissions):
|
def _test_dashboard_menu(mocker, app_, usr, service, permissions):
|
||||||
with app_.test_request_context():
|
with app_.test_request_context():
|
||||||
|
|||||||
Reference in New Issue
Block a user