feed-common 1.49.2 → 1.49.3

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