mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Ensure correct page titles on send test flows
We have some fairly complicated nested if statements in our Jinja that decide what the page titles should be. It’s only going to get more complicated with the send individual message routes. So this commit: - moves the logic from Jinja to Python - adds tests to check things are working as expected - sets the page titles to the right thing for each flow
This commit is contained in:
@@ -284,6 +284,7 @@ def send_test_step(service_id, template_id, step_index):
|
||||
|
||||
return render_template(
|
||||
'views/send-test.html',
|
||||
page_title=get_send_test_page_title(template.template_type, request.endpoint),
|
||||
template=template,
|
||||
form=form,
|
||||
optional_placeholder=optional_placeholder,
|
||||
@@ -546,3 +547,14 @@ def all_placeholders_in_session(placeholders):
|
||||
get_normalised_send_test_values_from_session().get(placeholder, False) not in (False, None)
|
||||
for placeholder in placeholders
|
||||
)
|
||||
|
||||
|
||||
def get_send_test_page_title(template_type, endpoint):
|
||||
if get_help_argument():
|
||||
return 'Example text message'
|
||||
if template_type == 'letter':
|
||||
return 'Print a test letter'
|
||||
return {
|
||||
'main.send_test_step': 'Send yourself a test',
|
||||
'main.send_one_off_step': 'Send one-off message',
|
||||
}[endpoint]
|
||||
|
||||
@@ -5,25 +5,13 @@
|
||||
{% from "components/table.html" import list_table, field, text_field, index_field, index_field_heading %}
|
||||
|
||||
{% block service_page_title %}
|
||||
{% if request.args['help'] %}
|
||||
Example text message
|
||||
{% else %}
|
||||
Send yourself a test
|
||||
{% endif %}
|
||||
{{ page_title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<h1 class="heading-large">
|
||||
{% if request.args['help'] %}
|
||||
Example text message
|
||||
{% else %}
|
||||
{% if template.template_type == 'letter' %}
|
||||
Print a test letter
|
||||
{% else %}
|
||||
Send yourself a test
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{{ page_title }}
|
||||
</h1>
|
||||
|
||||
<form method="post" class="js-stick-at-top-when-scrolling" data-module="autofocus">
|
||||
|
||||
Reference in New Issue
Block a user