@blaze-cms/react-page-builder 0.132.0 → 0.133.0-admin-updates.0

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.
Files changed (195) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/lib/components/Banner/BannerRender.js +2 -2
  3. package/lib/components/Banner/BannerRender.js.map +1 -1
  4. package/lib/components/Banner/helpers.js +2 -2
  5. package/lib/components/Banner/helpers.js.map +1 -1
  6. package/lib/components/BlazeLink.js +2 -2
  7. package/lib/components/BlazeLink.js.map +1 -1
  8. package/lib/components/Button.js +2 -2
  9. package/lib/components/Button.js.map +1 -1
  10. package/lib/components/Card/CardsContainer.js +2 -2
  11. package/lib/components/Card/CardsContainer.js.map +1 -1
  12. package/lib/components/Card/CardsRender.js +2 -2
  13. package/lib/components/Card/CardsRender.js.map +1 -1
  14. package/lib/components/Card/helpers/filter-query-setup.js +11 -5
  15. package/lib/components/Card/helpers/filter-query-setup.js.map +1 -1
  16. package/lib/components/ClickWrapper.js +2 -2
  17. package/lib/components/ClickWrapper.js.map +1 -1
  18. package/lib/components/Code/Code.js +2 -2
  19. package/lib/components/Code/Code.js.map +1 -1
  20. package/lib/components/DataSummary/helpers/build-loop-props-content.js +3 -2
  21. package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
  22. package/lib/components/DataSummary/helpers/get-link-to-published-content.js +2 -0
  23. package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  24. package/lib/components/Image/Image.js +2 -2
  25. package/lib/components/Image/Image.js.map +1 -1
  26. package/lib/components/Layout/Layout.js +2 -2
  27. package/lib/components/Layout/Layout.js.map +1 -1
  28. package/lib/components/List/ListBuilder.js +46 -26
  29. package/lib/components/List/ListBuilder.js.map +1 -1
  30. package/lib/components/List/ListFactory.js +5 -5
  31. package/lib/components/List/ListFactory.js.map +1 -1
  32. package/lib/components/List/components/Cards/CardsRender.js +2 -2
  33. package/lib/components/List/components/Cards/CardsRender.js.map +1 -1
  34. package/lib/components/List/components/Full/FullRender.js +2 -2
  35. package/lib/components/List/components/Full/FullRender.js.map +1 -1
  36. package/lib/components/List/components/Full/FullRenderItem.js +2 -2
  37. package/lib/components/List/components/Full/FullRenderItem.js.map +1 -1
  38. package/lib/components/List/components/Pagination/ListPagination.js +2 -2
  39. package/lib/components/List/components/Pagination/ListPagination.js.map +1 -1
  40. package/lib/components/List/helpers/build-az-url.js +2 -2
  41. package/lib/components/List/helpers/build-az-url.js.map +1 -1
  42. package/lib/components/List/helpers/build-pagination-url.js +2 -2
  43. package/lib/components/List/helpers/build-pagination-url.js.map +1 -1
  44. package/lib/components/List/helpers/get-list-query.js +6 -2
  45. package/lib/components/List/helpers/get-list-query.js.map +1 -1
  46. package/lib/components/List/helpers/get-sort-props.js +5 -1
  47. package/lib/components/List/helpers/get-sort-props.js.map +1 -1
  48. package/lib/components/SearchFilter/components/Range.js +2 -2
  49. package/lib/components/SearchFilter/components/Range.js.map +1 -1
  50. package/lib/components/SearchFilter/searchFilterReducer.js +2 -2
  51. package/lib/components/SearchFilterSort/helpers/update-sort.js +2 -2
  52. package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
  53. package/lib/components/TextBlock/index.js +2 -2
  54. package/lib/components/TextBlock/index.js.map +1 -1
  55. package/lib/components/Video/Video.js +2 -2
  56. package/lib/components/Video/Video.js.map +1 -1
  57. package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js +2 -2
  58. package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js.map +1 -1
  59. package/lib/constants/index.js +4 -34
  60. package/lib/constants/index.js.map +1 -1
  61. package/lib/helpers/append-images.js +2 -2
  62. package/lib/helpers/build-az-filter.js +8 -7
  63. package/lib/helpers/build-az-filter.js.map +1 -1
  64. package/lib/helpers/build-raw-query-base.js +2 -2
  65. package/lib/helpers/build-raw-query-base.js.map +1 -1
  66. package/lib/helpers/build-raw-query.js +29 -8
  67. package/lib/helpers/build-raw-query.js.map +1 -1
  68. package/lib/helpers/build-sort-values.js +49 -0
  69. package/lib/helpers/build-sort-values.js.map +1 -0
  70. package/lib/helpers/get-banner-data.js +2 -2
  71. package/lib/helpers/get-click-wrapper-options.js +2 -2
  72. package/lib/helpers/get-click-wrapper-options.js.map +1 -1
  73. package/lib/helpers/get-entities-with-banner.js +2 -2
  74. package/lib/helpers/get-entities-with-banner.js.map +1 -1
  75. package/lib/helpers/get-extra-az-bits.js +46 -3
  76. package/lib/helpers/get-extra-az-bits.js.map +1 -1
  77. package/lib/helpers/get-generic-props.js +2 -2
  78. package/lib/helpers/get-generic-props.js.map +1 -1
  79. package/lib/helpers/get-generic-render-variables.js +30 -37
  80. package/lib/helpers/get-generic-render-variables.js.map +1 -1
  81. package/lib/helpers/inject-multiple-banners/get-banners-for-nodes/get-banners-for-nodes.js +2 -2
  82. package/lib/helpers/inject-multiple-banners/get-banners-for-nodes/get-banners-for-nodes.js.map +1 -1
  83. package/lib/helpers/process-data-summary-value.js +2 -2
  84. package/lib/helpers/process-data-summary-value.js.map +1 -1
  85. package/lib/helpers/remove-unwanted-characters.js +2 -2
  86. package/lib/helpers/render-children.js +2 -2
  87. package/lib/helpers/render-children.js.map +1 -1
  88. package/lib/helpers/split-children.js +2 -2
  89. package/lib/helpers/update-childrens-parent.js +2 -2
  90. package/lib/hooks/helpers/append-gtm-classname.js +2 -2
  91. package/lib/hooks/helpers/append-gtm-classname.js.map +1 -1
  92. package/lib/hooks/helpers/buildPBComponents.js +2 -2
  93. package/lib/hooks/helpers/buildPBComponents.js.map +1 -1
  94. package/lib/hooks/helpers/get-lightbox-images.js +2 -2
  95. package/lib/hooks/helpers/get-lightbox-images.js.map +1 -1
  96. package/lib/hooks/helpers/inject-element-banners.js +2 -2
  97. package/lib/hooks/helpers/inject-element-banners.js.map +1 -1
  98. package/lib/hooks/helpers/inject-textblock-banners.js +2 -2
  99. package/lib/hooks/helpers/inject-textblock-banners.js.map +1 -1
  100. package/lib/utils/get-class-modifiers.js +2 -2
  101. package/lib/utils/get-class-modifiers.js.map +1 -1
  102. package/lib-es/components/Banner/BannerRender.js +2 -2
  103. package/lib-es/components/Banner/helpers.js +2 -2
  104. package/lib-es/components/BlazeLink.js +2 -2
  105. package/lib-es/components/Button.js +2 -2
  106. package/lib-es/components/Card/CardsContainer.js +2 -2
  107. package/lib-es/components/Card/CardsRender.js +2 -2
  108. package/lib-es/components/Card/helpers/filter-query-setup.js +11 -5
  109. package/lib-es/components/Card/helpers/filter-query-setup.js.map +1 -1
  110. package/lib-es/components/ClickWrapper.js +2 -2
  111. package/lib-es/components/Code/Code.js +2 -2
  112. package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +3 -2
  113. package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
  114. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +2 -1
  115. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  116. package/lib-es/components/Image/Image.js +2 -2
  117. package/lib-es/components/Layout/Layout.js +2 -2
  118. package/lib-es/components/List/ListBuilder.js +46 -26
  119. package/lib-es/components/List/ListBuilder.js.map +1 -1
  120. package/lib-es/components/List/ListFactory.js +5 -5
  121. package/lib-es/components/List/ListFactory.js.map +1 -1
  122. package/lib-es/components/List/components/Cards/CardsRender.js +2 -2
  123. package/lib-es/components/List/components/Full/FullRender.js +2 -2
  124. package/lib-es/components/List/components/Full/FullRenderItem.js +2 -2
  125. package/lib-es/components/List/components/Pagination/ListPagination.js +2 -2
  126. package/lib-es/components/List/helpers/build-az-url.js +2 -2
  127. package/lib-es/components/List/helpers/build-pagination-url.js +2 -2
  128. package/lib-es/components/List/helpers/get-list-query.js +5 -2
  129. package/lib-es/components/List/helpers/get-list-query.js.map +1 -1
  130. package/lib-es/components/List/helpers/get-sort-props.js +5 -1
  131. package/lib-es/components/List/helpers/get-sort-props.js.map +1 -1
  132. package/lib-es/components/SearchFilter/components/Range.js +2 -2
  133. package/lib-es/components/SearchFilter/searchFilterReducer.js +2 -2
  134. package/lib-es/components/SearchFilterSort/helpers/update-sort.js +2 -2
  135. package/lib-es/components/TextBlock/index.js +2 -2
  136. package/lib-es/components/Video/Video.js +2 -2
  137. package/lib-es/components/Video/providers/JWPlayer/JWPlayerProvider.js +2 -2
  138. package/lib-es/constants/index.js +2 -31
  139. package/lib-es/constants/index.js.map +1 -1
  140. package/lib-es/helpers/append-images.js +2 -2
  141. package/lib-es/helpers/build-az-filter.js +3 -2
  142. package/lib-es/helpers/build-az-filter.js.map +1 -1
  143. package/lib-es/helpers/build-raw-query-base.js +2 -2
  144. package/lib-es/helpers/build-raw-query.js +26 -8
  145. package/lib-es/helpers/build-raw-query.js.map +1 -1
  146. package/lib-es/helpers/build-sort-values.js +34 -0
  147. package/lib-es/helpers/build-sort-values.js.map +1 -0
  148. package/lib-es/helpers/get-banner-data.js +2 -2
  149. package/lib-es/helpers/get-click-wrapper-options.js +2 -2
  150. package/lib-es/helpers/get-entities-with-banner.js +2 -2
  151. package/lib-es/helpers/get-extra-az-bits.js +48 -2
  152. package/lib-es/helpers/get-extra-az-bits.js.map +1 -1
  153. package/lib-es/helpers/get-generic-props.js +2 -2
  154. package/lib-es/helpers/get-generic-render-variables.js +24 -28
  155. package/lib-es/helpers/get-generic-render-variables.js.map +1 -1
  156. package/lib-es/helpers/inject-multiple-banners/get-banners-for-nodes/get-banners-for-nodes.js +2 -2
  157. package/lib-es/helpers/process-data-summary-value.js +2 -2
  158. package/lib-es/helpers/remove-unwanted-characters.js +2 -2
  159. package/lib-es/helpers/render-children.js +2 -2
  160. package/lib-es/helpers/split-children.js +2 -2
  161. package/lib-es/helpers/update-childrens-parent.js +2 -2
  162. package/lib-es/hooks/helpers/append-gtm-classname.js +2 -2
  163. package/lib-es/hooks/helpers/buildPBComponents.js +2 -2
  164. package/lib-es/hooks/helpers/get-lightbox-images.js +2 -2
  165. package/lib-es/hooks/helpers/inject-element-banners.js +2 -2
  166. package/lib-es/hooks/helpers/inject-textblock-banners.js +2 -2
  167. package/lib-es/utils/get-class-modifiers.js +2 -2
  168. package/package.json +10 -10
  169. package/src/components/Card/helpers/filter-query-setup.js +4 -5
  170. package/src/components/DataSummary/helpers/build-loop-props-content.js +3 -2
  171. package/src/components/DataSummary/helpers/get-link-to-published-content.js +4 -1
  172. package/src/components/List/ListBuilder.js +46 -55
  173. package/src/components/List/ListFactory.js +9 -7
  174. package/src/components/List/helpers/get-list-query.js +5 -2
  175. package/src/components/List/helpers/get-sort-props.js +9 -1
  176. package/src/constants/index.js +2 -32
  177. package/src/helpers/build-az-filter.js +3 -2
  178. package/src/helpers/build-raw-query.js +9 -7
  179. package/src/helpers/build-sort-values.js +32 -0
  180. package/src/helpers/get-extra-az-bits.js +40 -2
  181. package/src/helpers/get-generic-render-variables.js +20 -27
  182. package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +41 -0
  183. package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +21 -0
  184. package/tests/unit/src/components/List/helpers/get-list-query.test.js +55 -0
  185. package/tests/unit/src/components/List/helpers/get-sort-props.test.js +18 -0
  186. package/tests/unit/src/components/PlaceholderIcon/__snapshots__/index.test.js.snap +72 -0
  187. package/tests/unit/src/components/PlaceholderIcon/index.test.js +20 -0
  188. package/tests/unit/src/constants/__snapshots__/index.test.js.snap +3 -0
  189. package/tests/unit/src/constants/index.test.js +7 -0
  190. package/tests/unit/src/helpers/__snapshots__/get-extra-az-bits.test.js.snap +137 -0
  191. package/tests/unit/src/helpers/build-az-query.test.js +4 -3
  192. package/tests/unit/src/helpers/build-raw-query.test.js +82 -58
  193. package/tests/unit/src/helpers/build-sort-values.test.js +34 -0
  194. package/tests/unit/src/helpers/get-extra-az-bits.test.js +36 -6
  195. package/tests/unit/src/helpers/get-generic-render-variables.test.js +50 -53
