diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index be376a989..756394bcc 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -173,7 +173,8 @@ def view_notifications(service_id, message_type): 'views/notifications.html', partials=get_notifications(service_id, message_type), message_type=message_type, - status=request.args.get('status') + status=request.args.get('status'), + page=request.args.get('page', 1) ) diff --git a/app/templates/views/notifications.html b/app/templates/views/notifications.html index 8ee8c5da6..48e809358 100644 --- a/app/templates/views/notifications.html +++ b/app/templates/views/notifications.html @@ -20,7 +20,7 @@ {{ ajax_block( partials, - url_for('.get_notifications_as_json', service_id=current_service.id, message_type=message_type, status=status), + url_for('.get_notifications_as_json', service_id=current_service.id, message_type=message_type, status=status, page=page), 'notifications' ) }} diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 0693d02f5..ab2813a57 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -279,6 +279,13 @@ def test_should_show_updates_for_one_job_as_json( ) ] ) +@pytest.mark.parametrize( + "page_argument, expected_page_argument", [ + (1, 1), + (22, 22), + (None, 1) + ] +) def test_can_show_notifications( app_, service_one, @@ -289,7 +296,9 @@ def test_can_show_notifications( message_type, page_title, status_argument, - expected_api_call + expected_api_call, + page_argument, + expected_page_argument ): with app_.test_request_context(): with app_.test_client() as client: @@ -298,7 +307,8 @@ def test_can_show_notifications( 'main.view_notifications', service_id=service_one['id'], message_type=message_type, - status=status_argument)) + status=status_argument, + page=page_argument)) assert response.status_code == 200 content = response.get_data(as_text=True) @@ -317,9 +327,17 @@ def test_can_show_notifications( status=status_argument ) == page.findAll("a", {"download": "download"})[0]['href'] + assert url_for( + '.get_notifications_as_json', + service_id=service_one['id'], + message_type=message_type, + status=status_argument, + page=expected_page_argument + ) == page.find("div", {'data-key': 'notifications'})['data-resource'] + mock_get_notifications.assert_called_with( limit_days=7, - page=1, + page=expected_page_argument, service_id=service_one['id'], status=expected_api_call, template_type=[message_type]