Skip to content

Commit

Permalink
🧪 [#5035] Add test for unintended mutation side effect
Browse files Browse the repository at this point in the history
Damn you, side effects.
  • Loading branch information
sergei-maertens committed Jan 28, 2025
1 parent 73d451f commit 97d0cc4
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/openforms/submissions/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,54 @@ def test_names_do_not_break_pdf_saving_to_disk(self):
report.generate_submission_report_pdf()

self.assertTrue(report.content.storage.exists(report.content.name))

@tag("gh-5035")
def test_total_configuration_wrapper_does_not_mutate_first_step(self):
form = FormFactory.create(
generate_minimal_setup=True,
formstep__form_definition__configuration={
"components": [
{
"key": "textfield1",
"type": "textfield",
"label": "textfield",
}
]
},
)
FormStepFactory.create(
form=form,
order=1,
form_definition__configuration={
"components": [
{
"key": "textfield2",
"type": "textfield",
"label": "Text field 2",
}
]
},
)
submission = SubmissionFactory.create(form=form)

configuration_wrapper = submission.total_configuration_wrapper

with self.subTest("all keys present"):
self.assertIn("textfield1", configuration_wrapper)
self.assertIn("textfield2", configuration_wrapper)

step1, step2 = submission.steps

with self.subTest("step 1 keys"):
step1_keys = [
c["key"]
for c in step1.form_step.form_definition.configuration["components"]
]
self.assertEqual(step1_keys, ["textfield1"])

with self.subTest("step 2 keys"):
step2_keys = [
c["key"]
for c in step2.form_step.form_definition.configuration["components"]
]
self.assertEqual(step2_keys, ["textfield2"])

0 comments on commit 97d0cc4

Please sign in to comment.