mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 18:22:37 -04:00
Fix count of columns on breaking change page
For some reason we were rebuilding `new_template` as a dictionary, without the `placeholders` attribute. This meant that we were never actually counting the placeholders, just counting the length of `None` and adding 1 to it. So this commit fixes that, beefs up the tests, and makes sure that everything is pluralised properly.
This commit is contained in:
@@ -262,12 +262,7 @@ def edit_service_template(service_id, template_id):
|
|||||||
return render_template(
|
return render_template(
|
||||||
'views/templates/breaking-change.html',
|
'views/templates/breaking-change.html',
|
||||||
template_change=template_change,
|
template_change=template_change,
|
||||||
new_template={
|
new_template=new_template,
|
||||||
'name': form.name.data,
|
|
||||||
'subject': subject,
|
|
||||||
'content': form.template_content.data,
|
|
||||||
'id': new_template.id
|
|
||||||
},
|
|
||||||
column_headings=list(ascii_uppercase[:len(new_template.placeholders) + 1]),
|
column_headings=list(ascii_uppercase[:len(new_template.placeholders) + 1]),
|
||||||
example_rows=[
|
example_rows=[
|
||||||
first_column_headings[new_template.template_type] + list(new_template.placeholders),
|
first_column_headings[new_template.template_type] + list(new_template.placeholders),
|
||||||
|
|||||||
@@ -41,7 +41,8 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
When you send messages using this template you’ll need
|
When you send messages using this template you’ll need
|
||||||
{{ new_template.placeholders|length + 1 }} columns of data:
|
{{ new_template.placeholders|length + 1 }}
|
||||||
|
column{{ 's' if new_template.placeholders|length > 0 else '' }} of data:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="spreadsheet">
|
<div class="spreadsheet">
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from freezegun import freeze_time
|
|||||||
from notifications_python_client.errors import HTTPError
|
from notifications_python_client.errors import HTTPError
|
||||||
from tests.conftest import service_one as create_sample_service
|
from tests.conftest import service_one as create_sample_service
|
||||||
from tests import validate_route_permission, template_json, single_notification_json
|
from tests import validate_route_permission, template_json, single_notification_json
|
||||||
|
from tests.app.test_utils import normalize_spaces
|
||||||
|
|
||||||
from app.main.views.templates import get_last_use_message, get_human_readable_delta
|
from app.main.views.templates import get_last_use_message, get_human_readable_delta
|
||||||
|
|
||||||
@@ -262,7 +263,7 @@ def test_should_show_interstitial_when_making_breaking_change(
|
|||||||
data={
|
data={
|
||||||
'id': template_id,
|
'id': template_id,
|
||||||
'name': "new name",
|
'name': "new name",
|
||||||
'template_content': "hello",
|
'template_content': "hello ((name)) lets talk about ((thing))",
|
||||||
'template_type': 'email',
|
'template_type': 'email',
|
||||||
'subject': 'reminder',
|
'subject': 'reminder',
|
||||||
'service': service_id,
|
'service': service_id,
|
||||||
@@ -276,10 +277,17 @@ def test_should_show_interstitial_when_making_breaking_change(
|
|||||||
assert page.find('a', {'class': 'page-footer-back-link'})['href'] == url_for(".edit_service_template",
|
assert page.find('a', {'class': 'page-footer-back-link'})['href'] == url_for(".edit_service_template",
|
||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
template_id=template_id)
|
template_id=template_id)
|
||||||
|
for index, p in enumerate([
|
||||||
|
'You removed ((date))',
|
||||||
|
'You added ((name))',
|
||||||
|
'When you send messages using this template you’ll need 3 columns of data:',
|
||||||
|
]):
|
||||||
|
assert normalize_spaces(page.select('main p')[index].text) == p
|
||||||
|
|
||||||
for key, value in {
|
for key, value in {
|
||||||
'name': 'new name',
|
'name': 'new name',
|
||||||
'subject': 'reminder',
|
'subject': 'reminder',
|
||||||
'template_content': 'hello',
|
'template_content': 'hello ((name)) lets talk about ((thing))',
|
||||||
'confirm': 'true'
|
'confirm': 'true'
|
||||||
}.items():
|
}.items():
|
||||||
assert page.find('input', {'name': key})['value'] == value
|
assert page.find('input', {'name': key})['value'] == value
|
||||||
|
|||||||
Reference in New Issue
Block a user