Skip to content

Commit

Permalink
Content QA for template category (#1914)
Browse files Browse the repository at this point in the history
* Align content translations with Figma

* Update cypress tests

* Reverted TEMPLATE_TYPES

* Simplify message_type so that we can compose the template descriptions.

* Fix tests to match content changes

* Remove FF from config.py

* Remove duplicate translation

---------

Co-authored-by: Jumana B <[email protected]>
  • Loading branch information
amazingphilippe and jzbahrai authored Jul 31, 2024
1 parent 5db650b commit 1b334aa
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 29 deletions.
14 changes: 7 additions & 7 deletions app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,26 +1920,26 @@ class TemplateCategoryForm(StripWhitespaceForm):
name_fr = StringField("FR", validators=[DataRequired(message=_l("This cannot be empty"))])
description_en = StringField("EN")
description_fr = StringField("FR")
hidden = RadioField(_l("Category visibility"), choices=[("True", _l("Hide")), ("False", _l("Show"))])
hidden = RadioField(_l("Hide category"), choices=[("True", _l("Hide")), ("False", _l("Show"))])
sms_sending_vehicle = RadioField(
_l("Sending method for text messages"), choices=[("long_code", _l("Long code")), ("short_code", _l("Short code"))]
)

email_process_type = RadioField(
_l("Email priority"),
choices=[
("priority", _l("High")),
("normal", _l("Medium")),
("bulk", _l("Low")),
("priority", _l("Priority")),
("normal", _l("Normal")),
("bulk", _l("Bulk")),
],
validators=[DataRequired(message=_l("This cannot be empty"))],
)
sms_process_type = RadioField(
_l("Text message priority"),
choices=[
("priority", _l("High")),
("normal", _l("Medium")),
("bulk", _l("Low")),
("priority", _l("Priority")),
("normal", _l("Normal")),
("bulk", _l("Bulk")),
],
validators=[DataRequired(message=_l("This cannot be empty"))],
)
6 changes: 3 additions & 3 deletions app/main/views/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@

# Todo: Remove this once the process_types in the backend are updated to use low/med/high
category_mapping = {
"bulk": "Low",
"normal": "Medium",
"priority": "High",
"bulk": "Bulk",
"normal": "Normal",
"priority": "Priority",
}

form_objects_with_category = {
Expand Down
7 changes: 4 additions & 3 deletions app/models/template_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from flask_babel import lazy_gettext as _l

TEMPLATE_TYPES = {
"email": _l("Email template"),
"sms": _l("Text message template"),
"letter": _l("Letter template"),
"email": _l("Email"),
"sms": _l("Text message"),
"letter": _l("Letter"),
}
TEMPLATE_TYPES_NO_LETTER = filtered_template_types = {key: value for key, value in TEMPLATE_TYPES.items() if key != "letter"}

Expand Down Expand Up @@ -121,6 +121,7 @@ def __init__(
super().__init__(template, ancestors)
self.service_id = service_id
self.hint = TEMPLATE_TYPES.get(template["template_type"])
self.type = template["template_type"]


class TemplateListFolder(TemplateListItem):
Expand Down
3 changes: 2 additions & 1 deletion app/templates/views/templates/_template_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
{% endif %}
</span>
<span id="sr-{{ item.id }}1" class="message-meta message-type">
{{ _(item.hint) }}
{# Compose hint + "template" IF it has a type. ELSE just print the hint #}
{{ _("{} template").format(_(item.hint)) | capitalize if item.type else _(item.hint) }}
</span>
{% if config["FF_TEMPLATE_CATEGORY"] %}
<span id="sr-{{ item.id }}2" class="message-meta message-category">
Expand Down
3 changes: 2 additions & 1 deletion app/templates/views/templates/copy.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ <h2 class="message-name">
{% endif %}
</h2>
<p class="message-type">
{{ _(item.hint) }}
{# Compose hint + "template" IF it has a type. ELSE just print the hint #}
{{ _("{} template").format(_(item.hint)) | capitalize if item.type else _(item.hint) }}
</p>
</div>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/templates/template_categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
{% endcall %}
{% else %}
{% call field() %}
{{ _("Visible") }}
{{ _("Show") }}
{% endcall %}
{% endif %}
{% endcall %}
Expand Down
12 changes: 10 additions & 2 deletions app/templates/views/templates/template_category.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@
<div class="form-group contain-floats box-border mb-gutterHalf md:mb-gutter">

<div class="mb-gutterHalf md:mb-gutter">
{{ textbox_localized("name", fields=({"en": form.name_en, "fr": form.name_fr}), legend=_("Describe category"), hint=_("Explain purpose of message")) }}
{{ textbox_localized(
"name",
fields=({"en": form.name_en, "fr": form.name_fr}),
legend=_("Category name")
) }}
</div>
<div class="mb-gutterHalf md:mb-gutter">
{{ textbox_localized("desc", fields=({"en": form.description_en, "fr": form.description_fr}), legend=_("Category description"), hint=_("Explain purpose of message")) }}
{{ textbox_localized(
"desc",
fields=({"en": form.description_en, "fr": form.description_fr}),
legend=_("Category description")
) }}
</div>

{{ radios(form.hidden) }}
Expand Down
13 changes: 5 additions & 8 deletions app/translations/csv/fr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@
"Manage settings and team","Gérer les paramètres et l'équipe"
"Manage API integration","Gérer l’intégration de l’API"
"default","par défaut"
"Email template","Courriel"
"Text message template","Message texte"
"Letter template","Gabarit de lettre"
"Email template","Gabarit de courriel"
"Text message template","Gabarit de message texte"
"{} template","Gabarit de {}"
"Menu","Menu"
"API documentation","Documentation API"
"Platform admin","Administrateur de la plateforme"
Expand Down Expand Up @@ -1911,14 +1911,12 @@
"Read and agree to the terms of use","Lisez et acceptez les conditions d’utilisation"
"Read and agree to continue","Lire et accepter pour continuer"
"Agree follows terms of use","Accepter suite aux conditions d'utilisation"
"High","Envoi prioritaire",
"Medium","Envoi normal"
"Low","Envoi de masse"
"Priority","Envoi prioritaire",
"Bulk","Envoi de masse"
"Text message priority","Niveau de priorité des messages texte"
"Hide category","Visibilité de la catégorie"
"Email priority","Niveau de priorité des courriels"
"Hide","Invisible"
"Visible","Visible"
"Category label","Étiquette de la catégorie"
"Category description","Description de la catégorie"
"Select category","Sélectionnez une catégorie"
Expand All @@ -1929,7 +1927,6 @@
"Cannot delete template category, ‘{}’, is associated with templates",""
"Long code","Code long"
"Short code","Code abrégé"
"Category visibility","Visibilité de la catégorie"
"You cannot delete a template category that is associated with a template","Impossible de supprimer la catégorie de gabarit ‘{}’, elle est associée à des gabarits."
"Category name","Nom de la catégorie"
"Visibility","Visibilité"
Expand Down
2 changes: 1 addition & 1 deletion tests/app/main/views/test_template_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def test_should_show_templates_folder_page(
assert normalize_spaces(page.select_one("h1").text) == expected_page_title

if app_.config["FF_TEMPLATE_CATEGORY"]:
expected_nav_links = ["All", "Email template", "Text message template", "All"]
expected_nav_links = ["All", "Email", "Text message", "All"]
links_in_page = page.select('nav[data-testid="filter-content"] a')
else:
expected_nav_links = ["All", "Email", "Text message", "Letter"]
Expand Down
2 changes: 1 addition & 1 deletion tests/app/main/views/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,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", "Other"]
expected_nav_links = ["All", "Email", "Text message", "All", "Other"]
links_in_page = page.select('nav[data-testid="filter-content"] a')
else:
expected_nav_links = ["All", "Email", "Text message", "Letter"]
Expand Down
2 changes: 1 addition & 1 deletion tests_cypress/cypress/e2e/admin/template-filters.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import config from "../../../config";
import { TemplateFiltersPage as Page } from "../../Notify/Admin/Pages/all";

const types = {
en: ["Email template", "Text message template"],
en: ["Email", "Text message"],
fr: ["Courriel", "Message texte"],
};

Expand Down

0 comments on commit 1b334aa

Please sign in to comment.