Merge branch 'main' into 2579-updating-homepage-content-at-end-of-may

This commit is contained in:
Beverly Nguyen
2025-06-11 11:31:44 -07:00
17 changed files with 5658 additions and 1183 deletions

View File

@@ -1725,111 +1725,111 @@ def test_add_template_page_title(
assert normalize_spaces(page.select_one("h1").text) == expected
def test_can_create_email_template_with_emoji(
client_request, mock_create_service_template
):
client_request.post(
".add_service_template",
service_id=SERVICE_ONE_ID,
template_type="email",
_data={
"name": "new name",
"subject": "Food incoming!",
"template_content": "here's a burrito 🌯",
"template_type": "email",
"service": SERVICE_ONE_ID,
"process_type": "normal",
},
_expected_status=302,
)
assert mock_create_service_template.called is True
# def test_can_create_email_template_with_emoji(
# client_request, mock_create_service_template
# ):
# client_request.post(
# ".add_service_template",
# service_id=SERVICE_ONE_ID,
# template_type="email",
# _data={
# "name": "new name",
# "subject": "Food incoming!",
# "template_content": "here's a burrito 🌯",
# "template_type": "email",
# "service": SERVICE_ONE_ID,
# "process_type": "normal",
# },
# _expected_status=302,
# )
# assert mock_create_service_template.called is True
@pytest.mark.parametrize(
("template_type", "expected_error"),
[
(
"sms",
(
"Please remove the unaccepted character 🍜 in your message, then save again"
),
),
],
)
def test_should_not_create_sms_template_with_emoji(
client_request,
service_one,
mock_create_service_template,
template_type,
expected_error,
):
service_one["permissions"] += [template_type]
page = client_request.post(
".add_service_template",
service_id=SERVICE_ONE_ID,
template_type=template_type,
_data={
"name": "new name",
"template_content": "here are some noodles 🍜",
"template_type": "sms",
"service": SERVICE_ONE_ID,
"process_type": "normal",
},
_expected_status=200,
)
# print(page.main.prettify())
assert expected_error in normalize_spaces(
page.select_one("#template_content-error").text
)
assert mock_create_service_template.called is False
# @pytest.mark.parametrize(
# ("template_type", "expected_error"),
# [
# (
# "sms",
# (
# "Please remove the unaccepted character 🍜 in your message, then save again"
# ),
# ),
# ],
# )
# def test_should_not_create_sms_template_with_emoji(
# client_request,
# service_one,
# mock_create_service_template,
# template_type,
# expected_error,
# ):
# service_one["permissions"] += [template_type]
# page = client_request.post(
# ".add_service_template",
# service_id=SERVICE_ONE_ID,
# template_type=template_type,
# _data={
# "name": "new name",
# "template_content": "here are some noodles 🍜",
# "template_type": "sms",
# "service": SERVICE_ONE_ID,
# "process_type": "normal",
# },
# _expected_status=200,
# )
# # print(page.main.prettify())
# assert expected_error in normalize_spaces(
# page.select_one("#template_content-error").text
# )
# assert mock_create_service_template.called is False
@pytest.mark.parametrize(
("template_type", "expected_error"),
[
(
"sms",
(
"Please remove the unaccepted character 🍔 in your message, then save again"
),
),
],
)
def test_should_not_update_sms_template_with_emoji(
mocker,
client_request,
service_one,
mock_get_service_template,
mock_update_service_template,
fake_uuid,
template_type,
expected_error,
):
service_one["permissions"] += [template_type]
return mocker.patch(
"app.service_api_client.get_service_template",
return_value=template_json(
SERVICE_ONE_ID,
fake_uuid,
type_=template_type,
),
)
page = client_request.post(
".edit_service_template",
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
_data={
"id": fake_uuid,
"name": "new name",
"template_content": "here's a burger 🍔",
"service": SERVICE_ONE_ID,
"template_type": template_type,
"process_type": "normal",
},
_expected_status=200,
)
assert expected_error in page.text
assert mock_update_service_template.called is False
# @pytest.mark.parametrize(
# ("template_type", "expected_error"),
# [
# (
# "sms",
# (
# "Please remove the unaccepted character 🍔 in your message, then save again"
# ),
# ),
# ],
# )
# def test_should_not_update_sms_template_with_emoji(
# mocker,
# client_request,
# service_one,
# mock_get_service_template,
# mock_update_service_template,
# fake_uuid,
# template_type,
# expected_error,
# ):
# service_one["permissions"] += [template_type]
# return mocker.patch(
# "app.service_api_client.get_service_template",
# return_value=template_json(
# SERVICE_ONE_ID,
# fake_uuid,
# type_=template_type,
# ),
# )
# page = client_request.post(
# ".edit_service_template",
# service_id=SERVICE_ONE_ID,
# template_id=fake_uuid,
# _data={
# "id": fake_uuid,
# "name": "new name",
# "template_content": "here's a burger 🍔",
# "service": SERVICE_ONE_ID,
# "template_type": template_type,
# "process_type": "normal",
# },
# _expected_status=200,
# )
# assert expected_error in page.text
# assert mock_update_service_template.called is False
@pytest.mark.parametrize(

View File

@@ -1,8 +1,10 @@
# import datetime
import datetime
import os
import re
import uuid
# import pytest
from playwright.sync_api import expect
from tests.end_to_end.conftest import check_axe_report
@@ -10,7 +12,7 @@ from tests.end_to_end.conftest import check_axe_report
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
async def create_new_template(page):
def create_new_template(page):
current_service_link = page.get_by_text("Current service")
expect(current_service_link).to_be_visible()
@@ -82,8 +84,6 @@ async def create_new_template(page):
page.wait_for_load_state("domcontentloaded")
preview_button = page.get_by_text("Preview")
assert await preview_button.evaluate("el => el.tagName") == "BUTTON"
expect(preview_button).to_be_visible()
preview_button.click()
@@ -94,7 +94,7 @@ async def create_new_template(page):
# We are not going to send the message for this test, we just want to confirm
# that the template has been created and we are now seeing the message from the
# template in the preview.
assert "Test message for e2e test" in page.content()
# assert "Test message for e2e test" in page.content()
def test_create_new_template(end_to_end_context):