@@ -43,17 +43,17 @@ describe('build raw query', () => {
43
43
  id,
44
44
  itemsToDisplay
45
45
  } = MOCKED_ARGS;
46
- const rawQuery = buildRawQuery(
46
+ const rawQuery = buildRawQuery({
47
47
  docType,
48
48
  operator,
49
- {
49
+ searchValues: {
50
50
  searchValuesText,
51
51
  searchValuesCheckboxSelectRange,
52
52
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
53
53
  },
54
54
  filterData,
55
55
  id
56
- );
56
+ });
57
57
 
58
58
  it('should always return an object', () => {
59
59
  expect(typeof rawQuery).toBe('object');
@@ -64,65 +64,65 @@ describe('build raw query', () => {
64
64
  });
65
65
 
66
66
  it('should return an object with only checkbox & select search values', () => {
67
- const rawQueryCheckboxSelect = buildRawQuery(
67
+ const rawQueryCheckboxSelect = buildRawQuery({
68
68
  docType,
69
69
  operator,
70
- {
70
+ searchValues: {
71
71
  searchValuesText: SEARCH_VALUES_TEXT_EMPTY,
72
72
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
73
73
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
74
74
  },
75
75
  filterData,
76
76
  id
77
- );
77
+ });
78
78
 
79
79
  expect(rawQueryCheckboxSelect).toEqual(RAW_QUERY_CHECKBOX_SELECT);
80
80
  });
81
81
 
82
82
  it('should return an object with only checkbox & select search values when checkbox has OR operator', () => {
83
- const rawQueryCheckboxSelect = buildRawQuery(
83
+ const rawQueryCheckboxSelect = buildRawQuery({
84
84
  docType,
85
85
  operator,
86
- {
86
+ searchValues: {
87
87
  searchValuesText: SEARCH_VALUES_TEXT_EMPTY,
88
88
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
89
89
  searchValuesCheckboxOr
90
90
  },
91
91
  filterData,
92
92
  id
93
- );
93
+ });
94
94
 
95
95
  expect(rawQueryCheckboxSelect).toEqual(RAW_QUERY_CHECKBOX_SELECT_CHECKBOX_HAS_OR_OPERATOR);
96
96
  });
97
97
 
98
98
  it('should return an object with all search values (checkbox, select, text) - and same operator', () => {
99
- const rawQueryCheckboxSelectTextSameOp = buildRawQuery(
99
+ const rawQueryCheckboxSelectTextSameOp = buildRawQuery({
100
100
  docType,
101
- AND_OPERATOR,
102
- {
101
+ operator: AND_OPERATOR,
102
+ searchValues: {
103
103
  searchValuesText: SEARCH_VALUES_TEXT,
104
104
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
105
105
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
106
106
  },
107
107
  filterData,
108
108
  id
109
- );
109
+ });
110
110
 
111
111
  expect(rawQueryCheckboxSelectTextSameOp).toEqual(RAW_QUERY_ALL_SEARCH_VALUE_SAME_OPERATOR);
112
112
  });
113
113
 
114
114
  it('should return an object with all search values (checkbox, select, text) - and different operator', () => {
115
- const rawQueryCheckboxSelectTextDifferentOp = buildRawQuery(
115
+ const rawQueryCheckboxSelectTextDifferentOp = buildRawQuery({
116
116
  docType,
117
117
  operator,
118
- {
118
+ searchValues: {
119
119
  searchValuesText: SEARCH_VALUES_TEXT,
120
120
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
121
121
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
122
122
  },
123
123
  filterData,
124
124
  id
125
- );
125
+ });
126
126
 
127
127
  expect(rawQueryCheckboxSelectTextDifferentOp).toEqual(
128
128
  RAW_QUERY_ALL_SEARCH_VALUE_DIFFERENT_OPERATOR
@@ -130,17 +130,17 @@ describe('build raw query', () => {
130
130
  });
131
131
 
132
132
  it('should return an object with all search values (checkbox, select, text) - same operator for text and checkbox with OR operator', () => {
133
- const rawQueryCheckboxSelectTextSameOp = buildRawQuery(
133
+ const rawQueryCheckboxSelectTextSameOp = buildRawQuery({
134
134
  docType,
135
- AND_OPERATOR,
136
- {
135
+ operator: AND_OPERATOR,
136
+ searchValues: {
137
137
  searchValuesText: SEARCH_VALUES_TEXT,
138
138
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
139
139
  searchValuesCheckboxOr
140
140
  },
141
141
  filterData,
142
142
  id
143
- );
143
+ });
144
144
 
145
145
  expect(rawQueryCheckboxSelectTextSameOp).toEqual(
146
146
  RAW_QUERY_ALL_SEARCH_VALUE_SAME_OPERATOR_TEXT_CHECKBOX_HAS_OR_OPERATOR
@@ -148,17 +148,17 @@ describe('build raw query', () => {
148
148
  });
149
149
 
150
150
  it('should return an object with all search values (checkbox, select, text) - and different operator for text and checkbox with OR operator', () => {
151
- const rawQueryCheckboxSelectTextDifferentOp = buildRawQuery(
151
+ const rawQueryCheckboxSelectTextDifferentOp = buildRawQuery({
152
152
  docType,
153
153
  operator,
154
- {
154
+ searchValues: {
155
155
  searchValuesText: SEARCH_VALUES_TEXT,
156
156
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
157
157
  searchValuesCheckboxOr
158
158
  },
159
159
  filterData,
160
160
  id
161
- );
161
+ });
162
162
 
163
163
  expect(rawQueryCheckboxSelectTextDifferentOp).toEqual(
164
164
  RAW_QUERY_ALL_SEARCH_VALUE_DIFFERENT_OPERATOR_TEXT_CHECKBOX_HAS_OR_OPERATOR
@@ -166,15 +166,15 @@ describe('build raw query', () => {
166
166
  });
167
167
 
168
168
  it('should return an object with featured & sponsored filter set on list', () => {
169
- const rawQueryMoreCheckboxFilters = buildRawQuery(
169
+ const rawQueryMoreCheckboxFilters = buildRawQuery({
170
170
  docType,
171
171
  operator,
172
- {
172
+ searchValues: {
173
173
  searchValuesText,
174
174
  searchValuesCheckboxSelectRange,
175
175
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
176
176
  },
177
- {
177
+ filterData: {
178
178
  filterValues: { checkboxFilters: ['featured', 'sponsored'], listFilterValues: {} },
179
179
  filterOperator: AND,
180
180
  relations: [],
@@ -182,42 +182,42 @@ describe('build raw query', () => {
182
182
  azFilter: 'x'
183
183
  },
184
184
  id
185
- );
185
+ });
186
186
 
187
187
  expect(rawQueryMoreCheckboxFilters).toEqual(RAW_QUERY_CHECKBOX_FILTERS);
188
188
  });
189
189
 
190
190
  it('should return an object with just one checkbox filter set on list', () => {
191
- const rawQueryOneCheckboxFilter = buildRawQuery(
191
+ const rawQueryOneCheckboxFilter = buildRawQuery({
192
192
  docType,
193
193
  operator,
194
- {
194
+ searchValues: {
195
195
  searchValuesText,
196
196
  searchValuesCheckboxSelectRange,
197
197
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
198
198
  },
199
- {
199
+ filterData: {
200
200
  filterValues: { checkboxFilters: ['sponsored'], listFilterValues: {} },
201
201
  filterOperator: AND,
202
202
  relations: [],
203
203
  stringProps: []
204
204
  },
205
205
  id
206
- );
206
+ });
207
207
 
208
208
  expect(rawQueryOneCheckboxFilter).toEqual(RAW_QUERY_ONE_CHECKBOX_FILTERS);
209
209
  });
210
210
 
211
211
  it('should return an object with just one checkbox filter set on list & other filter values', () => {
212
- const rawQueryOneCheckboxFilterMoreValues = buildRawQuery(
212
+ const rawQueryOneCheckboxFilterMoreValues = buildRawQuery({
213
213
  docType,
214
214
  operator,
215
- {
215
+ searchValues: {
216
216
  searchValuesText,
217
217
  searchValuesCheckboxSelectRange,
218
218
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
219
219
  },
220
- {
220
+ filterData: {
221
221
  filterValues: {
222
222
  checkboxFilters: ['sponsored'],
223
223
  listFilterValues: {
@@ -230,7 +230,7 @@ describe('build raw query', () => {
230
230
  stringProps: ['name', 'category.name']
231
231
  },
232
232
  id
233
- );
233
+ });
234
234
 
235
235
  expect(rawQueryOneCheckboxFilterMoreValues).toEqual(
236
236
  RAW_QUERY_ONE_CHECKBOX_FILTERS_AND_OTHER_FILTERS
@@ -238,15 +238,15 @@ describe('build raw query', () => {
238
238
  });
239
239
 
240
240
  it('should return an object with just one checkbox filter set on list & other filter values plus itemsToDIsplayIds', () => {
241
- const rawQueryOneCheckboxFilterMoreItemsToDisplayValues = buildRawQuery(
241
+ const rawQueryOneCheckboxFilterMoreItemsToDisplayValues = buildRawQuery({
242
242
  docType,
243
243
  operator,
244
- {
244
+ searchValues: {
245
245
  searchValuesText,
246
246
  searchValuesCheckboxSelectRange,
247
247
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
248
248
  },
249
- {
249
+ filterData: {
250
250
  filterValues: {
251
251
  checkboxFilters: ['sponsored'],
252
252
  listFilterValues: {
@@ -261,21 +261,21 @@ describe('build raw query', () => {
261
261
  },
262
262
  id,
263
263
  itemsToDisplay
264
- );
264
+ });
265
265
 
266
266
  expect(rawQueryOneCheckboxFilterMoreItemsToDisplayValues).toEqual(RAW_QUERY_ITEMS_TO_DISPLAY);
267
267
  });
268
268
 
269
269
  it('should return an object with just one checkbox filter set on list & other filter values when the filter operator is OR', () => {
270
- const rawQueryOneCheckboxFilterMoreValues = buildRawQuery(
270
+ const rawQueryOneCheckboxFilterMoreValues = buildRawQuery({
271
271
  docType,
272
272
  operator,
273
- {
273
+ searchValues: {
274
274
  searchValuesText,
275
275
  searchValuesCheckboxSelectRange,
276
276
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
277
277
  },
278
- {
278
+ filterData: {
279
279
  filterValues: {
280
280
  checkboxFilters: ['featured'],
281
281
  listFilterValues: { 'authors.firstname': ['John', 'Paul'], price: ['33'] }
@@ -285,7 +285,7 @@ describe('build raw query', () => {
285
285
  stringProps: ['author.firstname']
286
286
  },
287
287
  id
288
- );
288
+ });
289
289
 
290
290
  expect(rawQueryOneCheckboxFilterMoreValues).toEqual(
291
291
  RAW_QUERY_ONE_CHECKBOX_FILTERS_AND_OTHER_FILTERS_OR_OPERATOR
@@ -293,15 +293,15 @@ describe('build raw query', () => {
293
293
  });
294
294
 
295
295
  it('should return an object with just one checkbox filter set on list & other filter values when the filter operator is OR plus itemsToDIsplayIds', () => {
296
- const rawQueryOneCheckboxFilterMoreItemsToDisplayValues = buildRawQuery(
296
+ const rawQueryOneCheckboxFilterMoreItemsToDisplayValues = buildRawQuery({
297
297
  docType,
298
298
  operator,
299
- {
299
+ searchValues: {
300
300
  searchValuesText,
301
301
  searchValuesCheckboxSelectRange,
302
302
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
303
303
  },
304
- {
304
+ filterData: {
305
305
  filterValues: {
306
306
  checkboxFilters: ['sponsored'],
307
307
  listFilterValues: { metaTitle: ['meta', 'more-meta'], slug: ['slug-link'] }
@@ -312,7 +312,7 @@ describe('build raw query', () => {
312
312
  },
313
313
  id,
314
314
  itemsToDisplay
315
- );
315
+ });
316
316
 
317
317
  expect(rawQueryOneCheckboxFilterMoreItemsToDisplayValues).toEqual(
318
318
  RAW_QUERY_OR_OPERATOR_ITEMS_TO_DISPLAY
@@ -320,15 +320,15 @@ describe('build raw query', () => {
320
320
  });
321
321
 
322
322
  it('should return corresponding query when there are items to display and should apply sort is passed as true', () => {
323
- const rawQueryWithShouldApplySort = buildRawQuery(
323
+ const rawQueryWithShouldApplySort = buildRawQuery({
324
324
  docType,
325
325
  operator,
326
- {
326
+ searchValues: {
327
327
  searchValuesText,
328
328
  searchValuesCheckboxSelectRange,
329
329
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
330
330
  },
331
- {
331
+ filterData: {
332
332
  filterValues: {
333
333
  checkboxFilters: ['sponsored'],
334
334
  listFilterValues: { url: ['/url', '/alternative-url'], date: ['29-03-2020'] }
@@ -339,28 +339,52 @@ describe('build raw query', () => {
339
339
  },
340
340
  id,
341
341
  itemsToDisplay,
342
- true
343
- );
342
+ shouldApplySort: true
343
+ });
344
344
 
345
345
  expect(rawQueryWithShouldApplySort).toEqual(RAW_QUERY_WITH_SHOULD_APPLY_SORT);
346
346
  });
347
347
 
348
348
  it('should return query with aggs if requested', () => {
349
- const queryWithAggs = buildRawQuery(
349
+ const queryWithAggs = buildRawQuery({
350
350
  docType,
351
351
  operator,
352
- {
352
+ searchValues: {
353
353
  searchValuesText,
354
354
  searchValuesCheckboxSelectRange,
355
355
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
356
356
  },
357
357
  filterData,
358
358
  id,
359
- [],
360
- true,
361
- { shouldReturnAggs: true, isAZ: true }
362
- );
359
+ itemsToDisplay: [],
360
+ shouldApplySort: true,
361
+ azOptions: { shouldReturnAggs: true, isAZ: true }
362
+ });
363
363
 
364
364
  expect(queryWithAggs).toEqual(RAW_QUERY_WITH_AGGS);
365
365
  });
366
+
367
+ it('should return query with aggs if requested using custom az param', () => {
368
+ const customProperty = 'lastname';
369
+ const queryWithAggs = buildRawQuery({
370
+ docType,
371
+ operator,
372
+ searchValues: {
373
+ searchValuesText,
374
+ searchValuesCheckboxSelectRange,
375
+ searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
376
+ },
377
+ filterData,
378
+ id,
379
+ itemsToDisplay: [],
380
+ shouldApplySort: true,
381
+ azOptions: {
382
+ shouldReturnAggs: true,
383
+ isAZ: true,
384
+ sortProperties: [{ propsToDisplay: [customProperty] }]
385
+ }
386
+ });
387
+
388
+ expect(JSON.stringify(queryWithAggs)).toContain(`${customProperty}.keyword`);
389
+ });
366
390
  });
@@ -0,0 +1,34 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import buildSortValues from '../../../../src/helpers/build-sort-values';
3
+
4
+ describe('buildSortValues helper function', () => {
5
+ it('should return an object with empty sort array if no sortFilters are passed', () => {
6
+ const noSort = buildSortValues();
7
+ const emptySortFilters = buildSortValues([]);
8
+ expect(noSort).toEqual({ sort: [] });
9
+ expect(emptySortFilters).toEqual({ sort: [] });
10
+ });
11
+
12
+ it('should return null if no sortFilters are passed and useSortObject is true', () => {
13
+ const noSortUseSortObject = buildSortValues(null, [], [], true);
14
+ const emptySortFiltersUseSortObject = buildSortValues([], [], [], true);
15
+ expect(noSortUseSortObject).toEqual(null);
16
+ expect(emptySortFiltersUseSortObject).toEqual(null);
17
+ });
18
+
19
+ it('should return sort object if useSortObject is true and sortFilters match', () => {
20
+ const withUseSortObject = buildSortValues(
21
+ [
22
+ {
23
+ propsToDisplay: ['slug'],
24
+ sort: 'ASC',
25
+ label: ''
26
+ }
27
+ ],
28
+ [],
29
+ ['name', 'slug', 'metaTitle'],
30
+ true
31
+ );
32
+ expect(withUseSortObject).toEqual({ 'slug.keyword': 'asc' });
33
+ });
34
+ });
@@ -1,21 +1,51 @@
1
+ import { AZ_DEFAULT_PROP } from '../../../../src/constants';
1
2
  import getExtraAzBits from '../../../../src/helpers/get-extra-az-bits';
2
- import { AZ_AGGS, ALL_AZ_SORT } from '../../../../src/constants';
3
3
 
4
4
  describe('getExtraAzBits helper function', () => {
5
+ // shouldReturnAggs, isAZ, azSortProperty, azFilter
6
+ const customProperty = 'lastname';
7
+
5
8
  it('should return empty object if isAz is false', () => {
6
- const noExtraBits = getExtraAzBits(false, false);
9
+ const noExtraBits = getExtraAzBits({ shouldReturnAggs: false, isAZ: false });
7
10
  const noExtraBits2 = getExtraAzBits(false, true, 'a');
8
11
  expect(noExtraBits).toEqual({});
9
12
  expect(noExtraBits2).toEqual({});
10
13
  });
11
14
 
12
15
  it('should return AZ_AGGS if shouldReturnAggs and isAz is true', () => {
13
- const withAggs = getExtraAzBits(true, true);
14
- expect(withAggs).toEqual(AZ_AGGS);
16
+ const withAggs = getExtraAzBits({ shouldReturnAggs: true, isAZ: true });
17
+ propertyCheck(withAggs);
18
+ expect(withAggs).toMatchSnapshot();
15
19
  });
16
20
 
17
21
  it('should return ALL_AZ_SORT if shouldReturnAggs is false and is Az and no Az filter is passed', () => {
18
- const withAggs = getExtraAzBits(false, true, '');
19
- expect(withAggs).toEqual(ALL_AZ_SORT);
22
+ const withAggs = getExtraAzBits({ shouldReturnAggs: false, isAZ: true, azFilter: '' });
23
+ propertyCheck(withAggs);
24
+ expect(withAggs).toMatchSnapshot();
25
+ });
26
+
27
+ it('should return AZ_AGGS if shouldReturnAggs and isAz is true with custom property', () => {
28
+ const withAggs = getExtraAzBits({
29
+ shouldReturnAggs: true,
30
+ isAZ: true,
31
+ azSortProperty: customProperty
32
+ });
33
+ propertyCheck(withAggs, customProperty);
34
+ expect(withAggs).toMatchSnapshot();
35
+ });
36
+
37
+ it('should return ALL_AZ_SORT if shouldReturnAggs is false and is Az and no Az filter is passed with custom property', () => {
38
+ const withAggs = getExtraAzBits({
39
+ shouldReturnAggs: false,
40
+ isAZ: true,
41
+ azFilter: '',
42
+ azSortProperty: customProperty
43
+ });
44
+ propertyCheck(withAggs, customProperty);
45
+ expect(withAggs).toMatchSnapshot();
20
46
  });
21
47
  });
48
+
49
+ function propertyCheck(result, property = AZ_DEFAULT_PROP) {
50
+ expect(JSON.stringify(result)).toContain(`${property}.keyword`);
51
+ }
@@ -1,8 +1,6 @@
1
1
  import '@testing-library/jest-dom/extend-expect';
2
2
  import getGenericRenderVariables from '../../../../src/helpers/get-generic-render-variables';
3
3
 
4
- const IS_TEXT_SEARCH_FILTER_APPLIED_TRUE = true;
5
- const IS_TEXT_SEARCH_FILTER_APPLIED_FALSE = false;
6
4
  const RAW_QUERY_STRINGIFIED = '{}';
7
5
  const SORT_VALUE = 'updated:desc';
8
6
  const STRING_PROPS_EMPTY = [];
@@ -18,88 +16,87 @@ const mockedProps = overrides => ({
18
16
 
19
17
  describe('get card/list render variables', () => {
20
18
  it('should always return an object', () => {
21
- const variables = getGenericRenderVariables();
22
- const variablesWithProps = getGenericRenderVariables([], mockedProps(), STRING_PROPS_EMPTY);
19
+ const variables = getGenericRenderVariables({});
20
+ const variablesWithProps = getGenericRenderVariables({
21
+ relations: [],
22
+ filterProps: mockedProps(),
23
+ stringProps: STRING_PROPS_EMPTY
24
+ });
23
25
 
24
26
  expect(typeof variables).toBe('object');
25
27
  expect(typeof variablesWithProps).toBe('object');
26
28
  });
27
29
 
28
30
  it('should return an object with correct data', () => {
29
- const { limit, sort, offset } = getGenericRenderVariables(
30
- [],
31
- mockedProps(),
32
- STRING_PROPS_EMPTY
33
- );
31
+ const { limit, sort, offset } = getGenericRenderVariables({
32
+ relations: [],
33
+ filterProps: mockedProps(),
34
+ stringProps: STRING_PROPS_EMPTY
35
+ });
34
36
 
35
37
  expect(limit).toEqual(50);
36
38
  expect(offset).toEqual(2);
37
39
  expect(sort).toEqual(SORT_VALUE);
38
40
  });
39
41
 
40
- it('should return an object with sort being undefined when text-search filter applied', () => {
41
- const { sort } = getGenericRenderVariables(
42
- [],
43
- mockedProps(),
44
- STRING_PROPS_EMPTY,
45
- RAW_QUERY_STRINGIFIED,
46
- IS_TEXT_SEARCH_FILTER_APPLIED_TRUE
47
- );
48
-
49
- expect(sort).toBeFalsy();
50
- });
51
-
52
42
  it('should return an object with correct sort when text-search filter not applied', () => {
53
- const { sort } = getGenericRenderVariables(
54
- [],
55
- mockedProps(),
56
- STRING_PROPS_EMPTY,
57
- RAW_QUERY_STRINGIFIED,
58
- IS_TEXT_SEARCH_FILTER_APPLIED_FALSE
59
- );
43
+ const { sort } = getGenericRenderVariables({
44
+ relations: [],
45
+ filterProps: mockedProps(),
46
+ stringProps: STRING_PROPS_EMPTY,
47
+ rawQuery: RAW_QUERY_STRINGIFIED,
48
+ isTextSearchFilterApplied: false
49
+ });
60
50
 
61
51
  expect(sort).toEqual(SORT_VALUE);
62
52
  });
63
53
 
64
54
  it('should return an object with correct data when no arguments passed to function', () => {
65
- const { sort, offset } = getGenericRenderVariables();
66
-
55
+ const { sort, offset } = getGenericRenderVariables({});
67
56
  expect(sort).toBeFalsy();
68
57
  expect(offset).toEqual(0);
69
58
  });
70
59
 
71
60
  it('should return an object with correct data when no sortby is passed', () => {
72
- const { sort, offset } = getGenericRenderVariables(mockedProps({ sortby: [] }));
61
+ const { sort, offset } = getGenericRenderVariables({ relations: mockedProps({ sortby: [] }) });
73
62
 
74
63
  expect(sort).toBeFalsy();
75
64
  expect(offset).toEqual(0);
76
65
  });
77
66
 
78
67
  it('should return correct sort data when we pass an array', () => {
79
- const { sort } = getGenericRenderVariables(
80
- [],
81
- mockedProps({ sortby: ['length'] }),
82
- STRING_PROPS_EMPTY
83
- );
68
+ const { sort } = getGenericRenderVariables({
69
+ relations: [],
70
+ filterProps: mockedProps({ sortby: ['length'] }),
71
+ stringProps: STRING_PROPS_EMPTY
72
+ });
84
73
  expect(sort).toEqual('length:desc');
85
74
  });
86
75
 
87
76
  it('should return correct sort data when when there is a prop that is of type string', () => {
88
- const { sort } = getGenericRenderVariables([], mockedProps({ sortby: 'name' }), STRING_PROPS);
77
+ const { sort } = getGenericRenderVariables({
78
+ relations: [],
79
+ filterProps: mockedProps({ sortby: 'name' }),
80
+ stringProps: STRING_PROPS
81
+ });
89
82
  expect(sort).toEqual('name.keyword:desc');
90
83
  });
91
84
 
92
85
  it('should return correct sort data sortby is an array', () => {
93
- const { sort } = getGenericRenderVariables([], mockedProps({ sortby: ['name'] }), STRING_PROPS);
86
+ const { sort } = getGenericRenderVariables({
87
+ relations: [],
88
+ filterProps: mockedProps({ sortby: ['name'] }),
89
+ stringProps: STRING_PROPS
90
+ });
94
91
  expect(sort).toEqual('name.keyword:desc');
95
92
  });
96
93
 
97
94
  it("should return correct sort data when when there is a prop that is of type string and it's also a relation prop", () => {
98
- const { sort } = getGenericRenderVariables(
99
- [{ localField: 'entity', entityIdentifier: 'entity' }],
100
- mockedProps({ sortby: 'entity.name', sort: 'ASC' }),
101
- ['entity.name']
102
- );
95
+ const { sort } = getGenericRenderVariables({
96
+ relations: [{ localField: 'entity', entityIdentifier: 'entity' }],
97
+ filterProps: mockedProps({ sortby: 'entity.name', sort: 'ASC' }),
98
+ stringProps: ['entity.name']
99
+ });
103
100
 
104
101
  expect(sort).toEqual('entity.name.keyword:asc');
105
102
  });
@@ -107,21 +104,21 @@ describe('get card/list render variables', () => {
107
104
  it("should return correct sort data when when there is a prop that is not of type string but it's a relation prop", () => {
108
105
  const localField = 'entityField';
109
106
  const sortby = `${localField}.length`;
110
- const { sort } = getGenericRenderVariables(
111
- [{ localField, entityIdentifier: 'entity' }],
112
- mockedProps({ sortby, sort: 'ASC' }),
113
- []
114
- );
107
+ const { sort } = getGenericRenderVariables({
108
+ relations: [{ localField, entityIdentifier: 'entity' }],
109
+ filterProps: mockedProps({ sortby, sort: 'ASC' }),
110
+ stringProps: []
111
+ });
115
112
 
116
113
  expect(sort).toEqual(`${sortby}:asc`);
117
114
  });
118
115
 
119
116
  it('should return correct sort data when when there is a relation prop that is of type string but with updated value', () => {
120
- const { sort } = getGenericRenderVariables(
121
- [{ localField: 'tag', entityIdentifier: 'tags' }],
122
- mockedProps({ sortby: 'tag.name', sort: 'ASC' }),
123
- ['tags.name']
124
- );
117
+ const { sort } = getGenericRenderVariables({
118
+ relations: [{ localField: 'tag', entityIdentifier: 'tags' }],
119
+ filterProps: mockedProps({ sortby: 'tag.name', sort: 'ASC' }),
120
+ stringProps: ['tags.name']
121
+ });
125
122
 
126
123
  expect(sort).toEqual('tag.name.keyword:asc');
127
124
  });