mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 03:23:12 -04:00
Add letters to the request to go live page
It’s not either text messages, or emails, or both now – it’s any combination of the three channels. This commit adds ‘letters’ as an option on the request to go live page by changing the radio buttons to a group of checkboxes, so the user can choose as many or as few as they want. This commit also does a bunch of housekeeping stuff around the tests for this page, because they haven’t been touched in quite some time.
This commit is contained in:
@@ -431,15 +431,9 @@ class RequestToGoLiveForm(Form):
|
|||||||
],
|
],
|
||||||
validators=[DataRequired()]
|
validators=[DataRequired()]
|
||||||
)
|
)
|
||||||
channel = RadioField(
|
channel_email = BooleanField('Emails')
|
||||||
'What kind of messages will you be sending?',
|
channel_sms = BooleanField('Text messages')
|
||||||
choices=[
|
channel_letter = BooleanField('Letters')
|
||||||
('emails', 'Emails'),
|
|
||||||
('text messages', 'Text messages'),
|
|
||||||
('emails and text messages', 'Both')
|
|
||||||
],
|
|
||||||
validators=[DataRequired()]
|
|
||||||
)
|
|
||||||
start_date = StringField(
|
start_date = StringField(
|
||||||
'When will you be ready to start sending messages?',
|
'When will you be ready to start sending messages?',
|
||||||
validators=[DataRequired(message='Can’t be empty')]
|
validators=[DataRequired(message='Can’t be empty')]
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ from app.main.forms import (
|
|||||||
LetterBranding,
|
LetterBranding,
|
||||||
ServiceInboundApiForm)
|
ServiceInboundApiForm)
|
||||||
from app import user_api_client, current_service, organisations_client, inbound_number_client
|
from app import user_api_client, current_service, organisations_client, inbound_number_client
|
||||||
|
from notifications_utils.formatters import formatted_list
|
||||||
|
|
||||||
|
|
||||||
dummy_bearer_token = 'bearer_token_set'
|
dummy_bearer_token = 'bearer_token_set'
|
||||||
@@ -166,7 +167,11 @@ def service_request_to_go_live(service_id):
|
|||||||
current_service['name'],
|
current_service['name'],
|
||||||
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
|
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
|
||||||
form.mou.data,
|
form.mou.data,
|
||||||
form.channel.data,
|
formatted_list(filter(None, (
|
||||||
|
'email' if form.channel_email.data else None,
|
||||||
|
'text messages' if form.channel_sms.data else None,
|
||||||
|
'letters' if form.channel_letter.data else None,
|
||||||
|
)), before_each='', after_each=''),
|
||||||
form.start_date.data,
|
form.start_date.data,
|
||||||
form.start_volume.data,
|
form.start_volume.data,
|
||||||
form.peak_volume.data,
|
form.peak_volume.data,
|
||||||
|
|||||||
@@ -20,3 +20,18 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro checkbox_group(
|
||||||
|
legend,
|
||||||
|
fields
|
||||||
|
) %}
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<legend class="form-label">
|
||||||
|
{{ legend }}
|
||||||
|
</legend>
|
||||||
|
{% for field in fields %}
|
||||||
|
{{ checkbox(field) }}
|
||||||
|
{% endfor %}
|
||||||
|
</fieldset>
|
||||||
|
{% endmacro %}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{% extends "withnav_template.html" %}
|
{% extends "withnav_template.html" %}
|
||||||
|
{% from "components/checkbox.html" import checkbox_group %}
|
||||||
{% from "components/textbox.html" import textbox %}
|
{% from "components/textbox.html" import textbox %}
|
||||||
{% from "components/radios.html" import radios %}
|
{% from "components/radios.html" import radios %}
|
||||||
{% from "components/page-footer.html" import page_footer %}
|
{% from "components/page-footer.html" import page_footer %}
|
||||||
@@ -38,8 +39,12 @@
|
|||||||
'don’t know': 'We’ll check for you',
|
'don’t know': 'We’ll check for you',
|
||||||
}) }}
|
}) }}
|
||||||
</div>
|
</div>
|
||||||
|
{{ checkbox_group('What kind of messages will you be sending?', [
|
||||||
|
form.channel_email,
|
||||||
|
form.channel_sms,
|
||||||
|
form.channel_letter
|
||||||
|
]) }}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ radios(form.channel) }}
|
|
||||||
{{ textbox(form.start_date, width='1-1') }}
|
{{ textbox(form.start_date, width='1-1') }}
|
||||||
{{ textbox(form.start_volume, width='1-1', hint='For example, ‘1000 a month’.') }}
|
{{ textbox(form.start_volume, width='1-1', hint='For example, ‘1000 a month’.') }}
|
||||||
{{ textbox(form.peak_volume, width='1-1', hint='For example, ‘Messages will increase to 20,000 a month in January’.') }}
|
{{ textbox(form.peak_volume, width='1-1', hint='For example, ‘Messages will increase to 20,000 a month in January’.') }}
|
||||||
|
|||||||
@@ -435,43 +435,48 @@ def test_should_raise_duplicate_name_handled(
|
|||||||
|
|
||||||
|
|
||||||
def test_should_show_request_to_go_live(
|
def test_should_show_request_to_go_live(
|
||||||
logged_in_client,
|
client_request,
|
||||||
mock_get_service,
|
|
||||||
service_one
|
|
||||||
):
|
):
|
||||||
response = logged_in_client.get(
|
page = client_request.get(
|
||||||
url_for('main.service_request_to_go_live', service_id=service_one['id']))
|
'main.service_request_to_go_live', service_id=SERVICE_ONE_ID
|
||||||
assert response.status_code == 200
|
)
|
||||||
resp_data = response.get_data(as_text=True)
|
assert page.h1.text == 'Request to go live'
|
||||||
assert 'Request to go live' in resp_data
|
for channel, label in (
|
||||||
assert mock_get_service.called
|
('email', 'Emails'),
|
||||||
|
('sms', 'Text messages'),
|
||||||
|
('letter', 'Letters'),
|
||||||
|
):
|
||||||
|
assert normalize_spaces(
|
||||||
|
page.select_one('label[for=channel_{}]'.format(channel)).text
|
||||||
|
) == label
|
||||||
|
|
||||||
|
|
||||||
def test_should_redirect_after_request_to_go_live(
|
def test_should_redirect_after_request_to_go_live(
|
||||||
logged_in_client,
|
client_request,
|
||||||
active_user_with_permissions,
|
mocker,
|
||||||
service_one,
|
active_user_with_permissions,
|
||||||
mocker,
|
single_reply_to_email_addresses,
|
||||||
single_reply_to_email_addresses,
|
mock_get_letter_organisations,
|
||||||
mock_get_letter_organisations,
|
mock_get_inbound_number_for_service,
|
||||||
mock_get_inbound_number_for_service
|
|
||||||
):
|
):
|
||||||
mock_post = mocker.patch(
|
mock_post = mocker.patch(
|
||||||
'app.main.views.feedback.requests.post',
|
'app.main.views.feedback.requests.post',
|
||||||
return_value=Mock(status_code=201))
|
return_value=Mock(status_code=201),
|
||||||
response = logged_in_client.post(
|
)
|
||||||
url_for('main.service_request_to_go_live', service_id=service_one['id']),
|
page = client_request.post(
|
||||||
data={
|
'main.service_request_to_go_live',
|
||||||
|
service_id=SERVICE_ONE_ID,
|
||||||
|
_data={
|
||||||
'mou': 'yes',
|
'mou': 'yes',
|
||||||
'channel': 'emails',
|
'channel_email': 'y',
|
||||||
|
'channel_sms': 'y',
|
||||||
'start_date': '01/01/2017',
|
'start_date': '01/01/2017',
|
||||||
'start_volume': '100,000',
|
'start_volume': '100,000',
|
||||||
'peak_volume': '2,000,000',
|
'peak_volume': '2,000,000',
|
||||||
'upload_or_api': 'API'
|
'upload_or_api': 'API'
|
||||||
},
|
},
|
||||||
follow_redirects=True
|
_follow_redirects=True
|
||||||
)
|
)
|
||||||
assert response.status_code == 200
|
|
||||||
mock_post.assert_called_with(
|
mock_post.assert_called_with(
|
||||||
ANY,
|
ANY,
|
||||||
data={
|
data={
|
||||||
@@ -486,17 +491,18 @@ def test_should_redirect_after_request_to_go_live(
|
|||||||
)
|
)
|
||||||
|
|
||||||
returned_message = mock_post.call_args[1]['data']['message']
|
returned_message = mock_post.call_args[1]['data']['message']
|
||||||
assert 'emails' in returned_message
|
assert 'Channel: email and text messages' in returned_message
|
||||||
assert '01/01/2017' in returned_message
|
assert 'Start date: 01/01/2017' in returned_message
|
||||||
assert '100,000' in returned_message
|
assert 'Start volume: 100,000' in returned_message
|
||||||
assert '2,000,000' in returned_message
|
assert 'Peak volume: 2,000,000' in returned_message
|
||||||
assert 'API' in returned_message
|
assert 'Upload or API: API' in returned_message
|
||||||
|
|
||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
assert normalize_spaces(page.select_one('.banner-default').text) == (
|
||||||
flash_banner = page.find('div', class_='banner-default').string.strip()
|
'We’ve received your request to go live'
|
||||||
h1 = page.find('h1').string.strip()
|
)
|
||||||
assert flash_banner == 'We’ve received your request to go live'
|
assert normalize_spaces(page.select_one('h1').text) == (
|
||||||
assert h1 == 'Settings'
|
'Settings'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_log_error_on_request_to_go_live(
|
def test_log_error_on_request_to_go_live(
|
||||||
|
|||||||
Reference in New Issue
Block a user