- I have a problem or question -
- -- Check our system status + Check our system status page to see if there are any known issues with GOV.UK Notify.
Leave your details below if you'd like a response.
{{ textbox(form.name, width='1-1') }} {{ textbox(form.email_address, width='1-1') }} - {{ page_footer('Send') }} + {{ page_footer( + 'Send', + secondary_link=url_for('.support'), + secondary_link_text='Back to support', + ) }}- Contact the Notify team to get a copy of the agreement or to find out if your organisation has already accepted it. + Contact the Notify team to get a copy of the agreement or to find out if your organisation has already accepted it.
{% endcall %} @@ -83,7 +83,7 @@ Terms of use – GOV.UK NotifyCabinet Office act as data processor, as parent organisation of GOV.UK Notify. Your organisation remains the data controller.
-Contact us if you want more information about our approach to data protection and information risk management.
+Contact us if you want more information about our approach to data protection and information risk management.
You can remove your service from GOV.UK Notify at any time. Contact us and we’ll delete your account.
+You can remove your service from GOV.UK Notify at any time. Contact us and we’ll delete your account.
Any data that you have already processed through GOV.UK Notify will be deleted as part of the existing data deletion processes and data retention periods.
diff --git a/tests/app/main/views/test_feedback.py b/tests/app/main/views/test_feedback.py index bc78e2ed4..e2ca451ef 100644 --- a/tests/app/main/views/test_feedback.py +++ b/tests/app/main/views/test_feedback.py @@ -1,3 +1,5 @@ +from bs4 import BeautifulSoup +from functools import partial import pytest from flask import url_for from werkzeug.exceptions import InternalServerError @@ -24,76 +26,86 @@ def test_get_support_index_page(client): assert resp.status_code == 200 -def test_get_feedback_page(app_): - with app_.test_request_context(): - with app_.test_client() as client: - resp = client.get(url_for('main.feedback')) - assert resp.status_code == 200 +@pytest.mark.parametrize('support_type, expected_h1', [ + ('problem', 'Report a problem'), + ('question', 'Ask a question or give feedback'), +]) +def test_choose_support_type(client, support_type, expected_h1): + response = client.post( + url_for('main.support'), + data={'support_type': support_type}, follow_redirects=True + ) + assert response.status_code == 200 + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.h1.string.strip() == expected_h1 -def test_post_feedback_with_name_but_no_email(app_, mocker): +@pytest.mark.parametrize('ticket_type, expected_status_code', [ + ('problem', 200), + ('question', 200), + ('gripe', 404) +]) +def test_get_feedback_page(client, ticket_type, expected_status_code): + response = client.get(url_for('main.feedback', ticket_type=ticket_type)) + assert response.status_code == expected_status_code + + +@pytest.mark.parametrize('data, expected_message, expected_person_name, expected_email', [ + ( + {'feedback': "blah", 'name': 'Fred'}, + 'Environment: http://localhost/\nFred (no email address supplied)\nblah', + 'Fred', + 'donotreply@notifications.service.gov.uk', + ), + ( + {'feedback': "blah"}, + 'Environment: http://localhost/\n (no email address supplied)\nblah', + None, + 'donotreply@notifications.service.gov.uk', + ), + ( + {'feedback': "blah", 'name': "Steve Irwin", 'email_address': 'rip@gmail.com'}, + 'Environment: http://localhost/\n\nblah', + 'Steve Irwin', + 'rip@gmail.com', + ), +]) +@pytest.mark.parametrize('ticket_type', ['problem', 'question']) +def test_post_feedback_with_name_but_no_email( + client, + mocker, + ticket_type, + data, + expected_message, + expected_person_name, + expected_email, +): mock_post = mocker.patch( 'app.main.views.feedback.requests.post', - return_value=Mock(status_code=201)) - with app_.test_request_context(): - with app_.test_client() as client: - resp = client.post(url_for('main.feedback'), data={'feedback': "blah", 'name': 'Fred'}) - assert resp.status_code == 302 - mock_post.assert_called_with( - ANY, - data={ - 'department_id': ANY, - 'agent_team_id': ANY, - 'subject': 'Notify feedback', - 'message': 'Environment: http://localhost/\nFred (no email address supplied)\nblah', - 'person_email': app_.config['DESKPRO_PERSON_EMAIL'], - 'person_name': 'Fred'}, - headers=ANY) + return_value=Mock(status_code=201) + ) + resp = client.post( + url_for('main.feedback', ticket_type=ticket_type), + data=data, + ) + assert resp.status_code == 302 + mock_post.assert_called_with( + ANY, + data={ + 'department_id': ANY, + 'agent_team_id': ANY, + 'subject': 'Notify feedback', + 'message': expected_message.format(ticket_type), + 'person_email': expected_email, + 'person_name': expected_person_name, + 'label': ticket_type, + }, + headers=ANY + ) -def test_post_feedback_with_no_name_or_email(app_, mocker): - mock_post = mocker.patch( - 'app.main.views.feedback.requests.post', - return_value=Mock(status_code=201)) - with app_.test_request_context(): - with app_.test_client() as client: - resp = client.post(url_for('main.feedback'), data={'feedback': "blah"}) - assert resp.status_code == 302 - mock_post.assert_called_with( - ANY, - data={ - 'department_id': ANY, - 'agent_team_id': ANY, - 'subject': 'Notify feedback', - 'message': 'Environment: http://localhost/\n (no email address supplied)\nblah', - 'person_email': app_.config['DESKPRO_PERSON_EMAIL'], - 'person_name': None}, - headers=ANY) - - -def test_post_feedback_with_name_email(app_, mocker): - mock_post = mocker.patch( - 'app.main.views.feedback.requests.post', - return_value=Mock(status_code=201)) - with app_.test_request_context(): - with app_.test_client() as client: - resp = client.post( - url_for('main.feedback'), - data={'feedback': "blah", 'name': "Steve Irwin", 'email_address': 'rip@gmail.com'}) - assert resp.status_code == 302 - mock_post.assert_called_with( - ANY, - data={ - 'subject': 'Notify feedback', - 'department_id': ANY, - 'agent_team_id': ANY, - 'message': 'Environment: http://localhost/\n\nblah', - 'person_name': 'Steve Irwin', - 'person_email': 'rip@gmail.com'}, - headers=ANY) - - -def test_log_error_on_post(app_, mocker): +@pytest.mark.parametrize('ticket_type', ['problem', 'question']) +def test_log_error_on_post(app_, mocker, ticket_type): mock_post = mocker.patch( 'app.main.views.feedback.requests.post', return_value=Mock( @@ -106,7 +118,7 @@ def test_log_error_on_post(app_, mocker): with app_.test_client() as client: with pytest.raises(InternalServerError): resp = client.post( - url_for('main.feedback'), + url_for('main.feedback', ticket_type=ticket_type), data={'feedback': "blah", 'name': "Steve Irwin", 'email_address': 'rip@gmail.com'}) assert mock_post.called mock_logger.assert_called_with(