Fetch template length message as user types

This commit adds some Javascript that makes AJAX requests as the users
changes the content of their template.

It then takes the content returned by the backend and inserts it in the
page.
This commit is contained in:
Chris Hill-Scott
2021-01-06 17:32:46 +00:00
parent ca50d77ac2
commit 3fdaa29f35
6 changed files with 201 additions and 1 deletions

View File

@@ -467,10 +467,27 @@ def test_should_show_page_for_one_template(
assert page.select_one('textarea')['data-module'] == 'enhanced-textbox'
assert page.select_one('textarea')['data-highlight-placeholders'] == 'true'
assert "priority" not in str(page.select_one('main'))
assert (
page.select_one('[data-module=update-status]')['data-target']
) == (
page.select_one('textarea')['id']
) == (
'template_content'
)
assert (
page.select_one('[data-module=update-status]')['data-updates-url']
) == url_for(
'.count_content_length',
service_id=SERVICE_ONE_ID,
template_type='sms',
)
mock_get_service_template.assert_called_with(SERVICE_ONE_ID, template_id, None)
def test_broadcast_template_doesnt_highlight_placeholders(
def test_broadcast_template_doesnt_highlight_placeholders_but_does_count_characters(
client_request,
service_one,
mock_get_broadcast_template,
@@ -485,6 +502,22 @@ def test_broadcast_template_doesnt_highlight_placeholders(
assert page.select_one('textarea')['data-module'] == 'enhanced-textbox'
assert page.select_one('textarea')['data-highlight-placeholders'] == 'false'
assert (
page.select_one('[data-module=update-status]')['data-target']
) == (
page.select_one('textarea')['id']
) == (
'template_content'
)
assert (
page.select_one('[data-module=update-status]')['data-updates-url']
) == url_for(
'.count_content_length',
service_id=SERVICE_ONE_ID,
template_type='broadcast',
)
def test_caseworker_redirected_to_one_off(
client_request,