feed-common 1.50.3 → 1.50.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ import {
6
6
  checkRuleDuplication,
7
7
  compareMappings,
8
8
  compareRules,
9
+ detectProfileChange,
9
10
  getOperatorCounterpart,
10
11
  hasRules,
11
12
  sanitizeUploadProfile,
@@ -693,742 +694,792 @@ describe('Compare mappings', () => {
693
694
  });
694
695
  });
695
696
 
696
- // describe('Detect profile change', () => {
697
- // test('No changes', () => {
698
- // const profileA = {
699
- // id: '1',
700
- // profileIdTemplate: '1',
701
- // name: 'profileA',
702
- // rules: {
703
- // sections: [
704
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
705
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
706
- // ],
707
- // },
708
- // mappings: [
709
- // {
710
- // attribute: 'contentLanguage',
711
- // value: 'en',
712
- // rules: {
713
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
714
- // },
715
- // },
716
- // {
717
- // attribute: 'ageGroup',
718
- // value: 'newborn',
719
- // rules: {
720
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
721
- // },
722
- // },
723
- // ],
724
- // } as ProductUploadProfile;
725
-
726
- // const profileB = {
727
- // id: '1',
728
- // profileIdTemplate: '1',
729
- // name: 'profileA',
730
- // rules: {
731
- // sections: [
732
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
733
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
734
- // ],
735
- // },
736
- // mappings: [
737
- // {
738
- // attribute: 'contentLanguage',
739
- // value: 'en',
740
- // rules: {
741
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
742
- // },
743
- // },
744
- // {
745
- // attribute: 'ageGroup',
746
- // value: 'newborn',
747
- // rules: {
748
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
749
- // },
750
- // },
751
- // ],
752
- // } as ProductUploadProfile;
753
-
754
- // expect(detectProfileChange(profileA, profileB)).toEqual({
755
- // name: false,
756
- // rules: false,
757
- // mappings: false,
758
- // id: false,
759
- // });
760
- // });
697
+ describe('Detect profile change', () => {
698
+ test('No changes', () => {
699
+ const profileA = {
700
+ id: '1',
701
+ name: 'profileA',
702
+ rules: {
703
+ sections: [
704
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
705
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
706
+ ],
707
+ },
708
+ mappings: [
709
+ {
710
+ attribute: 'contentLanguage',
711
+ value: 'en',
712
+ rules: {
713
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
714
+ },
715
+ },
716
+ {
717
+ attribute: 'ageGroup',
718
+ value: 'newborn',
719
+ rules: {
720
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
721
+ },
722
+ },
723
+ ],
724
+ } as ProductUploadProfile;
725
+
726
+ const profileB = {
727
+ id: '1',
728
+ name: 'profileA',
729
+ rules: {
730
+ sections: [
731
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
732
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
733
+ ],
734
+ },
735
+ mappings: [
736
+ {
737
+ attribute: 'contentLanguage',
738
+ value: 'en',
739
+ rules: {
740
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
741
+ },
742
+ },
743
+ {
744
+ attribute: 'ageGroup',
745
+ value: 'newborn',
746
+ rules: {
747
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
748
+ },
749
+ },
750
+ ],
751
+ } as ProductUploadProfile;
752
+
753
+ expect(detectProfileChange(profileA, profileB)).toEqual({
754
+ name: false,
755
+ rules: false,
756
+ mappings: false,
757
+ id: false,
758
+ });
759
+ });
760
+
761
+ test('Name change', () => {
762
+ const profileA = {
763
+ id: '1',
764
+ name: 'profileA',
765
+ rules: {
766
+ sections: [
767
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
768
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
769
+ ],
770
+ },
771
+ mappings: [
772
+ {
773
+ attribute: 'contentLanguage',
774
+ value: 'en',
775
+ rules: {
776
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
777
+ },
778
+ },
779
+ {
780
+ attribute: 'ageGroup',
781
+ value: 'newborn',
782
+ rules: {
783
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
784
+ },
785
+ },
786
+ ],
787
+ } as ProductUploadProfile;
788
+
789
+ const profileB = {
790
+ id: '1',
791
+ name: 'profileB',
792
+ rules: {
793
+ sections: [
794
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
795
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
796
+ ],
797
+ },
798
+ mappings: [
799
+ {
800
+ attribute: 'contentLanguage',
801
+ value: 'en',
802
+ rules: {
803
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
804
+ },
805
+ },
806
+ {
807
+ attribute: 'ageGroup',
808
+ value: 'newborn',
809
+ rules: {
810
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
811
+ },
812
+ },
813
+ ],
814
+ } as ProductUploadProfile;
815
+
816
+ expect(detectProfileChange(profileA, profileB)).toEqual({
817
+ name: true,
818
+ rules: false,
819
+ mappings: false,
820
+ id: false,
821
+ });
822
+ });
823
+
824
+ test('Mappings change #1', () => {
825
+ const profileA = {
826
+ id: '1',
827
+ name: 'profileA',
828
+ rules: {
829
+ sections: [
830
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
831
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
832
+ ],
833
+ },
834
+ mappings: [
835
+ {
836
+ attribute: 'contentLanguage',
837
+ value: 'en',
838
+ rules: {
839
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
840
+ },
841
+ },
842
+ {
843
+ attribute: 'ageGroup',
844
+ value: 'newborn',
845
+ rules: {
846
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
847
+ },
848
+ },
849
+ ],
850
+ } as ProductUploadProfile;
851
+
852
+ const profileB = {
853
+ id: '1',
854
+ name: 'profileA',
855
+ rules: {
856
+ sections: [
857
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
858
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
859
+ ],
860
+ },
861
+ mappings: [
862
+ {
863
+ attribute: 'contentLanguage',
864
+ value: 'en',
865
+ rules: {
866
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
867
+ },
868
+ },
869
+ {
870
+ attribute: 'brand',
871
+ value: 'Voxhall',
872
+ rules: {
873
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
874
+ },
875
+ },
876
+ ],
877
+ } as ProductUploadProfile;
878
+
879
+ expect(detectProfileChange(profileA, profileB)).toEqual({
880
+ name: false,
881
+ rules: false,
882
+ mappings: true,
883
+ id: false,
884
+ });
885
+ });
886
+
887
+ test('Mappings change #2', () => {
888
+ const profileA = {
889
+ id: '1',
890
+ name: 'profileA',
891
+ rules: {
892
+ sections: [
893
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
894
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
895
+ ],
896
+ },
897
+ mappings: [
898
+ {
899
+ attribute: 'contentLanguage',
900
+ value: 'en',
901
+ rules: {
902
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
903
+ },
904
+ },
905
+ {
906
+ attribute: 'ageGroup',
907
+ value: 'newborn',
908
+ rules: {
909
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
910
+ },
911
+ },
912
+ ],
913
+ } as ProductUploadProfile;
914
+
915
+ const profileB = {
916
+ id: '1',
917
+ name: 'profileA',
918
+ rules: {
919
+ sections: [
920
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
921
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
922
+ ],
923
+ },
924
+ mappings: [
925
+ {
926
+ attribute: 'contentLanguage',
927
+ value: 'en',
928
+ rules: {
929
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
930
+ },
931
+ },
932
+ {
933
+ attribute: 'ageGroup',
934
+ value: 'newborn',
935
+ rules: {
936
+ sections: [
937
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
938
+ ],
939
+ },
940
+ },
941
+ ],
942
+ } as ProductUploadProfile;
943
+
944
+ expect(detectProfileChange(profileA, profileB)).toEqual({
945
+ name: false,
946
+ rules: false,
947
+ mappings: true,
948
+ id: false,
949
+ });
950
+ });
951
+
952
+ test('ID section change #1', () => {
953
+ const profileA = {
954
+ id: '1',
955
+ name: 'profileA',
956
+ rules: {
957
+ sections: [
958
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
959
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
960
+ ],
961
+ },
962
+ mappings: [
963
+ {
964
+ attribute: 'contentLanguage',
965
+ value: 'en',
966
+ rules: {
967
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
968
+ },
969
+ },
970
+ {
971
+ attribute: 'ageGroup',
972
+ value: 'newborn',
973
+ rules: {
974
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
975
+ },
976
+ },
977
+ ],
978
+ } as ProductUploadProfile;
979
+
980
+ const profileB = {
981
+ id: '1',
982
+ name: 'profileA',
983
+ rules: {
984
+ sections: [
985
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
986
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
987
+ ],
988
+ },
989
+ mappings: [
990
+ {
991
+ attribute: 'gender',
992
+ value: 'male',
993
+ rules: {
994
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
995
+ },
996
+ },
997
+ {
998
+ attribute: 'ageGroup',
999
+ value: 'newborn',
1000
+ rules: {
1001
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1002
+ },
1003
+ },
1004
+ ],
1005
+ } as ProductUploadProfile;
1006
+
1007
+ expect(detectProfileChange(profileA, profileB)).toEqual({
1008
+ name: false,
1009
+ rules: false,
1010
+ mappings: true,
1011
+ id: true,
1012
+ });
1013
+ });
1014
+
1015
+ test('ID section change #2', () => {
1016
+ const profileA = {
1017
+ id: '1',
1018
+ name: 'profileA',
1019
+ rules: {
1020
+ sections: [
1021
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1022
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1023
+ ],
1024
+ },
1025
+ mappings: [
1026
+ {
1027
+ attribute: 'contentLanguage',
1028
+ value: 'en',
1029
+ rules: {
1030
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1031
+ },
1032
+ },
1033
+ {
1034
+ attribute: 'ageGroup',
1035
+ value: 'newborn',
1036
+ rules: {
1037
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1038
+ },
1039
+ },
1040
+ ],
1041
+ } as ProductUploadProfile;
1042
+
1043
+ const profileB = {
1044
+ id: '1',
1045
+ name: 'profileA',
1046
+ rules: {
1047
+ sections: [
1048
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1049
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1050
+ ],
1051
+ },
1052
+ mappings: [
1053
+ {
1054
+ attribute: 'contentLanguage',
1055
+ value: 'en',
1056
+ rules: {
1057
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
1058
+ },
1059
+ },
1060
+ {
1061
+ attribute: 'ageGroup',
1062
+ value: 'newborn',
1063
+ rules: {
1064
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1065
+ },
1066
+ },
1067
+ ],
1068
+ } as ProductUploadProfile;
1069
+
1070
+ expect(detectProfileChange(profileA, profileB)).toEqual({
1071
+ name: false,
1072
+ rules: false,
1073
+ mappings: false,
1074
+ id: true,
1075
+ });
1076
+ });
1077
+
1078
+ test('Mapping change #1', () => {
1079
+ const profileA = {
1080
+ id: '1',
1081
+ name: 'profileA',
1082
+ rules: {
1083
+ sections: [
1084
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1085
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1086
+ ],
1087
+ },
1088
+ mappings: [
1089
+ {
1090
+ attribute: 'contentLanguage',
1091
+ value: 'en',
1092
+ rules: {
1093
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1094
+ },
1095
+ },
1096
+ {
1097
+ attribute: 'ageGroup',
1098
+ value: 'newborn',
1099
+ rules: {
1100
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1101
+ },
1102
+ },
1103
+ ],
1104
+ } as ProductUploadProfile;
1105
+
1106
+ const profileB = {
1107
+ id: '1',
1108
+ name: 'profileA',
1109
+ rules: {
1110
+ sections: [
1111
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1112
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1113
+ ],
1114
+ },
1115
+ mappings: [
1116
+ {
1117
+ attribute: 'contentLanguage',
1118
+ value: 'en',
1119
+ rules: {
1120
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1121
+ },
1122
+ },
1123
+ {
1124
+ attribute: 'ageGroup',
1125
+ value: 'newborn',
1126
+ rules: {
1127
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1128
+ },
1129
+ },
1130
+ {
1131
+ attribute: 'adult',
1132
+ value: true,
1133
+ rules: {
1134
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1135
+ },
1136
+ },
1137
+ ],
1138
+ } as ProductUploadProfile;
761
1139
 
762
- // test('Name change', () => {
763
- // const profileA = {
764
- // id: '1',
765
- // profileIdTemplate: '1',
766
- // name: 'profileA',
767
- // rules: {
768
- // sections: [
769
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
770
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
771
- // ],
772
- // },
773
- // mappings: [
774
- // {
775
- // attribute: 'contentLanguage',
776
- // value: 'en',
777
- // rules: {
778
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
779
- // },
780
- // },
781
- // {
782
- // attribute: 'ageGroup',
783
- // value: 'newborn',
784
- // rules: {
785
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
786
- // },
787
- // },
788
- // ],
789
- // } as ProductUploadProfile;
790
-
791
- // const profileB = {
792
- // id: '1',
793
- // profileIdTemplate: '1',
794
- // name: 'profileB',
795
- // rules: {
796
- // sections: [
797
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
798
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
799
- // ],
800
- // },
801
- // mappings: [
802
- // {
803
- // attribute: 'contentLanguage',
804
- // value: 'en',
805
- // rules: {
806
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
807
- // },
808
- // },
809
- // {
810
- // attribute: 'ageGroup',
811
- // value: 'newborn',
812
- // rules: {
813
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
814
- // },
815
- // },
816
- // ],
817
- // } as ProductUploadProfile;
818
-
819
- // expect(detectProfileChange(profileA, profileB)).toEqual({
820
- // name: true,
821
- // rules: false,
822
- // mappings: false,
823
- // id: false,
824
- // });
825
- // });
1140
+ expect(detectProfileChange(profileA, profileB)).toEqual({
1141
+ name: false,
1142
+ rules: false,
1143
+ mappings: true,
1144
+ id: false,
1145
+ });
1146
+ });
826
1147
 
827
- // test('Mappings change #1', () => {
828
- // const profileA = {
829
- // id: '1',
830
- // profileIdTemplate: '1',
831
- // name: 'profileA',
832
- // rules: {
833
- // sections: [
834
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
835
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
836
- // ],
837
- // },
838
- // mappings: [
839
- // {
840
- // attribute: 'contentLanguage',
841
- // value: 'en',
842
- // rules: {
843
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
844
- // },
845
- // },
846
- // {
847
- // attribute: 'ageGroup',
848
- // value: 'newborn',
849
- // rules: {
850
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
851
- // },
852
- // },
853
- // ],
854
- // } as ProductUploadProfile;
855
-
856
- // const profileB = {
857
- // id: '1',
858
- // profileIdTemplate: '1',
859
- // name: 'profileA',
860
- // rules: {
861
- // sections: [
862
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
863
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
864
- // ],
865
- // },
866
- // mappings: [
867
- // {
868
- // attribute: 'contentLanguage',
869
- // value: 'en',
870
- // rules: {
871
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
872
- // },
873
- // },
874
- // {
875
- // attribute: 'brand',
876
- // value: 'Voxhall',
877
- // rules: {
878
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
879
- // },
880
- // },
881
- // ],
882
- // } as ProductUploadProfile;
883
-
884
- // expect(detectProfileChange(profileA, profileB)).toEqual({
885
- // name: false,
886
- // rules: false,
887
- // mappings: true,
888
- // id: false,
889
- // });
890
- // });
1148
+ test('Mapping change #2', () => {
1149
+ const profileA = {
1150
+ id: '1',
1151
+ name: 'profileA',
1152
+ rules: {
1153
+ sections: [
1154
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1155
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1156
+ ],
1157
+ },
1158
+ mappings: [
1159
+ {
1160
+ attribute: 'contentLanguage',
1161
+ value: 'en',
1162
+ rules: {
1163
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1164
+ },
1165
+ },
1166
+ {
1167
+ attribute: 'ageGroup',
1168
+ value: 'newborn',
1169
+ rules: {
1170
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1171
+ },
1172
+ },
1173
+ ],
1174
+ } as ProductUploadProfile;
891
1175
 
892
- // test('Mappings change #2', () => {
893
- // const profileA = {
894
- // id: '1',
895
- // profileIdTemplate: '1',
896
- // name: 'profileA',
897
- // rules: {
898
- // sections: [
899
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
900
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
901
- // ],
902
- // },
903
- // mappings: [
904
- // {
905
- // attribute: 'contentLanguage',
906
- // value: 'en',
907
- // rules: {
908
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
909
- // },
910
- // },
911
- // {
912
- // attribute: 'ageGroup',
913
- // value: 'newborn',
914
- // rules: {
915
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
916
- // },
917
- // },
918
- // ],
919
- // } as ProductUploadProfile;
920
-
921
- // const profileB = {
922
- // id: '1',
923
- // profileIdTemplate: '1',
924
- // name: 'profileA',
925
- // rules: {
926
- // sections: [
927
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
928
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
929
- // ],
930
- // },
931
- // mappings: [
932
- // {
933
- // attribute: 'contentLanguage',
934
- // value: 'en',
935
- // rules: {
936
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
937
- // },
938
- // },
939
- // {
940
- // attribute: 'ageGroup',
941
- // value: 'newborn',
942
- // rules: {
943
- // sections: [
944
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
945
- // ],
946
- // },
947
- // },
948
- // ],
949
- // } as ProductUploadProfile;
950
-
951
- // expect(detectProfileChange(profileA, profileB)).toEqual({
952
- // name: false,
953
- // rules: false,
954
- // mappings: true,
955
- // id: false,
956
- // });
957
- // });
1176
+ const profileB = {
1177
+ id: '1',
1178
+ name: 'profileA',
1179
+ rules: {
1180
+ sections: [
1181
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1182
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1183
+ ],
1184
+ },
1185
+ mappings: [
1186
+ {
1187
+ attribute: 'contentLanguage',
1188
+ value: 'en',
1189
+ rules: {
1190
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1191
+ },
1192
+ },
1193
+ {
1194
+ attribute: 'adult',
1195
+ value: true,
1196
+ rules: {
1197
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1198
+ },
1199
+ },
1200
+ ],
1201
+ } as ProductUploadProfile;
958
1202
 
959
- // test('ID section change #1', () => {
960
- // const profileA = {
961
- // id: '1',
962
- // profileIdTemplate: '1',
963
- // name: 'profileA',
964
- // rules: {
965
- // sections: [
966
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
967
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
968
- // ],
969
- // },
970
- // mappings: [
971
- // {
972
- // attribute: 'contentLanguage',
973
- // value: 'en',
974
- // rules: {
975
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
976
- // },
977
- // },
978
- // {
979
- // attribute: 'ageGroup',
980
- // value: 'newborn',
981
- // rules: {
982
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
983
- // },
984
- // },
985
- // ],
986
- // } as ProductUploadProfile;
987
-
988
- // const profileB = {
989
- // id: '1',
990
- // profileIdTemplate: '1',
991
- // name: 'profileA',
992
- // rules: {
993
- // sections: [
994
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
995
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
996
- // ],
997
- // },
998
- // mappings: [
999
- // {
1000
- // attribute: 'gender',
1001
- // value: 'male',
1002
- // rules: {
1003
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1004
- // },
1005
- // },
1006
- // {
1007
- // attribute: 'ageGroup',
1008
- // value: 'newborn',
1009
- // rules: {
1010
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1011
- // },
1012
- // },
1013
- // ],
1014
- // } as ProductUploadProfile;
1015
-
1016
- // expect(detectProfileChange(profileA, profileB)).toEqual({
1017
- // name: false,
1018
- // rules: false,
1019
- // mappings: true,
1020
- // id: true,
1021
- // });
1022
- // });
1203
+ expect(detectProfileChange(profileA, profileB)).toEqual({
1204
+ name: false,
1205
+ rules: false,
1206
+ mappings: true,
1207
+ id: false,
1208
+ });
1209
+ });
1023
1210
 
1024
- // test('ID section change #2', () => {
1025
- // const profileA = {
1026
- // id: '1',
1027
- // profileIdTemplate: '1',
1028
- // name: 'profileA',
1029
- // rules: {
1030
- // sections: [
1031
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1032
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1033
- // ],
1034
- // },
1035
- // mappings: [
1036
- // {
1037
- // attribute: 'contentLanguage',
1038
- // value: 'en',
1039
- // rules: {
1040
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1041
- // },
1042
- // },
1043
- // {
1044
- // attribute: 'ageGroup',
1045
- // value: 'newborn',
1046
- // rules: {
1047
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1048
- // },
1049
- // },
1050
- // ],
1051
- // } as ProductUploadProfile;
1052
-
1053
- // const profileB = {
1054
- // id: '1',
1055
- // profileIdTemplate: '1',
1056
- // name: 'profileA',
1057
- // rules: {
1058
- // sections: [
1059
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1060
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1061
- // ],
1062
- // },
1063
- // mappings: [
1064
- // {
1065
- // attribute: 'contentLanguage',
1066
- // value: 'en',
1067
- // rules: {
1068
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
1069
- // },
1070
- // },
1071
- // {
1072
- // attribute: 'ageGroup',
1073
- // value: 'newborn',
1074
- // rules: {
1075
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1076
- // },
1077
- // },
1078
- // ],
1079
- // } as ProductUploadProfile;
1080
-
1081
- // expect(detectProfileChange(profileA, profileB)).toEqual({
1082
- // name: false,
1083
- // rules: false,
1084
- // mappings: false,
1085
- // id: true,
1086
- // });
1087
- // });
1211
+ test('Mappings change #3', () => {
1212
+ const profileA = {
1213
+ id: '1',
1214
+ name: 'profileA',
1215
+ rules: {
1216
+ sections: [
1217
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1218
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1219
+ ],
1220
+ },
1221
+ mappings: [
1222
+ {
1223
+ attribute: 'contentLanguage',
1224
+ value: 'en',
1225
+ rules: {
1226
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1227
+ },
1228
+ },
1229
+ {
1230
+ attribute: 'ageGroup',
1231
+ value: 'newborn',
1232
+ rules: {
1233
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1234
+ },
1235
+ },
1236
+ ],
1237
+ } as ProductUploadProfile;
1088
1238
 
1089
- // test('Mapping change #1', () => {
1090
- // const profileA = {
1091
- // id: '1',
1092
- // profileIdTemplate: '1',
1093
- // name: 'profileA',
1094
- // rules: {
1095
- // sections: [
1096
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1097
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1098
- // ],
1099
- // },
1100
- // mappings: [
1101
- // {
1102
- // attribute: 'contentLanguage',
1103
- // value: 'en',
1104
- // rules: {
1105
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1106
- // },
1107
- // },
1108
- // {
1109
- // attribute: 'ageGroup',
1110
- // value: 'newborn',
1111
- // rules: {
1112
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1113
- // },
1114
- // },
1115
- // ],
1116
- // } as ProductUploadProfile;
1117
-
1118
- // const profileB = {
1119
- // id: '1',
1120
- // profileIdTemplate: '1',
1121
- // name: 'profileA',
1122
- // rules: {
1123
- // sections: [
1124
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1125
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1126
- // ],
1127
- // },
1128
- // mappings: [
1129
- // {
1130
- // attribute: 'contentLanguage',
1131
- // value: 'en',
1132
- // rules: {
1133
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1134
- // },
1135
- // },
1136
- // {
1137
- // attribute: 'ageGroup',
1138
- // value: 'newborn',
1139
- // rules: {
1140
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1141
- // },
1142
- // },
1143
- // {
1144
- // attribute: 'adult',
1145
- // value: true,
1146
- // rules: {
1147
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1148
- // },
1149
- // },
1150
- // ],
1151
- // } as ProductUploadProfile;
1152
-
1153
- // expect(detectProfileChange(profileA, profileB)).toEqual({
1154
- // name: false,
1155
- // rules: false,
1156
- // mappings: true,
1157
- // id: false,
1158
- // });
1159
- // });
1239
+ const profileB = {
1240
+ id: '1',
1241
+ name: 'profileA',
1242
+ rules: {
1243
+ sections: [
1244
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1245
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1246
+ ],
1247
+ },
1248
+ mappings: [
1249
+ {
1250
+ attribute: 'contentLanguage',
1251
+ value: 'en',
1252
+ rules: {
1253
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1254
+ },
1255
+ },
1256
+ {
1257
+ attribute: 'ageGroup',
1258
+ value: 'newborn',
1259
+ rules: {
1260
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: 'title1' }] }],
1261
+ },
1262
+ },
1263
+ ],
1264
+ } as ProductUploadProfile;
1160
1265
 
