-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deleted the tests which were refering to the old flow as well. The new appointments do not have summary or steps so no need to test with such a configuration.
- Loading branch information
Showing
8 changed files
with
6 additions
and
295 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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import inspect | ||
import re | ||
from copy import deepcopy | ||
from datetime import date, datetime | ||
from decimal import Decimal | ||
from unittest.mock import patch | ||
|
||
|
@@ -10,15 +8,8 @@ | |
from django.template import TemplateSyntaxError | ||
from django.test import TestCase, override_settings | ||
from django.urls import reverse | ||
from django.utils.html import format_html | ||
from django.utils.translation import gettext as _ | ||
|
||
from openforms.appointments.base import ( | ||
AppointmentDetails, | ||
BasePlugin, | ||
Location, | ||
Product, | ||
) | ||
from openforms.appointments.constants import AppointmentDetailsStatus | ||
from openforms.appointments.contrib.demo.plugin import DemoAppointment | ||
from openforms.appointments.tests.factories import AppointmentInfoFactory | ||
|
@@ -32,7 +23,7 @@ | |
) | ||
from openforms.submissions.utils import send_confirmation_email | ||
from openforms.tests.utils import NOOP_CACHES | ||
from openforms.utils.tests.html_assert import HTMLAssertMixin, strip_all_attributes | ||
from openforms.utils.tests.html_assert import HTMLAssertMixin | ||
from openforms.utils.urls import build_absolute_uri | ||
|
||
from ..confirmation_emails import ( | ||
|
@@ -579,51 +570,6 @@ def test_email_payment_completed(self): | |
self.assertNotIn(url, rendered_content) | ||
|
||
|
||
class TestAppointmentPlugin(BasePlugin): | ||
def get_available_products(self, current_products=None): | ||
return [ | ||
Product(identifier="1", name="Test product 1"), | ||
Product(identifier="2", name="Test product 2"), | ||
] | ||
|
||
def get_locations(self, products): | ||
return [Location(identifier="1", name="Test location")] | ||
|
||
def get_dates(self, products, location, start_at=None, end_at=None): | ||
return [date(2021, 1, 1)] | ||
|
||
def get_times(self, products, location, day): | ||
return [datetime(2021, 1, 1, 12, 0)] | ||
|
||
def get_required_customer_fields(self, products): | ||
return [] | ||
|
||
def create_appointment(self, products, location, start_at, client, remarks=None): | ||
return "1" | ||
|
||
def delete_appointment(self, identifier: str) -> None: | ||
return | ||
|
||
def get_appointment_details(self, identifier: str): | ||
return AppointmentDetails( | ||
identifier=identifier, | ||
products=[ | ||
Product(identifier="1", name="Test product 1 & 2"), | ||
Product(identifier="2", name="Test product 3"), | ||
], | ||
location=Location( | ||
identifier="1", | ||
name="Test location", | ||
city="Teststad", | ||
postalcode="1234ab", | ||
), | ||
start_at=datetime(2021, 1, 1, 12, 0), | ||
end_at=datetime(2021, 1, 1, 12, 15), | ||
remarks="Remarks", | ||
other={"Some": "<h1>Data</h1>"}, | ||
) | ||
|
||
|
||
@override_settings(DEFAULT_FROM_EMAIL="[email protected]") | ||
class ConfirmationEmailRenderingIntegrationTest(HTMLAssertMixin, TestCase): | ||
template = """ | ||
|
@@ -647,233 +593,6 @@ class ConfirmationEmailRenderingIntegrationTest(HTMLAssertMixin, TestCase): | |
""" | ||
maxDiff = None | ||
|
||
@patch( | ||
"openforms.emails.templatetags.appointments.get_plugin", | ||
return_value=TestAppointmentPlugin("test"), | ||
) | ||
def test_send_confirmation_mail_text_kitchensink(self, appointment_plugin_mock): | ||
config = GlobalConfiguration.get_solo() | ||
config.email_template_netloc_allowlist = ["gemeente.nl"] | ||
config.save() | ||
|
||
conf = deepcopy(NESTED_COMPONENT_CONF) | ||
conf["components"].append( | ||
{ | ||
"id": "erttrr", | ||
"key": "file", | ||
"type": "file", | ||
"label": "File", | ||
"showInEmail": True, | ||
} | ||
) | ||
|
||
submission = SubmissionFactory.from_components( | ||
conf["components"], | ||
{ | ||
"name": "Foo", | ||
"lastName": "de Bar & de Baas", | ||
"email": "[email protected]", | ||
"file": [ | ||
{ | ||
"url": "http://server/api/v2/submissions/files/62f2ec22-da7d-4385-b719-b8637c1cd483", | ||
"data": { | ||
"url": "http://server/api/v2/submissions/files/62f2ec22-da7d-4385-b719-b8637c1cd483", | ||
"form": "", | ||
"name": "my-image.jpg", | ||
"size": 46114, | ||
"baseUrl": "http://server/form", | ||
"project": "", | ||
}, | ||
"name": "my-image-12305610-2da4-4694-a341-ccb919c3d543.jpg", | ||
"size": 46114, | ||
"type": "image/jpg", | ||
"storage": "url", | ||
"originalName": "my-image.jpg", | ||
} | ||
], | ||
}, | ||
registration_success=True, | ||
public_registration_reference="xyz123", | ||
form__product__price=Decimal("12.34"), | ||
form__product__information="<p>info line 1</p>\r\n<p>info line 2</p>\r\n<p>info line 3</p>", | ||
form__payment_backend="test", | ||
form_url="http://server/form", | ||
co_sign_data={ | ||
"plugin": "digid", | ||
"identifier": "123456782", | ||
"fields": { | ||
"voornaam": "Tina", | ||
"geslachtsnaam": "Shikari", | ||
}, | ||
"representation": "T. Shikari", | ||
}, | ||
) | ||
AppointmentInfoFactory.create( | ||
status=AppointmentDetailsStatus.success, | ||
appointment_id="123456789", | ||
submission=submission, | ||
) | ||
self.assertTrue(submission.payment_required) | ||
self.assertFalse(submission.payment_user_has_paid) | ||
|
||
template = inspect.cleandoc(self.template) | ||
ConfirmationEmailTemplateFactory.create( | ||
form=submission.form, subject="My Subject", content=template | ||
) | ||
first_step_name = submission.submissionstep_set.all()[ | ||
0 | ||
].form_step.form_definition.name | ||
|
||
send_confirmation_email(submission) | ||
|
||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
message = mail.outbox[0] | ||
self.assertEqual(message.subject, "My Subject") | ||
self.assertEqual(message.recipients(), ["[email protected]"]) | ||
self.assertEqual(message.from_email, "[email protected]") | ||
|
||
ref = submission.public_registration_reference | ||
|
||
url_exp = r"https?://[a-z0-9:/._-]+" | ||
pay_line = _( | ||
"Payment of EUR %(payment_price)s is required. You can pay using the link below." | ||
) % {"payment_price": "12,34"} | ||
|
||
with self.subTest("text"): | ||
expected_text = inspect.cleandoc( | ||
f""" | ||
Geachte heer/mevrouw, | ||
Wij hebben uw inzending, met referentienummer {ref}, in goede orde ontvangen. | ||
Kijk voor meer informatie op de homepage (#URL#) | ||
{_("Summary")} | ||
{first_step_name} | ||
- A fieldset | ||
- Name: Foo | ||
- Last name: de Bar & de Baas | ||
- File: {_("attachment: %s") % "my-image.jpg"} | ||
- {_("Co-signed by")}: T. Shikari | ||
{_("Appointment information")} | ||
{_("Products")}: | ||
- Test product 1 & 2 | ||
- Test product 3 | ||
{_("Location")}: | ||
Test location | ||
1234ab Teststad | ||
{_("Date and time")}: | ||
1 januari 2021, 12:00 - 12:15 | ||
{_("Remarks")}: | ||
Remarks | ||
Some: | ||
Data | ||
{_("If you want to cancel or change your appointment, you can do so below.")} | ||
{_("Cancel appointment")}: #URL# | ||
{_("Change appointment")}: #URL# | ||
info line 1 | ||
info line 2 | ||
info line 3 | ||
{_("Payment information")} | ||
{pay_line} | ||
{_("Go to the payment page")}: #URL# | ||
Met vriendelijke groet, | ||
Open Formulieren | ||
""" | ||
).lstrip() | ||
|
||
# process to keep tests sane (random tokens) | ||
text = message.body.rstrip() | ||
text = re.sub(url_exp, "#URL#", text) | ||
self.assertEqual(expected_text, text) | ||
self.assertNotIn("<a ", text) | ||
self.assertNotIn("<td ", text) | ||
self.assertNotIn("<p ", text) | ||
self.assertNotIn("<br ", text) | ||
|
||
with self.subTest("html"): | ||
# html alternative | ||
self.assertEqual(len(message.alternatives), 1) | ||
|
||
message_html = message.alternatives[0][0] | ||
|
||
self.assertTagWithTextIn("td", "Name", message_html) | ||
self.assertTagWithTextIn("td", "Foo", message_html) | ||
self.assertIn('<a href="http://gemeente.nl">', message_html) | ||
|
||
message_html_only_tags = strip_all_attributes(message_html) | ||
# check co-sign data presence | ||
self.assertInHTML( | ||
format_html( | ||
"<tr> <td>{label}</td> <td>T. Shikari</td> </tr>", | ||
label=_("Co-signed by"), | ||
), | ||
message_html_only_tags, | ||
) | ||
|
||
# fieldset and step containers should be visible | ||
self.assertInHTML( | ||
format_html("<h3>{}</h3>", first_step_name), | ||
message_html_only_tags, | ||
) | ||
|
||
# renderer should ignore hidden inputs | ||
self.assertNotIn("Hidden input", message_html_only_tags) | ||
self.assertNotIn("A fieldset with hidden children", message_html_only_tags) | ||
self.assertNotIn("Hidden input 2", message_html_only_tags) | ||
|
||
with self.subTest("attachments"): | ||
# file uploads may not be added as attachments, see #1193 | ||
self.assertEqual(message.attachments, []) | ||
|
||
@patch( | ||
"openforms.emails.templatetags.appointments.get_plugin", | ||
return_value=TestAppointmentPlugin("test"), | ||
) | ||
def test_html_in_subject(self, appointment_plugin_mock): | ||
"""Assert that HTML is not escaped in Email subjects""" | ||
|
||
conf = deepcopy(NESTED_COMPONENT_CONF) | ||
|
||
submission = SubmissionFactory.from_components( | ||
conf["components"], | ||
{ | ||
"name": "John", | ||
"lastName": "Doe", | ||
"email": "[email protected]", | ||
}, | ||
registration_success=True, | ||
) | ||
submission.form.name = "Foo's bar" | ||
|
||
template = inspect.cleandoc(self.template) | ||
|
||
ConfirmationEmailTemplateFactory.create( | ||
form=submission.form, subject="Subject: {{ form_name }}", content=template | ||
) | ||
|
||
send_confirmation_email(submission) | ||
|
||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
message = mail.outbox[0] | ||
self.assertEqual(message.subject, "Subject: Foo's bar") | ||
|
||
def test_templatetag_alias(self): | ||
submission = SubmissionFactory.from_components( | ||
[ | ||
|
1 change: 0 additions & 1 deletion
1
src/openforms/js/components/admin/form_design/form-creation-form.js
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
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