-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't require description if the category is hidden (#1910)
* fix: dont require description if the category is hidden * test: fix template category in the test data * fix formatting * Fix tests * chore: formatting * test: rename test; add template-categories test suite to CI * fix: default hidden categories to display as "other" on template list and fitlers * fix(test): update test to look for "Other" category * fix: maintain category id of hidden categories * fix: sort filters alphabetically * test: ensure filters are sorted alphabetically * chore: remove default value for FF_TEMPLATE_CATEGORY from test config and rely on .env * chore: formatting * chore: formatting --------- Co-authored-by: Jumana Bahrainwala <[email protected]>
- Loading branch information
1 parent
1e4461a
commit b45837b
Showing
7 changed files
with
97 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ | |
{% else %} | ||
{{ _('Other') }} | ||
{% endif %} | ||
</span> | ||
</span> | ||
{% endif %} | ||
</div> | ||
{% endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,16 +165,24 @@ def test_edit_email_template_cat_other_to_freshdesk( | |
"name": name, | ||
"template_content": content, | ||
"template_type": "sms", | ||
"template_category_id": DEFAULT_TEMPLATE_CATEGORY_LOW, | ||
"template_category_id": DEFAULT_TEMPLATE_CATEGORY_LOW if app_.config["FF_TEMPLATE_CATEGORY"] else None, | ||
"service": SERVICE_ONE_ID, | ||
"template_category_other": "hello", | ||
"reply_to_text": "[email protected]", | ||
"process_type": None if app_.config["FF_TEMPLATE_CATEGORY"] else DEFAULT_PROCESS_TYPE, | ||
}, | ||
_follow_redirects=True, | ||
) | ||
|
||
mock_update_service_template.assert_called_with( | ||
fake_uuid, name, "sms", content, SERVICE_ONE_ID, None, DEFAULT_PROCESS_TYPE, DEFAULT_TEMPLATE_CATEGORY_LOW | ||
fake_uuid, | ||
name, | ||
"sms", | ||
content, | ||
SERVICE_ONE_ID, | ||
None, | ||
None if app_.config["FF_TEMPLATE_CATEGORY"] else DEFAULT_PROCESS_TYPE, | ||
DEFAULT_TEMPLATE_CATEGORY_LOW if app_.config["FF_TEMPLATE_CATEGORY"] else None, | ||
) | ||
assert mock_send_other_category_to_freshdesk.called is True | ||
mock_send_other_category_to_freshdesk.assert_called_once_with( | ||
|
@@ -294,7 +302,7 @@ def test_should_show_page_for_choosing_a_template( | |
page = client_request.get("main.choose_template", service_id=service_one["id"], **extra_args) | ||
|
||
if app_.config["FF_TEMPLATE_CATEGORY"]: | ||
expected_nav_links = ["All", "Email template", "Text message template", "All"] | ||
expected_nav_links = ["All", "Email template", "Text message template", "All", "Other"] | ||
links_in_page = page.select('nav[data-testid="filter-content"] a') | ||
else: | ||
expected_nav_links = ["All", "Email", "Text message", "Letter"] | ||
|
@@ -1335,40 +1343,50 @@ def test_should_redirect_to_one_off_if_template_type_is_letter( | |
) | ||
|
||
|
||
# parametrize with FF enabled and disabled | ||
@pytest.mark.parametrize("ff_enabled", [True, False]) | ||
def test_should_redirect_when_saving_a_template( | ||
client_request, mock_get_template_categories, mock_get_service_template, mock_update_service_template, fake_uuid, app_ | ||
client_request, | ||
mock_get_template_categories, | ||
mock_get_service_template, | ||
mock_update_service_template, | ||
fake_uuid, | ||
app_, | ||
ff_enabled, | ||
): | ||
name = "new name" | ||
content = "template <em>content</em> with & entity" | ||
page = client_request.post( | ||
".edit_service_template", | ||
service_id=SERVICE_ONE_ID, | ||
template_id=fake_uuid, | ||
_data={ | ||
"id": fake_uuid, | ||
"name": name, | ||
"template_content": content, | ||
"template_type": "sms", | ||
"template_category_id": DEFAULT_TEMPLATE_CATEGORY_LOW, | ||
"service": SERVICE_ONE_ID, | ||
"process_type": DEFAULT_PROCESS_TYPE, | ||
}, | ||
_follow_redirects=True, | ||
) | ||
with set_config(app_, "FF_TEMPLATE_CATEGORY", ff_enabled): | ||
name = "new name" | ||
content = "template <em>content</em> with & entity" | ||
|
||
flash_banner = page.select_one(".banner-default-with-tick").string.strip() | ||
assert flash_banner == f"'{name}' template saved" | ||
page = client_request.post( | ||
".edit_service_template", | ||
service_id=SERVICE_ONE_ID, | ||
template_id=fake_uuid, | ||
_data={ | ||
"id": fake_uuid, | ||
"name": name, | ||
"template_content": content, | ||
"template_type": "sms", | ||
"template_category_id": DEFAULT_TEMPLATE_CATEGORY_LOW if ff_enabled else None, | ||
"service": SERVICE_ONE_ID, | ||
"process_type": None if ff_enabled else DEFAULT_PROCESS_TYPE, | ||
}, | ||
_follow_redirects=True, | ||
) | ||
|
||
mock_update_service_template.assert_called_with( | ||
fake_uuid, | ||
name, | ||
"sms", | ||
content, | ||
SERVICE_ONE_ID, | ||
None, | ||
DEFAULT_PROCESS_TYPE, | ||
DEFAULT_TEMPLATE_CATEGORY_LOW if app_.config["FF_TEMPLATE_CATEGORY"] else None, | ||
) | ||
flash_banner = page.select_one(".banner-default-with-tick").string.strip() | ||
assert flash_banner == f"'{name}' template saved" | ||
# self, id_, name, type_, content, service_id, subject=None, process_type=None, template_category_id=None | ||
mock_update_service_template.assert_called_with( | ||
fake_uuid, | ||
name, | ||
"sms", | ||
content, | ||
SERVICE_ONE_ID, | ||
None, | ||
None if ff_enabled else DEFAULT_PROCESS_TYPE, | ||
DEFAULT_TEMPLATE_CATEGORY_LOW if ff_enabled else None, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("process_type", [TemplateProcessTypes.NORMAL.value, TemplateProcessTypes.PRIORITY.value]) | ||
|
@@ -1617,16 +1635,16 @@ def test_removing_placeholders_is_not_a_breaking_change( | |
|
||
@pytest.mark.parametrize("template_type", ["sms", "email"]) | ||
def test_should_not_update_if_template_name_too_long( | ||
client_request, template_type, fake_uuid, mock_get_service_template, mock_update_service_template_400_name_too_long | ||
client_request, template_type, fake_uuid, mock_get_service_template, mock_update_service_template_400_name_too_long, app_ | ||
): | ||
template_data = { | ||
"id": fake_uuid, | ||
"service": SERVICE_ONE_ID, | ||
"name": "new name", | ||
"template_content": "template content!!", | ||
"template_type": template_type, | ||
"template_category_id": DEFAULT_TEMPLATE_CATEGORY_LOW, | ||
"process_type": DEFAULT_PROCESS_TYPE, | ||
"template_category_id": DEFAULT_TEMPLATE_CATEGORY_LOW if app_.config["FF_TEMPLATE_CATEGORY"] else None, | ||
"process_type": TC_PRIORITY_VALUE if app_.config["FF_TEMPLATE_CATEGORY"] else DEFAULT_PROCESS_TYPE, | ||
} | ||
if template_type == "email": | ||
template_data.update({"subject": "subject"}) | ||
|
@@ -1692,10 +1710,7 @@ def test_should_not_create_too_big_template( | |
|
||
|
||
def test_should_not_update_too_big_template( | ||
client_request, | ||
mock_get_service_template, | ||
mock_update_service_template_400_content_too_big, | ||
fake_uuid, | ||
client_request, mock_get_service_template, mock_update_service_template_400_content_too_big, fake_uuid, app_ | ||
): | ||
page = client_request.post( | ||
".edit_service_template", | ||
|
@@ -1708,7 +1723,7 @@ def test_should_not_update_too_big_template( | |
"service": SERVICE_ONE_ID, | ||
"template_type": "sms", | ||
"template_category_id": DEFAULT_TEMPLATE_CATEGORY_LOW, | ||
"process_type": DEFAULT_PROCESS_TYPE, | ||
"process_type": TC_PRIORITY_VALUE if app_.config["FF_TEMPLATE_CATEGORY"] else DEFAULT_PROCESS_TYPE, | ||
}, | ||
_expected_status=200, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters