mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Show error banner for one off letter in trial mode
In trial mode you can’t send letters. But it’s still useful to be able to build up a letter to see how it work. Best place to put this error is before someone tries to send a letter for real.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<h1 class='banner-title' data-module="track-error" data-error-type="Trying to send letters in trial mode" data-error-label="{{ upload_id }}">
|
||||
You can’t send
|
||||
{{ 'this letter' if count_of_recipients == 1 else 'these letters' }}
|
||||
</h1>
|
||||
<p>
|
||||
In <a href="{{ url_for('.using_notify') }}#trial-mode">trial mode</a> you
|
||||
can only preview how your letters will look
|
||||
</p>
|
||||
@@ -109,14 +109,15 @@
|
||||
|
||||
{% elif trying_to_send_letters_in_trial_mode %}
|
||||
|
||||
<h1 class='banner-title' data-module="track-error" data-error-type="Trying to send letters in trial mode" data-error-label="{{ upload_id }}">
|
||||
You can’t send
|
||||
{{ 'this letter' if count_of_recipients == 1 else 'these letters' }}
|
||||
</h1>
|
||||
<p>
|
||||
In <a href="{{ url_for('.using_notify') }}#trial-mode">trial mode</a> you
|
||||
can only preview how your letters will look
|
||||
</p>
|
||||
<div class="bottom-gutter">
|
||||
{% with
|
||||
count_of_recipients=count_of_recipients
|
||||
%}
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
{% include "partials/check/trying-to-send-letters-in-trial-mode.html" %}
|
||||
{% endcall %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
{% elif recipients.more_rows_than_can_send %}
|
||||
|
||||
|
||||
@@ -7,7 +7,18 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
{% if error == 'not-allowed-to-send-to' %}
|
||||
{% if template.template_type == 'letter' and current_service.trial_mode %}
|
||||
{% set error = 'trial-mode-letters' %}
|
||||
<div class="bottom-gutter">
|
||||
{% with
|
||||
count_of_recipients=1
|
||||
%}
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
{% include "partials/check/trying-to-send-letters-in-trial-mode.html" %}
|
||||
{% endcall %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% elif error == 'not-allowed-to-send-to' %}
|
||||
<div class="bottom-gutter">
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
{% with
|
||||
|
||||
@@ -1976,14 +1976,19 @@ def test_letter_can_only_be_sent_now(
|
||||
mocker.patch('app.main.views.send.set_metadata_on_csv_upload')
|
||||
mocker.patch('app.main.views.send.get_page_count_for_letter', return_value=1)
|
||||
|
||||
content = client_request.get(
|
||||
page = client_request.get(
|
||||
'main.check_messages',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
upload_id=fake_uuid,
|
||||
template_id=fake_uuid,
|
||||
)
|
||||
|
||||
assert 'name="scheduled_for"' not in content
|
||||
assert 'name="scheduled_for"' not in page
|
||||
assert normalize_spaces(
|
||||
page.select_one('[type=submit]').text
|
||||
) == (
|
||||
'Send 1 letter'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('when', [
|
||||
@@ -2761,6 +2766,51 @@ def test_one_off_letters_have_download_link(
|
||||
assert page.select_one('a[download]').text == 'Download as a printable PDF'
|
||||
|
||||
|
||||
def test_send_one_off_letter_errors_in_trial_mode(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_service,
|
||||
mock_get_service_letter_template,
|
||||
mock_has_permissions,
|
||||
fake_uuid,
|
||||
mock_get_users_by_service,
|
||||
mock_get_service_statistics,
|
||||
mock_get_job_doesnt_exist,
|
||||
mock_s3_set_metadata,
|
||||
):
|
||||
|
||||
mocker.patch(
|
||||
'app.main.views.send.get_page_count_for_letter',
|
||||
return_value=5,
|
||||
)
|
||||
|
||||
with client_request.session_transaction() as session:
|
||||
session['recipient'] = None
|
||||
session['placeholders'] = {
|
||||
'address_line_1': 'First Last',
|
||||
'address_line_2': '123 Street',
|
||||
'postcode': 'SW1 1AA',
|
||||
}
|
||||
|
||||
page = client_request.get(
|
||||
'main.check_notification',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
_test_page_title=False,
|
||||
)
|
||||
|
||||
assert normalize_spaces(page.select('.banner-dangerous')) == normalize_spaces(
|
||||
'You can’t send this letter '
|
||||
'In trial mode you can only preview how your letters will look'
|
||||
)
|
||||
|
||||
assert len(page.select('.letter img')) == 5
|
||||
|
||||
assert not page.select('[type=submit]')
|
||||
assert page.select_one('.page-footer-back-link').text == 'Back'
|
||||
assert page.select_one('a[download]').text == 'Download as a printable PDF'
|
||||
|
||||
|
||||
def test_check_messages_shows_over_max_row_error(
|
||||
logged_in_client,
|
||||
api_user_active,
|
||||
|
||||
Reference in New Issue
Block a user