From 436d023722569acba79e43da8971193b80e7a6ea Mon Sep 17 00:00:00 2001
From: Chris Hill-Scott
Date: Thu, 11 Apr 2019 14:35:30 +0100
Subject: [PATCH 1/2] Block incomplete requests to go live
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Dealing with users who request to go live but haven’t completed all the
steps still represents a significant support overhead for our team.
We’ve made some improvements to the percentage of incomplete requests
with a better page design, but ultimately because it still shows the
button people think it’s OK to press the button while some of the items
on the page still say [Not completed].
We can do this now because organisations are in the database, which
means we can mark the agreement signed as soon as we get it back,
without having to deploy code.
---
.../service-settings/request-to-go-live.html | 14 ++--
tests/app/main/views/test_service_settings.py | 77 ++++++++++++++++---
2 files changed, 77 insertions(+), 14 deletions(-)
diff --git a/app/templates/views/service-settings/request-to-go-live.html b/app/templates/views/service-settings/request-to-go-live.html
index 1483e79bc..d1471268e 100644
--- a/app/templates/views/service-settings/request-to-go-live.html
+++ b/app/templates/views/service-settings/request-to-go-live.html
@@ -52,7 +52,15 @@
) }}
{% endif %}
{% endcall %}
- {% if current_user.is_gov_user %}
+ {% if not current_user.is_gov_user %}
+
+ Only team members with a government email address can request to go live.
+
+ {% elif (not current_service.go_live_checklist_completed) or (show_agreement and not agreement_signed) %}
+
+ No go
+
+ {% else %}
When we receive your request we’ll get back to you within one working day.
@@ -62,10 +70,6 @@
{% call form_wrapper() %}
{{ page_footer('Request to go live') }}
{% endcall %}
- {% else %}
-
- Only team members with a government email address can request to go live.
-
{% endif %}
diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py
index dc81457af..3b638ac89 100644
--- a/tests/app/main/views/test_service_settings.py
+++ b/tests/app/main/views/test_service_settings.py
@@ -1,3 +1,4 @@
+from collections import namedtuple
from functools import partial
from unittest.mock import ANY, PropertyMock, call
from urllib.parse import parse_qs, urlparse
@@ -731,18 +732,78 @@ def test_should_check_for_sending_things_right(
assert normalize_spaces(checklist_items[2].text) == expected_templates_checklist_item
assert normalize_spaces(checklist_items[3].text) == expected_reply_to_checklist_item
- assert page.select_one('form')['method'] == 'post'
- assert 'action' not in page.select_one('form')
-
mock_count_users.assert_called_once_with(SERVICE_ONE_ID, 'manage_service')
- assert mock_templates.call_args_list == [
- call(),
- ]
+ assert mock_templates.called is True
if count_of_email_templates:
mock_get_reply_to_email_addresses.assert_called_once_with(SERVICE_ONE_ID)
+@pytest.mark.parametrize('checklist_completed, agreement_signed, expected_button', (
+ (True, True, True),
+ (True, None, True),
+ (True, False, False),
+ (False, True, False),
+ (False, None, False),
+))
+def test_should_not_show_go_live_button_if_checklist_not_complete(
+ client_request,
+ mocker,
+ mock_get_service_templates,
+ mock_get_users_by_service,
+ single_sms_sender,
+ checklist_completed,
+ agreement_signed,
+ expected_button,
+):
+
+ def _agreement_info():
+ return namedtuple(
+ 'AgreementInfo', ['agreement_signed']
+ )(agreement_signed=agreement_signed)
+
+ mocker.patch(
+ 'app.models.service.Service.go_live_checklist_completed',
+ new_callable=PropertyMock,
+ return_value=checklist_completed,
+ )
+ mocker.patch(
+ 'app.utils.AgreementInfo.from_current_user',
+ side_effect=_agreement_info,
+ )
+
+ for channel in ('email', 'sms', 'letter'):
+ mocker.patch(
+ 'app.models.service.Service.volume_{}'.format(channel),
+ create=True,
+ new_callable=PropertyMock,
+ return_value=0,
+ )
+
+ page = client_request.get(
+ 'main.request_to_go_live', service_id=SERVICE_ONE_ID
+ )
+ assert page.h1.text == 'Before you request to go live'
+
+ if expected_button:
+ assert page.select_one('form')['method'] == 'post'
+ assert 'action' not in page.select_one('form')
+ assert normalize_spaces(page.select('main p')[0].text) == (
+ 'When we receive your request we’ll get back to you within one working day.'
+ )
+ assert normalize_spaces(page.select('main p')[1].text) == (
+ 'By requesting to go live you’re agreeing to our terms of use.'
+ )
+ page.select_one('[type=submit]').text.strip() == ('Request to go live')
+ else:
+ assert not page.select('form')
+ assert not page.select('[type=submit]')
+ assert len(page.select('main p')) == 1
+ assert normalize_spaces(page.select_one('main p').text) == (
+ 'No go'
+ )
+
+
@pytest.mark.parametrize((
'estimated_sms_volume,'
'organisation_type,'
@@ -887,9 +948,7 @@ def test_should_check_for_sms_sender_on_go_live(
checklist_items = page.select('.task-list .task-list-item')
assert normalize_spaces(checklist_items[3].text) == expected_sms_sender_checklist_item
- assert mock_templates.call_args_list == [
- call(),
- ]
+ assert mock_templates.called is True
mock_get_sms_senders.assert_called_once_with(SERVICE_ONE_ID)
From f997b446ff192759d7b0a67ae9e6bc89fa003a2e Mon Sep 17 00:00:00 2001
From: karlchillmaid
Date: Thu, 11 Apr 2019 15:43:26 +0100
Subject: [PATCH 2/2] Update
app/templates/views/service-settings/request-to-go-live.html
Co-Authored-By: quis
---
app/templates/views/service-settings/request-to-go-live.html | 2 +-
tests/app/main/views/test_service_settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/templates/views/service-settings/request-to-go-live.html b/app/templates/views/service-settings/request-to-go-live.html
index d1471268e..45d66f00e 100644
--- a/app/templates/views/service-settings/request-to-go-live.html
+++ b/app/templates/views/service-settings/request-to-go-live.html
@@ -58,7 +58,7 @@
{% elif (not current_service.go_live_checklist_completed) or (show_agreement and not agreement_signed) %}
- No go
+ You must complete these steps before you can request to go live.
{% else %}
diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py
index 3b638ac89..847bc3536 100644
--- a/tests/app/main/views/test_service_settings.py
+++ b/tests/app/main/views/test_service_settings.py
@@ -800,7 +800,7 @@ def test_should_not_show_go_live_button_if_checklist_not_complete(
assert not page.select('[type=submit]')
assert len(page.select('main p')) == 1
assert normalize_spaces(page.select_one('main p').text) == (
- 'No go'
+ 'You must complete these steps before you can request to go live.'
)