|
1 | 1 | import logging
|
2 | 2 |
|
3 |
| -from django.test import TestCase, override_settings |
| 3 | +from django.test import TestCase, override_settings, tag |
4 | 4 | from django.utils.html import format_html
|
5 | 5 | from django.utils.translation import gettext_lazy as _
|
6 | 6 |
|
|
10 | 10 | from testfixtures import LogCapture
|
11 | 11 |
|
12 | 12 | from openforms.config.models import GlobalConfiguration
|
| 13 | +from openforms.forms.tests.factories import FormLogicFactory |
13 | 14 |
|
| 15 | +from ..form_logic import evaluate_form_logic |
14 | 16 | from ..models import SubmissionReport
|
15 | 17 | from ..tasks.pdf import generate_submission_report
|
16 | 18 | from .factories import SubmissionFactory, SubmissionReportFactory
|
@@ -108,6 +110,45 @@ def test_hidden_output_not_included(self):
|
108 | 110 | # step has no visible children -> also not visible
|
109 | 111 | self.assertNotIn(step_title, html)
|
110 | 112 |
|
| 113 | + @tag("gh-5037") |
| 114 | + def test_date_object_is_converted_to_str_when_it_comes_from_logic_rule(self): |
| 115 | + submission = SubmissionFactory.from_components( |
| 116 | + [ |
| 117 | + { |
| 118 | + "type": "date", |
| 119 | + "key": "date1", |
| 120 | + }, |
| 121 | + { |
| 122 | + "type": "date", |
| 123 | + "key": "updatedDate", |
| 124 | + }, |
| 125 | + ], |
| 126 | + submitted_data={"date1": "2025-01-01"}, |
| 127 | + completed=True, |
| 128 | + with_report=True, |
| 129 | + ) |
| 130 | + |
| 131 | + FormLogicFactory.create( |
| 132 | + form=submission.form, |
| 133 | + json_logic_trigger={"==": [{"var": "date1"}, "2025-01-01"]}, |
| 134 | + actions=[ |
| 135 | + { |
| 136 | + "variable": "updatedDate", |
| 137 | + "action": { |
| 138 | + "type": "variable", |
| 139 | + "value": {"+": [{"var": "date1"}, {"duration": "P1M"}]}, |
| 140 | + }, |
| 141 | + }, |
| 142 | + ], |
| 143 | + ) |
| 144 | + evaluate_form_logic( |
| 145 | + submission, submission.submissionstep_set.get(), submission.data |
| 146 | + ) |
| 147 | + |
| 148 | + html = submission.report.generate_submission_report_pdf() |
| 149 | + |
| 150 | + self.assertIn("31 januari 2025", html) |
| 151 | + |
111 | 152 | def test_visible_output_included(self):
|
112 | 153 | """
|
113 | 154 | Assert that hidden components are not included in the report.
|
|
0 commit comments