@@ -438,3 +438,112 @@ def test_object_nulls_regression(self, m):
438
438
},
439
439
},
440
440
)
441
+
442
+ @tag ("dh-673" , "gh-4140" )
443
+ @override_settings (DISABLE_SENDING_HIDDEN_FIELDS = True )
444
+ @requests_mock .Mocker ()
445
+ def test_opt_out_of_sending_hidden_fields (self , m ):
446
+ submission = SubmissionFactory .from_components (
447
+ components_list = [
448
+ {
449
+ "type" : "radio" ,
450
+ "key" : "radio" ,
451
+ "label" : "Radio" ,
452
+ "values" : [
453
+ {"label" : "1" , "value" : "1" },
454
+ {"label" : "2" , "value" : "2" },
455
+ ],
456
+ "defaultValue" : None ,
457
+ "validate" : {"required" : True },
458
+ "openForms" : {"dataSrc" : "manual" },
459
+ },
460
+ {
461
+ "type" : "textfield" ,
462
+ "key" : "tekstveld" ,
463
+ "label" : "Tekstveld" ,
464
+ "hidden" : True ,
465
+ "validate" : {"required" : True },
466
+ "conditional" : {"eq" : "1" , "show" : True , "when" : "radio" },
467
+ "defaultValue" : None ,
468
+ "clearOnHide" : True ,
469
+ },
470
+ {
471
+ "type" : "currency" ,
472
+ "currency" : "EUR" ,
473
+ "key" : "bedrag" ,
474
+ "label" : "Bedrag" ,
475
+ "hidden" : True ,
476
+ "validate" : {"required" : True },
477
+ "conditional" : {"eq" : "1" , "show" : True , "when" : "radio" },
478
+ "defaultValue" : None ,
479
+ "clearOnHide" : True ,
480
+ },
481
+ {
482
+ "type" : "fieldset" ,
483
+ "key" : "fieldsetNoVisibleChildren" ,
484
+ "label" : "A container without visible children" ,
485
+ "hidden" : True ,
486
+ "components" : [
487
+ {
488
+ "type" : "textfield" ,
489
+ "key" : "input7" ,
490
+ "label" : "Input 7" ,
491
+ "hidden" : True ,
492
+ }
493
+ ],
494
+ },
495
+ ],
496
+ with_report = True ,
497
+ submitted_data = {"radio" : "2" },
498
+ form_definition_kwargs = {"slug" : "stepwithnulls" },
499
+ )
500
+ config = ObjectsAPIGroupConfigFactory .create (
501
+ objecttypes_service__api_root = "https://objecttypen.nl/api/v1/" ,
502
+ )
503
+ plugin = ObjectsAPIRegistration (PLUGIN_IDENTIFIER )
504
+
505
+ m .get (
506
+ "https://objecttypen.nl/api/v1/objecttypes/f3f1b370-97ed-4730-bc7e-ebb20c230377" ,
507
+ json = {
508
+ "url" : "https://objecttypen.nl/api/v1/objecttypes/f3f1b370-97ed-4730-bc7e-ebb20c230377"
509
+ },
510
+ status_code = 200 ,
511
+ )
512
+
513
+ with (
514
+ patch (
515
+ "openforms.registrations.contrib.objects_api.plugin.get_objects_client"
516
+ ) as mock_objects_client ,
517
+ ):
518
+ _objects_client = mock_objects_client .return_value .__enter__ .return_value
519
+ _objects_client .create_object .return_value = {"dummy" : "response" }
520
+
521
+ plugin .register_submission (
522
+ submission ,
523
+ {
524
+ "objects_api_group" : config ,
525
+ "version" : 1 ,
526
+ "objecttype" : UUID ("f3f1b370-97ed-4730-bc7e-ebb20c230377" ),
527
+ "objecttype_version" : 300 ,
528
+ # skip document uploads
529
+ "informatieobjecttype_submission_report" : "" ,
530
+ "upload_submission_csv" : False ,
531
+ "update_existing_object" : False ,
532
+ "informatieobjecttype_attachment" : "" ,
533
+ "content_json" : "{% json_summary %}" ,
534
+ },
535
+ )
536
+
537
+ _objects_client .create_object .mock_assert_called_once ()
538
+ record_data = _objects_client .create_object .call_args [1 ]["record_data" ]["data" ]
539
+ # for missing values, the empty value (depending on component type) must be used
540
+ # Note that the input data was validated against the hidden/visible and
541
+ # clearOnHide state - absence of the data implies that the component was not
542
+ # visible and its data was cleared (otherwise the value *would* have been sent
543
+ # along and be present).
544
+ self .assertEqual (
545
+ record_data ,
546
+ {
547
+ "stepwithnulls" : {"radio" : "2" },
548
+ },
549
+ )
0 commit comments