1161
- // test('Mapping change #2', () => {
1162
- // const profileA = {
1163
- // id: '1',
1164
- // profileIdTemplate: '1',
1165
- // name: 'profileA',
1166
- // rules: {
1167
- // sections: [
1168
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1169
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1170
- // ],
1171
- // },
1172
- // mappings: [
1173
- // {
1174
- // attribute: 'contentLanguage',
1175
- // value: 'en',
1176
- // rules: {
1177
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1178
- // },
1179
- // },
1180
- // {
1181
- // attribute: 'ageGroup',
1182
- // value: 'newborn',
1183
- // rules: {
1184
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1185
- // },
1186
- // },
1187
- // ],
1188
- // } as ProductUploadProfile;
1189
-
1190
- // const profileB = {
1191
- // id: '1',
1192
- // profileIdTemplate: '1',
1193
- // name: 'profileA',
1194
- // rules: {
1195
- // sections: [
1196
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1197
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1198
- // ],
1199
- // },
1200
- // mappings: [
1201
- // {
1202
- // attribute: 'contentLanguage',
1203
- // value: 'en',
1204
- // rules: {
1205
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1206
- // },
1207
- // },
1208
- // {
1209
- // attribute: 'adult',
1210
- // value: true,
1211
- // rules: {
1212
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1213
- // },
1214
- // },
1215
- // ],
1216
- // } as ProductUploadProfile;
1217
-
1218
- // expect(detectProfileChange(profileA, profileB)).toEqual({
1219
- // name: false,
1220
- // rules: false,
1221
- // mappings: true,
1222
- // id: false,
1223
- // });
1224
- // });
1266
+ expect(detectProfileChange(profileA, profileB)).toEqual({
1267
+ name: false,
1268
+ rules: false,
1269
+ mappings: true,
1270
+ id: false,
1271
+ });
1272
+ });
1225
1273
 
