mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 02:53:11 -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()]
|
||||
)
|
||||
channel = RadioField(
|
||||
'What kind of messages will you be sending?',
|
||||
choices=[
|
||||
('emails', 'Emails'),
|
||||
('text messages', 'Text messages'),
|
||||
('emails and text messages', 'Both')
|
||||
],
|
||||
validators=[DataRequired()]
|
||||
)
|
||||
channel_email = BooleanField('Emails')
|
||||
channel_sms = BooleanField('Text messages')
|
||||
channel_letter = BooleanField('Letters')
|
||||
start_date = StringField(
|
||||
'When will you be ready to start sending messages?',
|
||||
validators=[DataRequired(message='Can’t be empty')]
|
||||
|
||||
@@ -34,6 +34,7 @@ from app.main.forms import (
|
||||
LetterBranding,
|
||||
ServiceInboundApiForm)
|
||||
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'
|
||||
@@ -166,7 +167,11 @@ def service_request_to_go_live(service_id):
|
||||
current_service['name'],
|
||||
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
|
||||
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_volume.data,
|
||||
form.peak_volume.data,
|
||||
|
||||
@@ -20,3 +20,18 @@
|
||||
</label>
|
||||
</div>
|
||||
{% 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" %}
|
||||
{% from "components/checkbox.html" import checkbox_group %}
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
@@ -38,8 +39,12 @@
|
||||
'don’t know': 'We’ll check for you',
|
||||
}) }}
|
||||
</div>
|
||||
{{ checkbox_group('What kind of messages will you be sending?', [
|
||||
form.channel_email,
|
||||
form.channel_sms,
|
||||
form.channel_letter
|
||||
]) }}
|
||||
<div class="form-group">
|
||||
{{ radios(form.channel) }}
|
||||
{{ textbox(form.start_date, width='1-1') }}
|
||||
{{ 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’.') }}
|
||||
|
||||
@@ -435,43 +435,48 @@ def test_should_raise_duplicate_name_handled(
|
||||
|
||||
|
||||
def test_should_show_request_to_go_live(
|
||||
logged_in_client,
|
||||
mock_get_service,
|
||||
service_one
|
||||
client_request,
|
||||
):
|
||||
response = logged_in_client.get(
|
||||
url_for('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 'Request to go live' in resp_data
|
||||
assert mock_get_service.called
|
||||
page = client_request.get(
|
||||
'main.service_request_to_go_live', service_id=SERVICE_ONE_ID
|
||||
)
|
||||
assert page.h1.text == 'Request to go live'
|
||||
for channel, label in (
|
||||
('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(
|
||||
logged_in_client,
|
||||
active_user_with_permissions,
|
||||
service_one,
|
||||
mocker,
|
||||
single_reply_to_email_addresses,
|
||||
mock_get_letter_organisations,
|
||||
mock_get_inbound_number_for_service
|
||||
client_request,
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
single_reply_to_email_addresses,
|
||||
mock_get_letter_organisations,
|
||||
mock_get_inbound_number_for_service,
|
||||
):
|
||||
mock_post = mocker.patch(
|
||||
'app.main.views.feedback.requests.post',
|
||||
return_value=Mock(status_code=201))
|
||||
response = logged_in_client.post(
|
||||
url_for('main.service_request_to_go_live', service_id=service_one['id']),
|
||||
data={
|
||||
return_value=Mock(status_code=201),
|
||||
)
|
||||
page = client_request.post(
|
||||
'main.service_request_to_go_live',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_data={
|
||||
'mou': 'yes',
|
||||
'channel': 'emails',
|
||||
'channel_email': 'y',
|
||||
'channel_sms': 'y',
|
||||
'start_date': '01/01/2017',
|
||||
'start_volume': '100,000',
|
||||
'peak_volume': '2,000,000',
|
||||
'upload_or_api': 'API'
|
||||
},
|
||||
follow_redirects=True
|
||||
_follow_redirects=True
|
||||
)
|
||||
assert response.status_code == 200
|
||||
mock_post.assert_called_with(
|
||||
ANY,
|
||||
data={
|
||||
@@ -486,17 +491,18 @@ def test_should_redirect_after_request_to_go_live(
|
||||
)
|
||||
|
||||
returned_message = mock_post.call_args[1]['data']['message']
|
||||
assert 'emails' in returned_message
|
||||
assert '01/01/2017' in returned_message
|
||||
assert '100,000' in returned_message
|
||||
assert '2,000,000' in returned_message
|
||||
assert 'API' in returned_message
|
||||
assert 'Channel: email and text messages' in returned_message
|
||||
assert 'Start date: 01/01/2017' in returned_message
|
||||
assert 'Start volume: 100,000' in returned_message
|
||||
assert 'Peak volume: 2,000,000' in returned_message
|
||||
assert 'Upload or API: API' in returned_message
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
flash_banner = page.find('div', class_='banner-default').string.strip()
|
||||
h1 = page.find('h1').string.strip()
|
||||
assert flash_banner == 'We’ve received your request to go live'
|
||||
assert h1 == 'Settings'
|
||||
assert normalize_spaces(page.select_one('.banner-default').text) == (
|
||||
'We’ve received your request to go live'
|
||||
)
|
||||
assert normalize_spaces(page.select_one('h1').text) == (
|
||||
'Settings'
|
||||
)
|
||||
|
||||
|
||||
def test_log_error_on_request_to_go_live(
|
||||
|
||||
Reference in New Issue
Block a user