@truedat/bg 7.12.6 → 7.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -141,7 +141,7 @@ describe("selectors: getParsedEvents", () => {
141
141
  payload: {
142
142
  content: {
143
143
  removed: {},
144
- changed: { changed_field_1: "value_1", changed_field_2: "value_2" },
144
+ changed: { changed_field_1: { origin: "origin", value: "value_1" }, changed_field_2: { origin: "origin", value: "value_2" } },
145
145
  added: {},
146
146
  },
147
147
  },
@@ -210,7 +210,7 @@ describe("selectors: getParsedEvents", () => {
210
210
  id: 9,
211
211
  event: "update_concept_draft",
212
212
  resource_id: 10,
213
- payload: { content: { changed: { field_1: { id: 1, name: "foo" } } } },
213
+ payload: { content: { changed: { field_1: { origin: "origin", value: { id: 1, name: "foo" } } } } },
214
214
  },
215
215
  {
216
216
  id: 10,
@@ -274,4 +274,894 @@ describe("selectors: getParsedEvents", () => {
274
274
  expect(res).toHaveLength(0);
275
275
  expect(res).toEqual(expect.arrayContaining([]));
276
276
  });
277
+
278
+ describe("event_via propagation", () => {
279
+ it("should include msg_via in relation_created events", () => {
280
+ const events = [
281
+ {
282
+ id: 1,
283
+ event: "relation_created",
284
+ resource_id: 100,
285
+ payload: {
286
+ event_via: "single_update",
287
+ target_id: 123,
288
+ target_type: "data_structure",
289
+ target_name: "Test Structure",
290
+ },
291
+ },
292
+ ];
293
+
294
+ const res = getParsedEvents({ events, concept });
295
+
296
+ expect(res).toHaveLength(1);
297
+ expect(res[0].payload).toEqual([
298
+ {
299
+ msg_key: "relation_created_data_structure",
300
+ msg_params: ["Test Structure"],
301
+ msg_via: "single_update",
302
+ },
303
+ ]);
304
+ });
305
+
306
+ it("should include msg_via in relation_deleted events", () => {
307
+ const events = [
308
+ {
309
+ id: 1,
310
+ event: "relation_deleted",
311
+ resource_id: 100,
312
+ payload: {
313
+ event_via: "bulk_upload",
314
+ target_id: 456,
315
+ target_type: "business_concept",
316
+ target_name: "Test Concept",
317
+ },
318
+ },
319
+ ];
320
+
321
+ const res = getParsedEvents({ events, concept });
322
+
323
+ expect(res).toHaveLength(1);
324
+ expect(res[0].payload).toEqual([
325
+ {
326
+ msg_key: "relation_deleted_business_concept",
327
+ msg_params: ["Test Concept"],
328
+ msg_via: "bulk_upload",
329
+ },
330
+ ]);
331
+ });
332
+
333
+ it("should include msg_via in relation_deprecated events", () => {
334
+ const events = [
335
+ {
336
+ id: 1,
337
+ event: "relation_deprecated",
338
+ resource_id: 100,
339
+ payload: {
340
+ event_via: "single_update",
341
+ target_id: 789,
342
+ target_type: "implementation",
343
+ },
344
+ },
345
+ ];
346
+
347
+ const res = getParsedEvents({ events, concept });
348
+
349
+ expect(res).toHaveLength(1);
350
+ expect(res[0].payload).toEqual([
351
+ {
352
+ msg_key: "relation_deprecated_implementation",
353
+ msg_params: [789],
354
+ msg_via: "single_update",
355
+ },
356
+ ]);
357
+ });
358
+
359
+ it("should include msg_via in concept_published events", () => {
360
+ const events = [
361
+ {
362
+ id: 1,
363
+ event: "concept_published",
364
+ resource_id: 100,
365
+ payload: {
366
+ event_via: "single_update",
367
+ },
368
+ },
369
+ ];
370
+
371
+ const res = getParsedEvents({ events, concept });
372
+
373
+ expect(res).toHaveLength(1);
374
+ expect(res[0].payload).toEqual([{ msg_via: "single_update" }]);
375
+ });
376
+
377
+ it("should include msg_via in concept_deprecated events", () => {
378
+ const events = [
379
+ {
380
+ id: 1,
381
+ event: "concept_deprecated",
382
+ resource_id: 100,
383
+ payload: {
384
+ event_via: "bulk_upload",
385
+ },
386
+ },
387
+ ];
388
+
389
+ const res = getParsedEvents({ events, concept });
390
+
391
+ expect(res).toHaveLength(1);
392
+ expect(res[0].payload).toEqual([{ msg_via: "bulk_upload" }]);
393
+ });
394
+
395
+ it("should include msg_via in concept_submitted events", () => {
396
+ const events = [
397
+ {
398
+ id: 1,
399
+ event: "concept_submitted",
400
+ resource_id: 100,
401
+ payload: {
402
+ event_via: "single_update",
403
+ },
404
+ },
405
+ ];
406
+
407
+ const res = getParsedEvents({ events, concept });
408
+
409
+ expect(res).toHaveLength(1);
410
+ expect(res[0].payload).toEqual([{ msg_via: "single_update" }]);
411
+ });
412
+
413
+ it("should include msg_via in create_concept_draft events", () => {
414
+ const events = [
415
+ {
416
+ id: 1,
417
+ event: "create_concept_draft",
418
+ resource_id: 100,
419
+ payload: {
420
+ version: 3,
421
+ event_via: "single_update",
422
+ },
423
+ },
424
+ ];
425
+
426
+ const res = getParsedEvents({ events, concept });
427
+
428
+ expect(res).toHaveLength(1);
429
+ expect(res[0].payload).toEqual([
430
+ {
431
+ msg_key: "created_version",
432
+ msg_params: [3],
433
+ msg_via: "single_update",
434
+ },
435
+ ]);
436
+ });
437
+
438
+ it("should include msg_via in delete_concept_draft events", () => {
439
+ const events = [
440
+ {
441
+ id: 1,
442
+ event: "delete_concept_draft",
443
+ resource_id: 100,
444
+ payload: {
445
+ version: 2,
446
+ event_via: "bulk_upload",
447
+ },
448
+ },
449
+ ];
450
+
451
+ const res = getParsedEvents({ events, concept });
452
+
453
+ expect(res).toHaveLength(1);
454
+ expect(res[0].payload).toEqual([
455
+ {
456
+ msg_key: "deleted_version",
457
+ msg_params: [2],
458
+ msg_via: "bulk_upload",
459
+ },
460
+ ]);
461
+ });
462
+
463
+ it("should handle undefined event_via", () => {
464
+ const events = [
465
+ {
466
+ id: 1,
467
+ event: "concept_published",
468
+ resource_id: 100,
469
+ payload: {},
470
+ },
471
+ ];
472
+
473
+ const res = getParsedEvents({ events, concept });
474
+
475
+ expect(res).toHaveLength(1);
476
+ expect(res[0].payload).toEqual([{ msg_via: undefined }]);
477
+ });
478
+
479
+ it("should use target_name when available, fallback to target_id", () => {
480
+ const eventsWithName = [
481
+ {
482
+ id: 1,
483
+ event: "relation_created",
484
+ resource_id: 100,
485
+ payload: {
486
+ event_via: "single_update",
487
+ target_id: 123,
488
+ target_type: "data_structure",
489
+ target_name: "My Structure",
490
+ },
491
+ },
492
+ ];
493
+
494
+ const eventsWithoutName = [
495
+ {
496
+ id: 2,
497
+ event: "relation_created",
498
+ resource_id: 101,
499
+ payload: {
500
+ event_via: "single_update",
501
+ target_id: 456,
502
+ target_type: "data_structure",
503
+ },
504
+ },
505
+ ];
506
+
507
+ const resWithName = getParsedEvents({ events: eventsWithName, concept });
508
+ const resWithoutName = getParsedEvents({
509
+ events: eventsWithoutName,
510
+ concept,
511
+ });
512
+
513
+ expect(resWithName[0].payload[0].msg_params).toEqual(["My Structure"]);
514
+ expect(resWithoutName[0].payload[0].msg_params).toEqual([456]);
515
+ });
516
+ });
517
+
518
+ describe("field value display for different data types", () => {
519
+ const conceptWithMixedFields = {
520
+ template: {
521
+ content: [
522
+ {
523
+ fields: [
524
+ { type: "string", name: "Checkbox String", label: "Checkbox String" },
525
+ { type: "string", name: "Date", label: "Date" },
526
+ { type: "string", name: "Date Time", label: "Date Time" },
527
+ { type: "domain", name: "Dropdown Domain", label: "Dropdown Domain" },
528
+ { type: "string", name: "Dropdown Key Value", label: "Dropdown Key Value" },
529
+ { type: "string", name: "Dropdown String", label: "Dropdown String" },
530
+ { type: "system", name: "Dropdown System", label: "Dropdown System" },
531
+ { type: "enriched_text", name: "Enrichedtext", label: "Enrichedtext" },
532
+ { type: "string", name: "Extra", label: "Extra" },
533
+ { type: "hierarchy", name: "Hierarchy", label: "Hierarchy" },
534
+ { type: "hierarchy", name: "Hierarchy multiple", label: "Hierarchy multiple" },
535
+ { type: "url", name: "Links", label: "Links" },
536
+ { type: "integer", name: "Number", label: "Number" },
537
+ { type: "string", name: "Radio String", label: "Radio String" },
538
+ { type: "table", name: "Table", label: "Table" },
539
+ { type: "list", name: "Text Input", label: "Text Input" },
540
+ { type: "string", name: "Textarea", label: "Textarea" },
541
+ { type: "image", name: "Image", label: "Image" },
542
+ ],
543
+ },
544
+ ],
545
+ },
546
+ };
547
+
548
+ it("should show values for array fields (checkbox, dropdown, text input)", () => {
549
+ const events = [
550
+ {
551
+ id: 1,
552
+ event: "update_concept_draft",
553
+ resource_id: 443,
554
+ payload: {
555
+ event_via: "single_update",
556
+ content: {
557
+ changed: {
558
+ "Checkbox String": {
559
+ origin: "user",
560
+ value: ["foo", "bar"],
561
+ },
562
+ "Dropdown Domain": {
563
+ origin: "user",
564
+ value: [123, 456],
565
+ },
566
+ "Dropdown String": {
567
+ origin: "user",
568
+ value: ["option_a", "option_b"],
569
+ },
570
+ "Text Input": {
571
+ origin: "user",
572
+ value: ["lorem", "ipsum"],
573
+ },
574
+ "Hierarchy multiple": {
575
+ origin: "user",
576
+ value: ["1_1", "1_2"],
577
+ },
578
+ },
579
+ },
580
+ },
581
+ },
582
+ ];
583
+
584
+ const res = getParsedEvents({ events, concept: conceptWithMixedFields });
585
+
586
+ expect(res).toHaveLength(1);
587
+ expect(res[0].payload).toContainEqual({
588
+ msg_key: "changed_field",
589
+ msg_params: ["Checkbox String", JSON.stringify(["foo", "bar"])],
590
+ msg_via: "single_update",
591
+ });
592
+ expect(res[0].payload).toContainEqual({
593
+ msg_key: "changed_field",
594
+ msg_params: ["Dropdown Domain", JSON.stringify([123, 456])],
595
+ msg_via: "single_update",
596
+ });
597
+ expect(res[0].payload).toContainEqual({
598
+ msg_key: "changed_field",
599
+ msg_params: ["Dropdown String", JSON.stringify(["option_a", "option_b"])],
600
+ msg_via: "single_update",
601
+ });
602
+ expect(res[0].payload).toContainEqual({
603
+ msg_key: "changed_field",
604
+ msg_params: ["Text Input", JSON.stringify(["lorem", "ipsum"])],
605
+ msg_via: "single_update",
606
+ });
607
+ expect(res[0].payload).toContainEqual({
608
+ msg_key: "changed_field",
609
+ msg_params: ["Hierarchy multiple", JSON.stringify(["1_1", "1_2"])],
610
+ msg_via: "single_update",
611
+ });
612
+ });
613
+
614
+ it("should show values for simple scalar fields", () => {
615
+ const events = [
616
+ {
617
+ id: 1,
618
+ event: "update_concept_draft",
619
+ resource_id: 443,
620
+ payload: {
621
+ event_via: "single_update",
622
+ content: {
623
+ changed: {
624
+ Date: {
625
+ origin: "user",
626
+ value: "2024-01-15",
627
+ },
628
+ "Date Time": {
629
+ origin: "user",
630
+ value: "2024-01-15T10:30",
631
+ },
632
+ "Dropdown Key Value": {
633
+ origin: "user",
634
+ value: "key_001",
635
+ },
636
+ Extra: {
637
+ origin: "user",
638
+ value: "lorem ipsum",
639
+ },
640
+ Hierarchy: {
641
+ origin: "user",
642
+ value: "1_2",
643
+ },
644
+ Number: {
645
+ origin: "user",
646
+ value: 123,
647
+ },
648
+ "Radio String": {
649
+ origin: "user",
650
+ value: "option_a",
651
+ },
652
+ Textarea: {
653
+ origin: "user",
654
+ value: "dolor sit amet",
655
+ },
656
+ },
657
+ },
658
+ },
659
+ },
660
+ ];
661
+
662
+ const res = getParsedEvents({ events, concept: conceptWithMixedFields });
663
+
664
+ expect(res).toHaveLength(1);
665
+ expect(res[0].payload).toContainEqual({
666
+ msg_key: "changed_field",
667
+ msg_params: ["Date", "2024-01-15"],
668
+ msg_via: "single_update",
669
+ });
670
+ expect(res[0].payload).toContainEqual({
671
+ msg_key: "changed_field",
672
+ msg_params: ["Date Time", "2024-01-15T10:30"],
673
+ msg_via: "single_update",
674
+ });
675
+ expect(res[0].payload).toContainEqual({
676
+ msg_key: "changed_field",
677
+ msg_params: ["Dropdown Key Value", "key_001"],
678
+ msg_via: "single_update",
679
+ });
680
+ expect(res[0].payload).toContainEqual({
681
+ msg_key: "changed_field",
682
+ msg_params: ["Extra", "lorem ipsum"],
683
+ msg_via: "single_update",
684
+ });
685
+ expect(res[0].payload).toContainEqual({
686
+ msg_key: "changed_field",
687
+ msg_params: ["Hierarchy", "1_2"],
688
+ msg_via: "single_update",
689
+ });
690
+ expect(res[0].payload).toContainEqual({
691
+ msg_key: "changed_field",
692
+ msg_params: ["Number", 123],
693
+ msg_via: "single_update",
694
+ });
695
+ expect(res[0].payload).toContainEqual({
696
+ msg_key: "changed_field",
697
+ msg_params: ["Radio String", "option_a"],
698
+ msg_via: "single_update",
699
+ });
700
+ expect(res[0].payload).toContainEqual({
701
+ msg_key: "changed_field",
702
+ msg_params: ["Textarea", "dolor sit amet"],
703
+ msg_via: "single_update",
704
+ });
705
+ });
706
+
707
+ it("should NOT show values for complex field types (enriched_text, url, table, system, image)", () => {
708
+ const events = [
709
+ {
710
+ id: 1,
711
+ event: "update_concept_draft",
712
+ resource_id: 443,
713
+ payload: {
714
+ event_via: "single_update",
715
+ content: {
716
+ changed: {
717
+ "Dropdown System": {
718
+ origin: "user",
719
+ value: {
720
+ external_id: "system_foo",
721
+ id: 123,
722
+ name: "System Bar",
723
+ },
724
+ },
725
+ Enrichedtext: {
726
+ origin: "user",
727
+ value: {
728
+ document: {
729
+ data: {},
730
+ nodes: [
731
+ {
732
+ data: {},
733
+ nodes: [
734
+ {
735
+ marks: [],
736
+ object: "text",
737
+ text: "Lorem ipsum dolor sit amet",
738
+ },
739
+ ],
740
+ object: "block",
741
+ type: "paragraph",
742
+ },
743
+ ],
744
+ object: "document",
745
+ },
746
+ object: "value",
747
+ },
748
+ },
749
+ Links: {
750
+ origin: "user",
751
+ value: [
752
+ {
753
+ url_name: "Example Link",
754
+ url_value: "https://example.com",
755
+ },
756
+ ],
757
+ },
758
+ Table: {
759
+ origin: "user",
760
+ value: [
761
+ {
762
+ "Col A": "foo",
763
+ "Col B": "bar",
764
+ },
765
+ ],
766
+ },
767
+ Image: {
768
+ origin: "user",
769
+ value: {
770
+ url: "https://example.com/image.png",
771
+ },
772
+ },
773
+ },
774
+ },
775
+ },
776
+ },
777
+ ];
778
+
779
+ const res = getParsedEvents({ events, concept: conceptWithMixedFields });
780
+
781
+ expect(res).toHaveLength(1);
782
+ expect(res[0].payload).toContainEqual({
783
+ msg_key: "changed_field_without_target",
784
+ msg_params: [
785
+ "Dropdown System",
786
+ JSON.stringify({
787
+ external_id: "system_foo",
788
+ id: 123,
789
+ name: "System Bar",
790
+ }),
791
+ ],
792
+ msg_via: "single_update",
793
+ });
794
+ expect(res[0].payload).toContainEqual({
795
+ msg_key: "changed_field_without_target",
796
+ msg_params: [
797
+ "Enrichedtext",
798
+ expect.stringContaining("Lorem ipsum dolor sit amet"),
799
+ ],
800
+ msg_via: "single_update",
801
+ });
802
+ expect(res[0].payload).toContainEqual({
803
+ msg_key: "changed_field_without_target",
804
+ msg_params: [
805
+ "Links",
806
+ JSON.stringify([
807
+ {
808
+ url_name: "Example Link",
809
+ url_value: "https://example.com",
810
+ },
811
+ ]),
812
+ ],
813
+ msg_via: "single_update",
814
+ });
815
+ expect(res[0].payload).toContainEqual({
816
+ msg_key: "changed_field_without_target",
817
+ msg_params: [
818
+ "Table",
819
+ JSON.stringify([
820
+ {
821
+ "Col A": "foo",
822
+ "Col B": "bar",
823
+ },
824
+ ]),
825
+ ],
826
+ msg_via: "single_update",
827
+ });
828
+ expect(res[0].payload).toContainEqual({
829
+ msg_key: "changed_field_without_target",
830
+ msg_params: [
831
+ "Image",
832
+ JSON.stringify({
833
+ url: "https://example.com/image.png",
834
+ }),
835
+ ],
836
+ msg_via: "single_update",
837
+ });
838
+ });
839
+
840
+ it("should NOT show values for null or undefined fields", () => {
841
+ const events = [
842
+ {
843
+ id: 1,
844
+ event: "update_concept_draft",
845
+ resource_id: 443,
846
+ payload: {
847
+ event_via: "single_update",
848
+ content: {
849
+ changed: {
850
+ "Text Input": {
851
+ origin: "user",
852
+ value: null,
853
+ },
854
+ Extra: {
855
+ origin: "user",
856
+ value: undefined,
857
+ },
858
+ },
859
+ },
860
+ },
861
+ },
862
+ ];
863
+
864
+ const res = getParsedEvents({ events, concept: conceptWithMixedFields });
865
+
866
+ expect(res).toHaveLength(1);
867
+ expect(res[0].payload).toContainEqual({
868
+ msg_key: "changed_field_without_target",
869
+ msg_params: ["Text Input", null],
870
+ msg_via: "single_update",
871
+ });
872
+ expect(res[0].payload).toContainEqual({
873
+ msg_key: "changed_field_without_target",
874
+ msg_params: ["Extra", undefined],
875
+ msg_via: "single_update",
876
+ });
877
+ });
878
+ });
879
+
880
+ describe("update_concept specific fields", () => {
881
+ it("should handle confidential field in update_concept", () => {
882
+ const events = [
883
+ {
884
+ id: 1,
885
+ event: "update_concept",
886
+ resource_id: 100,
887
+ payload: {
888
+ confidential: true,
889
+ event_via: "single_update",
890
+ content: {},
891
+ },
892
+ },
893
+ ];
894
+
895
+ const res = getParsedEvents({ events, concept });
896
+
897
+ expect(res).toHaveLength(1);
898
+ expect(res[0].payload).toContainEqual({
899
+ msg_key: "confidential_true",
900
+ msg_via: "single_update",
901
+ });
902
+ });
903
+
904
+ it("should handle confidential false in update_concept", () => {
905
+ const events = [
906
+ {
907
+ id: 1,
908
+ event: "update_concept",
909
+ resource_id: 100,
910
+ payload: {
911
+ confidential: false,
912
+ event_via: "single_update",
913
+ content: {},
914
+ },
915
+ },
916
+ ];
917
+
918
+ const res = getParsedEvents({ events, concept });
919
+
920
+ expect(res).toHaveLength(1);
921
+ expect(res[0].payload).toContainEqual({
922
+ msg_key: "confidential_false",
923
+ msg_via: "single_update",
924
+ });
925
+ });
926
+
927
+ it("should NOT handle confidential field in update_concept_draft", () => {
928
+ const events = [
929
+ {
930
+ id: 1,
931
+ event: "update_concept_draft",
932
+ resource_id: 100,
933
+ payload: {
934
+ confidential: true,
935
+ event_via: "single_update",
936
+ content: {},
937
+ },
938
+ },
939
+ ];
940
+
941
+ const res = getParsedEvents({ events, concept });
942
+
943
+ expect(res).toHaveLength(1);
944
+ expect(res[0].payload).not.toContainEqual(
945
+ expect.objectContaining({
946
+ msg_key: "confidential_true",
947
+ })
948
+ );
949
+ });
950
+ });
951
+
952
+ describe("update_concept_draft specific fields", () => {
953
+ it("should handle name field in update_concept_draft", () => {
954
+ const events = [
955
+ {
956
+ id: 1,
957
+ event: "update_concept_draft",
958
+ resource_id: 100,
959
+ payload: {
960
+ name: "New Concept Name",
961
+ event_via: "single_update",
962
+ content: {},
963
+ },
964
+ },
965
+ ];
966
+
967
+ const res = getParsedEvents({ events, concept });
968
+
969
+ expect(res).toHaveLength(1);
970
+ expect(res[0].payload).toContainEqual({
971
+ msg_key: "changed_field",
972
+ msg_params: ["name", "New Concept Name"],
973
+ msg_via: "single_update",
974
+ });
975
+ });
976
+
977
+ it("should NOT handle name field in update_concept", () => {
978
+ const events = [
979
+ {
980
+ id: 1,
981
+ event: "update_concept",
982
+ resource_id: 100,
983
+ payload: {
984
+ name: "New Concept Name",
985
+ event_via: "single_update",
986
+ content: {},
987
+ },
988
+ },
989
+ ];
990
+
991
+ const res = getParsedEvents({ events, concept });
992
+
993
+ expect(res).toHaveLength(1);
994
+ expect(res[0].payload).not.toContainEqual(
995
+ expect.objectContaining({
996
+ msg_key: "changed_field",
997
+ msg_params: expect.arrayContaining(["name", "New Concept Name"]),
998
+ })
999
+ );
1000
+ });
1001
+
1002
+ it("should handle description field in update_concept_draft", () => {
1003
+ const events = [
1004
+ {
1005
+ id: 1,
1006
+ event: "update_concept_draft",
1007
+ resource_id: 100,
1008
+ payload: {
1009
+ description: "New description",
1010
+ event_via: "single_update",
1011
+ content: {},
1012
+ },
1013
+ },
1014
+ ];
1015
+
1016
+ const res = getParsedEvents({ events, concept });
1017
+
1018
+ expect(res).toHaveLength(1);
1019
+ expect(res[0].payload).toContainEqual({
1020
+ msg_key: "changed_field_without_target",
1021
+ msg_params: ["description"],
1022
+ msg_via: "single_update",
1023
+ });
1024
+ });
1025
+
1026
+ it("should NOT handle description field in update_concept", () => {
1027
+ const events = [
1028
+ {
1029
+ id: 1,
1030
+ event: "update_concept",
1031
+ resource_id: 100,
1032
+ payload: {
1033
+ description: "New description",
1034
+ event_via: "single_update",
1035
+ content: {},
1036
+ },
1037
+ },
1038
+ ];
1039
+
1040
+ const res = getParsedEvents({ events, concept });
1041
+
1042
+ expect(res).toHaveLength(1);
1043
+ expect(res[0].payload).not.toContainEqual(
1044
+ expect.objectContaining({
1045
+ msg_key: "changed_field_without_target",
1046
+ msg_params: ["description"],
1047
+ })
1048
+ );
1049
+ });
1050
+
1051
+ it("should return empty payload when update_concept_draft has no content", () => {
1052
+ const events = [
1053
+ {
1054
+ id: 1,
1055
+ event: "update_concept_draft",
1056
+ resource_id: 100,
1057
+ payload: {
1058
+ name: "Test",
1059
+ event_via: "single_update",
1060
+ },
1061
+ },
1062
+ ];
1063
+
1064
+ const res = getParsedEvents({ events, concept });
1065
+
1066
+ expect(res).toHaveLength(1);
1067
+ expect(res[0].payload).toEqual([]);
1068
+ });
1069
+ });
1070
+
1071
+ describe("combined fields processing", () => {
1072
+ it("should process all update_concept fields together", () => {
1073
+ const events = [
1074
+ {
1075
+ id: 1,
1076
+ event: "update_concept",
1077
+ resource_id: 100,
1078
+ payload: {
1079
+ confidential: true,
1080
+ shared_to: [{ id: 1, name: "Domain A" }],
1081
+ domain_id: 42,
1082
+ event_via: "bulk_upload",
1083
+ content: {
1084
+ changed: {
1085
+ field_1: { origin: "origin", value: "new_value" },
1086
+ },
1087
+ },
1088
+ },
1089
+ },
1090
+ ];
1091
+
1092
+ const res = getParsedEvents({ events, concept });
1093
+
1094
+ expect(res).toHaveLength(1);
1095
+ expect(res[0].payload).toContainEqual({
1096
+ msg_key: "confidential_true",
1097
+ msg_via: "bulk_upload",
1098
+ });
1099
+ expect(res[0].payload).toContainEqual({
1100
+ msg_key: "shared_to",
1101
+ msg_params: ["Domain A"],
1102
+ msg_via: "bulk_upload",
1103
+ });
1104
+ expect(res[0].payload).toContainEqual({
1105
+ msg_key: "domain_updated_with_id",
1106
+ msg_params: [42],
1107
+ msg_via: "bulk_upload",
1108
+ });
1109
+ expect(res[0].payload).toContainEqual({
1110
+ msg_key: "changed_field_without_target",
1111
+ msg_params: ["Label", "new_value"],
1112
+ msg_via: "bulk_upload",
1113
+ });
1114
+ });
1115
+
1116
+ it("should process all update_concept_draft fields together", () => {
1117
+ const events = [
1118
+ {
1119
+ id: 1,
1120
+ event: "update_concept_draft",
1121
+ resource_id: 100,
1122
+ payload: {
1123
+ name: "Updated Name",
1124
+ description: "Updated description",
1125
+ shared_to: [{ id: 1, name: "Domain B" }],
1126
+ domain_id: 43,
1127
+ event_via: "single_update",
1128
+ content: {
1129
+ added: {
1130
+ field_1: { origin: "origin", value: "added_value" },
1131
+ },
1132
+ },
1133
+ },
1134
+ },
1135
+ ];
1136
+
1137
+ const res = getParsedEvents({ events, concept });
1138
+
1139
+ expect(res).toHaveLength(1);
1140
+ expect(res[0].payload).toContainEqual({
1141
+ msg_key: "shared_to",
1142
+ msg_params: ["Domain B"],
1143
+ msg_via: "single_update",
1144
+ });
1145
+ expect(res[0].payload).toContainEqual({
1146
+ msg_key: "changed_field_without_target",
1147
+ msg_params: ["description"],
1148
+ msg_via: "single_update",
1149
+ });
1150
+ expect(res[0].payload).toContainEqual({
1151
+ msg_key: "changed_field",
1152
+ msg_params: ["name", "Updated Name"],
1153
+ msg_via: "single_update",
1154
+ });
1155
+ expect(res[0].payload).toContainEqual({
1156
+ msg_key: "domain_updated_with_id",
1157
+ msg_params: [43],
1158
+ msg_via: "single_update",
1159
+ });
1160
+ expect(res[0].payload).toContainEqual({
1161
+ msg_key: "added_field_without_target",
1162
+ msg_params: ["Label", "added_value"],
1163
+ msg_via: "single_update",
1164
+ });
1165
+ });
1166
+ });
277
1167
  });