1226
- // test('Mappings change #3', () => {
1227
- // const profileA = {
1228
- // id: '1',
1229
- // profileIdTemplate: '1',
1230
- // name: 'profileA',
1231
- // rules: {
1232
- // sections: [
1233
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1234
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1235
- // ],
1236
- // },
1237
- // mappings: [
1238
- // {
1239
- // attribute: 'contentLanguage',
1240
- // value: 'en',
1241
- // rules: {
1242
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1243
- // },
1244
- // },
1245
- // {
1246
- // attribute: 'ageGroup',
1247
- // value: 'newborn',
1248
- // rules: {
1249
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1250
- // },
1251
- // },
1252
- // ],
1253
- // } as ProductUploadProfile;
1254
-
1255
- // const profileB = {
1256
- // id: '1',
1257
- // profileIdTemplate: '1',
1258
- // name: 'profileA',
1259
- // rules: {
1260
- // sections: [
1261
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1262
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1263
- // ],
1264
- // },
1265
- // mappings: [
1266
- // {
1267
- // attribute: 'contentLanguage',
1268
- // value: 'en',
1269
- // rules: {
1270
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1271
- // },
1272
- // },
1273
- // {
1274
- // attribute: 'ageGroup',
1275
- // value: 'newborn',
1276
- // rules: {
1277
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: 'title1' }] }],
1278
- // },
1279
- // },
1280
- // ],
1281
- // } as ProductUploadProfile;
1282
-
1283
- // expect(detectProfileChange(profileA, profileB)).toEqual({
1284
- // name: false,
1285
- // rules: false,
1286
- // mappings: true,
1287
- // id: false,
1288
- // });
1289
- // });
1274
+ test('Mappings change #4', () => {
1275
+ const profileA = {
1276
+ id: '1',
1277
+ name: 'profileA',
1278
+ rules: {
1279
+ sections: [
1280
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1281
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1282
+ ],
1283
+ },
1284
+ mappings: [
1285
+ {
1286
+ attribute: 'contentLanguage',
1287
+ value: 'en',
1288
+ rules: {
1289
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1290
+ },
1291
+ },
1292
+ {
1293
+ attribute: 'ageGroup',
1294
+ value: 'newborn',
1295
+ rules: {
1296
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1297
+ },
1298
+ },
1299
+ ],
1300
+ } as ProductUploadProfile;
1290
1301
 
1291
- // test('Rules change', () => {
1292
- // const profileA = {
1293
- // id: '1',
1294
- // profileIdTemplate: '1',
1295
- // name: 'profileA',
1296
- // rules: {
1297
- // sections: [
1298
- // { id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1299
- // { id: '1', ruleItems: [{ id: '1', attribute: 'price', operator: 'less', value: 100 }] },
1300
- // ],
1301
- // },
1302
- // mappings: [
1303
- // {
1304
- // id: '1',
1305
- // attribute: 'contentLanguage',
1306
- // value: 'en',
1307
- // rules: {
1308
- // sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
1309
- // },
1310
- // },
1311
- // {
1312
- // id: '1',
1313
- // attribute: 'ageGroup',
1314
- // value: 'newborn',
1315
- // rules: {
1316
- // sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
1317
- // },
1318
- // },
1319
- // ],
1320
- // defaultValue: '',
1321
- // type: XMLFeedType.Google,
1322
- // format: XmlFeedFormat.XML,
1323
- // active: true,
1324
- // } as ProductUploadProfile;
1325
-
1326
- // const profileB = {
1327
- // id: '1',
1328
- // name: 'profileA',
1329
- // rules: {
1330
- // sections: [
1331
- // { id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1332
- // { id: '1', ruleItems: [{ id: '1', attribute: 'price', operator: 'less', value: 101 }] },
1333
- // ],
1334
- // },
1335
- // mappings: [
1336
- // {
1337
- // id: '1',
1338
- // attribute: 'contentLanguage',
1339
- // value: 'en',
1340
- // rules: {
1341
- // sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
1342
- // },
1343
- // },
1344
- // {
1345
- // id: '2',
1346
- // attribute: 'ageGroup',
1347
- // value: 'newborn',
1348
- // rules: {
1349
- // sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
1350
- // },
1351
- // },
1352
- // ],
1353
- // defaultValue: '',
1354
- // type: XMLFeedType.Google,
1355
- // format: XmlFeedFormat.XML,
1356
- // active: true,
1357
- // } as ProductUploadProfile;
1358
-
1359
- // expect(detectProfileChange(profileA, profileB)).toEqual({
1360
- // name: false,
1361
- // rules: true,
1362
- // mappings: false,
1363
- // id: false,
1364
- // });
1365
- // });
1302
+ const profileB = {
1303
+ id: '1',
1304
+ name: 'profileA',
1305
+ rules: {
1306
+ sections: [
1307
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1308
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1309
+ ],
1310
+ },
1311
+ mappings: [
1312
+ {
1313
+ attribute: 'contentLanguage',
1314
+ value: 'en',
1315
+ rules: {
1316
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1317
+ },
1318
+ },
1319
+ {
1320
+ attribute: 'ageGroup',
1321
+ value: 'newborn',
1322
+ rules: {
1323
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1324
+ },
1325
+ },
1326
+ {
1327
+ attribute: 'targetCountry',
1328
+ value: 'US',
1329
+ rules: {
1330
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1331
+ },
1332
+ },
1333
+ ],
1334
+ } as ProductUploadProfile;
1366
1335
 
1367
- // test('All changed', () => {
1368
- // const profileA = {
1369
- // id: '1',
1370
- // profileIdTemplate: '1',
1371
- // name: 'profileA',
1372
- // rules: {
1373
- // sections: [
1374
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1375
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1376
- // ],
1377
- // },
1378
- // mappings: [
1379
- // {
1380
- // attribute: 'contentLanguage',
1381
- // value: 'en',
1382
- // rules: {
1383
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1384
- // },
1385
- // },
1386
- // {
1387
- // attribute: 'ageGroup',
1388
- // value: 'newborn',
1389
- // rules: {
1390
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1391
- // },
1392
- // },
1393
- // ],
1394
- // } as ProductUploadProfile;
1395
-
1396
- // const profileB = {
1397
- // id: '1',
1398
- // profileIdTemplate: '1',
1399
- // name: 'profileB',
1400
- // rules: {
1401
- // sections: [
1402
- // { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1403
- // { ruleItems: [{ attribute: 'price', operator: 'less', value: 101 }] },
1404
- // ],
1405
- // },
1406
- // mappings: [
1407
- // {
1408
- // attribute: 'contentLanguage',
1409
- // value: 'en',
1410
- // rules: {
1411
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
1412
- // },
1413
- // },
1414
- // {
1415
- // attribute: 'ageGroup',
1416
- // value: 'newborn',
1417
- // rules: {
1418
- // sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
1419
- // },
1420
- // },
1421
- // ],
1422
- // } as ProductUploadProfile;
1423
-
1424
- // expect(detectProfileChange(profileA, profileB)).toEqual({
1425
- // name: true,
1426
- // rules: true,
1427
- // mappings: true,
1428
- // id: true,
1429
- // });
1430
- // });
1431
- // });
1336
+ expect(detectProfileChange(profileA, profileB)).toEqual({
1337
+ name: false,
1338
+ rules: false,
1339
+ mappings: false,
1340
+ id: true,
1341
+ });
1342
+ });
1343
+
1344
+ test('Rules change', () => {
1345
+ const profileA = {
1346
+ id: '1',
1347
+ profileIdTemplate: '1',
1348
+ name: 'profileA',
1349
+ rules: {
1350
+ sections: [
1351
+ { id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1352
+ { id: '1', ruleItems: [{ id: '1', attribute: 'price', operator: 'less', value: 100 }] },
1353
+ ],
1354
+ },
1355
+ mappings: [
1356
+ {
1357
+ id: '1',
1358
+ attribute: 'contentLanguage',
1359
+ value: 'en',
1360
+ rules: {
1361
+ sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
1362
+ },
1363
+ },
1364
+ {
1365
+ id: '1',
1366
+ attribute: 'ageGroup',
1367
+ value: 'newborn',
1368
+ rules: {
1369
+ sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
1370
+ },
1371
+ },
1372
+ ],
1373
+ defaultValue: '',
1374
+ type: XMLFeedType.Google,
1375
+ format: XmlFeedFormat.XML,
1376
+ active: true,
1377
+ } as ProductUploadProfile;
1378
+
1379
+ const profileB = {
1380
+ id: '1',
1381
+ name: 'profileA',
1382
+ rules: {
1383
+ sections: [
1384
+ { id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1385
+ { id: '1', ruleItems: [{ id: '1', attribute: 'price', operator: 'less', value: 101 }] },
1386
+ ],
1387
+ },
1388
+ mappings: [
1389
+ {
1390
+ id: '1',
1391
+ attribute: 'contentLanguage',
1392
+ value: 'en',
1393
+ rules: {
1394
+ sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
1395
+ },
1396
+ },
1397
+ {
1398
+ id: '2',
1399
+ attribute: 'ageGroup',
1400
+ value: 'newborn',
1401
+ rules: {
1402
+ sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
1403
+ },
1404
+ },
1405
+ ],
1406
+ defaultValue: '',
1407
+ type: XMLFeedType.Google,
1408
+ format: XmlFeedFormat.XML,
1409
+ active: true,
1410
+ } as ProductUploadProfile;
1411
+
1412
+ expect(detectProfileChange(profileA, profileB)).toEqual({
1413
+ name: false,
1414
+ rules: true,
1415
+ mappings: false,
1416
+ id: false,
1417
+ });
1418
+ });
1419
+
1420
+ test('All changed', () => {
1421
+ const profileA = {
1422
+ id: '1',
1423
+ name: 'profileA',
1424
+ rules: {
1425
+ sections: [
1426
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1427
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
1428
+ ],
1429
+ },
1430
+ mappings: [
1431
+ {
1432
+ attribute: 'contentLanguage',
1433
+ value: 'en',
1434
+ rules: {
1435
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1436
+ },
1437
+ },
1438
+ {
1439
+ attribute: 'ageGroup',
1440
+ value: 'newborn',
1441
+ rules: {
1442
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
1443
+ },
1444
+ },
1445
+ ],
1446
+ } as ProductUploadProfile;
1447
+
1448
+ const profileB = {
1449
+ id: '1',
1450
+ name: 'profileB',
1451
+ rules: {
1452
+ sections: [
1453
+ { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
1454
+ { ruleItems: [{ attribute: 'price', operator: 'less', value: 101 }] },
1455
+ ],
1456
+ },
1457
+ mappings: [
1458
+ {
1459
+ attribute: 'contentLanguage',
1460
+ value: 'en',
1461
+ rules: {
1462
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
1463
+ },
1464
+ },
1465
+ {
1466
+ attribute: 'ageGroup',
1467
+ value: 'newborn',
1468
+ rules: {
1469
+ sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
1470
+ },
1471
+ },
1472
+ ],
1473
+ } as ProductUploadProfile;
1474
+
1475
+ expect(detectProfileChange(profileA, profileB)).toEqual({
1476
+ name: true,
1477
+ rules: true,
1478
+ mappings: true,
1479
+ id: true,
1480
+ });
1481
+ });
1482
+ });
1432
1483
 
1433
1484
  describe('Sanitize upload profile', () => {
1434
1485
  test('Test #1', () => {