diff --git a/src/open_inwoner/configurations/tests/test_admin.py b/src/open_inwoner/configurations/tests/test_admin.py index d1f59b6013..d3695a8434 100644 --- a/src/open_inwoner/configurations/tests/test_admin.py +++ b/src/open_inwoner/configurations/tests/test_admin.py @@ -118,6 +118,10 @@ def setUp(self): self.form["secondary_font_color"] = "#FFFFFF" self.form["accent_color"] = "#FFFFFF" self.form["accent_font_color"] = "#FFFFFF" + # django-jsonform requires JS to work properly and with Webtest the default + # value for ArrayFields is an empty string, causing it crash to when trying to parse + # that value as JSON + self.form["recipients_email_digest"] = "[]" def test_valid_path_is_saved(self): config = SiteConfiguration.get_solo() diff --git a/src/open_inwoner/configurations/tests/test_colors.py b/src/open_inwoner/configurations/tests/test_colors.py index 61fcdba568..9e9fa404d9 100644 --- a/src/open_inwoner/configurations/tests/test_colors.py +++ b/src/open_inwoner/configurations/tests/test_colors.py @@ -27,6 +27,10 @@ def test_contrast_is_checked(self): form["secondary_font_color"] = "#FFFFFF" form["accent_color"] = "#FFFFFF" form["accent_font_color"] = "#FFFFFF" + # django-jsonform requires JS to work properly and with Webtest the default + # value for ArrayFields is an empty string, causing it crash to when trying to parse + # that value as JSON + form["recipients_email_digest"] = "[]" response = form.submit("_continue").follow() messages = list(response.context["messages"]) diff --git a/src/open_inwoner/configurations/tests/test_upload.py b/src/open_inwoner/configurations/tests/test_upload.py index 9a95a3aa2d..e22e59b31d 100644 --- a/src/open_inwoner/configurations/tests/test_upload.py +++ b/src/open_inwoner/configurations/tests/test_upload.py @@ -23,6 +23,11 @@ def setUp(self): reverse("admin:configurations_siteconfiguration_change"), user=self.user ).forms["siteconfiguration_form"] + # django-jsonform requires JS to work properly and with Webtest the default + # value for ArrayFields is an empty string, causing it crash to when trying to parse + # that value as JSON + self.form["recipients_email_digest"] = "[]" + def test_upload_font_correct_filetype(self): font_file = Upload("valid.ttf", b"content", content_type="font/ttf") self.form["name"] = "Test" diff --git a/src/open_inwoner/pdc/admin/category.py b/src/open_inwoner/pdc/admin/category.py index fe1248130c..27327631bd 100644 --- a/src/open_inwoner/pdc/admin/category.py +++ b/src/open_inwoner/pdc/admin/category.py @@ -52,7 +52,7 @@ def zaaktypen_select_schema() -> dict: class CategoryAdminForm(movenodeform_factory(Category)): - zaaktypen = JSONFormField(schema=zaaktypen_select_schema) + zaaktypen = JSONFormField(schema=zaaktypen_select_schema, required=False) class Meta: model = Category diff --git a/src/open_inwoner/pdc/tests/test_category_admin.py b/src/open_inwoner/pdc/tests/test_category_admin.py index ec48af16f8..4c134ea736 100644 --- a/src/open_inwoner/pdc/tests/test_category_admin.py +++ b/src/open_inwoner/pdc/tests/test_category_admin.py @@ -1,3 +1,4 @@ +import json from unittest.mock import patch from django.contrib.auth.models import Permission @@ -28,6 +29,10 @@ def test_user_can_publish_root_category_on_add_form(self): form["published"] = True form["_position"] = "first-child" form["_ref_node_id"] = 0 + # django-jsonform requires JS to work properly and with Webtest the default + # value for ArrayFields is an empty string, causing it crash to when trying to parse + # that value as JSON + form["zaaktypen"] = "[]" form.submit() category = Category.objects.first() self.assertEqual(category.slug, "foo1") @@ -43,6 +48,10 @@ def test_user_can_publish_child_category_with_root_published_on_add_form(self): form["published"] = True form["_position"] = "first-child" form["_ref_node_id"] = root.id + # django-jsonform requires JS to work properly and with Webtest the default + # value for ArrayFields is an empty string, causing it crash to when trying to parse + # that value as JSON + form["zaaktypen"] = "[]" form.submit() updated_category = Category.objects.get(slug="bar1") self.assertTrue(updated_category.published) @@ -178,7 +187,7 @@ def test_user_can_link_zaaktypen_if_category_filtering_with_zaken_feature_flag_e user=self.user, ).form - form["zaaktypen"] = "001" + form["zaaktypen"] = json.dumps(["001"]) response = form.submit("_save") self.assertEqual(response.status_code, 302) @@ -201,7 +210,7 @@ def test_user_cannot_link_zaaktypen_if_category_filtering_with_zaken_feature_fla user=self.user, ).form - form["zaaktypen"] = "001" + form["zaaktypen"] = json.dumps(["001"]) response = form.submit() self.assertEqual(response.status_code, 200) diff --git a/src/open_inwoner/pdc/tests/test_logging.py b/src/open_inwoner/pdc/tests/test_logging.py index 6d16bda7f5..574bd7e234 100644 --- a/src/open_inwoner/pdc/tests/test_logging.py +++ b/src/open_inwoner/pdc/tests/test_logging.py @@ -176,6 +176,10 @@ def test_addition(self): form = response.forms["category_form"] form["name"] = self.category.name form["slug"] = self.category.slug + # django-jsonform requires JS to work properly and with Webtest the default + # value for ArrayFields is an empty string, causing it crash to when trying to parse + # that value as JSON + form["zaaktypen"] = "[]" form.submit() category = Category.objects.filter(slug=self.category.slug).first() log_entry = TimelineLog.objects.last() @@ -201,6 +205,10 @@ def test_change(self): ) form = response.forms["category_form"] form["description"] = "Updated description" + # django-jsonform requires JS to work properly and with Webtest the default + # value for ArrayFields is an empty string, causing it crash to when trying to parse + # that value as JSON + form["zaaktypen"] = "[]" form.submit() log_entry = TimelineLog.objects.last() @@ -212,7 +220,7 @@ def test_change(self): self.assertEqual( log_entry.extra_data, { - "message": "Omschrijving, Ten opzichte van and Zaaktypen gewijzigd.", + "message": "Omschrijving and Ten opzichte van gewijzigd.", "action_flag": [2, "Change"], "content_object_repr": category.name, },