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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/CHANGELOG.md +24 -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 +30 -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 +27 -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 +13 -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 +151 -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
@@ -32,6 +32,7 @@ const filterData = {
32
32
  relations: [],
33
33
  stringProps: []
34
34
  };
35
+ const customProperty = 'lastname';
35
36
 
36
37
  describe('build raw query', () => {
37
38
  const {
@@ -43,17 +44,17 @@ describe('build raw query', () => {
43
44
  id,
44
45
  itemsToDisplay
45
46
  } = MOCKED_ARGS;
46
- const rawQuery = buildRawQuery(
47
+ const rawQuery = buildRawQuery({
47
48
  docType,
48
49
  operator,
49
- {
50
+ searchValues: {
50
51
  searchValuesText,
51
52
  searchValuesCheckboxSelectRange,
52
53
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
53
54
  },
54
55
  filterData,
55
56
  id
56
- );
57
+ });
57
58
 
58
59
  it('should always return an object', () => {
59
60
  expect(typeof rawQuery).toBe('object');
@@ -64,65 +65,65 @@ describe('build raw query', () => {
64
65
  });
65
66
 
66
67
  it('should return an object with only checkbox & select search values', () => {
67
- const rawQueryCheckboxSelect = buildRawQuery(
68
+ const rawQueryCheckboxSelect = buildRawQuery({
68
69
  docType,
69
70
  operator,
70
- {
71
+ searchValues: {
71
72
  searchValuesText: SEARCH_VALUES_TEXT_EMPTY,
72
73
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
73
74
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
74
75
  },
75
76
  filterData,
76
77
  id
77
- );
78
+ });
78
79
 
79
80
  expect(rawQueryCheckboxSelect).toEqual(RAW_QUERY_CHECKBOX_SELECT);
80
81
  });
81
82
 
82
83
  it('should return an object with only checkbox & select search values when checkbox has OR operator', () => {
83
- const rawQueryCheckboxSelect = buildRawQuery(
84
+ const rawQueryCheckboxSelect = buildRawQuery({
84
85
  docType,
85
86
  operator,
86
- {
87
+ searchValues: {
87
88
  searchValuesText: SEARCH_VALUES_TEXT_EMPTY,
88
89
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
89
90
  searchValuesCheckboxOr
90
91
  },
91
92
  filterData,
92
93
  id
93
- );
94
+ });
94
95
 
95
96
  expect(rawQueryCheckboxSelect).toEqual(RAW_QUERY_CHECKBOX_SELECT_CHECKBOX_HAS_OR_OPERATOR);
96
97
  });
97
98
 
98
99
  it('should return an object with all search values (checkbox, select, text) - and same operator', () => {
99
- const rawQueryCheckboxSelectTextSameOp = buildRawQuery(
100
+ const rawQueryCheckboxSelectTextSameOp = buildRawQuery({
100
101
  docType,
101
- AND_OPERATOR,
102
- {
102
+ operator: AND_OPERATOR,
103
+ searchValues: {
103
104
  searchValuesText: SEARCH_VALUES_TEXT,
104
105
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
105
106
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
106
107
  },
107
108
  filterData,
108
109
  id
109
- );
110
+ });
110
111
 
111
112
  expect(rawQueryCheckboxSelectTextSameOp).toEqual(RAW_QUERY_ALL_SEARCH_VALUE_SAME_OPERATOR);
112
113
  });
113
114
 
114
115
  it('should return an object with all search values (checkbox, select, text) - and different operator', () => {
115
- const rawQueryCheckboxSelectTextDifferentOp = buildRawQuery(
116
+ const rawQueryCheckboxSelectTextDifferentOp = buildRawQuery({
116
117
  docType,
117
118
  operator,
118
- {
119
+ searchValues: {
119
120
  searchValuesText: SEARCH_VALUES_TEXT,
120
121
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
121
122
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
122
123
  },
123
124
  filterData,
124
125
  id
125
- );
126
+ });
126
127
 
127
128
  expect(rawQueryCheckboxSelectTextDifferentOp).toEqual(
128
129
  RAW_QUERY_ALL_SEARCH_VALUE_DIFFERENT_OPERATOR
@@ -130,17 +131,17 @@ describe('build raw query', () => {
130
131
  });
131
132
 
132
133
  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(
134
+ const rawQueryCheckboxSelectTextSameOp = buildRawQuery({
134
135
  docType,
135
- AND_OPERATOR,
136
- {
136
+ operator: AND_OPERATOR,
137
+ searchValues: {
137
138
  searchValuesText: SEARCH_VALUES_TEXT,
138
139
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
139
140
  searchValuesCheckboxOr
140
141
  },
141
142
  filterData,
142
143
  id
143
- );
144
+ });
144
145
 
145
146
  expect(rawQueryCheckboxSelectTextSameOp).toEqual(
146
147
  RAW_QUERY_ALL_SEARCH_VALUE_SAME_OPERATOR_TEXT_CHECKBOX_HAS_OR_OPERATOR
@@ -148,17 +149,17 @@ describe('build raw query', () => {
148
149
  });
149
150
 
150
151
  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(
152
+ const rawQueryCheckboxSelectTextDifferentOp = buildRawQuery({
152
153
  docType,
153
154
  operator,
154
- {
155
+ searchValues: {
155
156
  searchValuesText: SEARCH_VALUES_TEXT,
156
157
  searchValuesCheckboxSelectRange: SEARCH_VALUES_CHECKBOX_SELECT,
157
158
  searchValuesCheckboxOr
158
159
  },
159
160
  filterData,
160
161
  id
161
- );
162
+ });
162
163
 
163
164
  expect(rawQueryCheckboxSelectTextDifferentOp).toEqual(
164
165
  RAW_QUERY_ALL_SEARCH_VALUE_DIFFERENT_OPERATOR_TEXT_CHECKBOX_HAS_OR_OPERATOR
@@ -166,15 +167,15 @@ describe('build raw query', () => {
166
167
  });
167
168
 
168
169
  it('should return an object with featured & sponsored filter set on list', () => {
169
- const rawQueryMoreCheckboxFilters = buildRawQuery(
170
+ const rawQueryMoreCheckboxFilters = buildRawQuery({
170
171
  docType,
171
172
  operator,
172
- {
173
+ searchValues: {
173
174
  searchValuesText,
174
175
  searchValuesCheckboxSelectRange,
175
176
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
176
177
  },
177
- {
178
+ filterData: {
178
179
  filterValues: { checkboxFilters: ['featured', 'sponsored'], listFilterValues: {} },
179
180
  filterOperator: AND,
180
181
  relations: [],
@@ -182,42 +183,42 @@ describe('build raw query', () => {
182
183
  azFilter: 'x'
183
184
  },
184
185
  id
185
- );
186
+ });
186
187
 
187
188
  expect(rawQueryMoreCheckboxFilters).toEqual(RAW_QUERY_CHECKBOX_FILTERS);
188
189
  });
189
190
 
190
191
  it('should return an object with just one checkbox filter set on list', () => {
191
- const rawQueryOneCheckboxFilter = buildRawQuery(
192
+ const rawQueryOneCheckboxFilter = buildRawQuery({
192
193
  docType,
193
194
  operator,
194
- {
195
+ searchValues: {
195
196
  searchValuesText,
196
197
  searchValuesCheckboxSelectRange,
197
198
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
198
199
  },
199
- {
200
+ filterData: {
200
201
  filterValues: { checkboxFilters: ['sponsored'], listFilterValues: {} },
201
202
  filterOperator: AND,
202
203
  relations: [],
203
204
  stringProps: []
204
205
  },
205
206
  id
206
- );
207
+ });
207
208
 
208
209
  expect(rawQueryOneCheckboxFilter).toEqual(RAW_QUERY_ONE_CHECKBOX_FILTERS);
209
210
  });
210
211
 
211
212
  it('should return an object with just one checkbox filter set on list & other filter values', () => {
212
- const rawQueryOneCheckboxFilterMoreValues = buildRawQuery(
213
+ const rawQueryOneCheckboxFilterMoreValues = buildRawQuery({
213
214
  docType,
214
215
  operator,
215
- {
216
+ searchValues: {
216
217
  searchValuesText,
217
218
  searchValuesCheckboxSelectRange,
218
219
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
219
220
  },
220
- {
221
+ filterData: {
221
222
  filterValues: {
222
223
  checkboxFilters: ['sponsored'],
223
224
  listFilterValues: {
@@ -230,7 +231,7 @@ describe('build raw query', () => {
230
231
  stringProps: ['name', 'category.name']
231
232
  },
232
233
  id
233
- );
234
+ });
234
235
 
235
236
  expect(rawQueryOneCheckboxFilterMoreValues).toEqual(
236
237
  RAW_QUERY_ONE_CHECKBOX_FILTERS_AND_OTHER_FILTERS
@@ -238,15 +239,15 @@ describe('build raw query', () => {
238
239
  });
239
240
 
240
241
  it('should return an object with just one checkbox filter set on list & other filter values plus itemsToDIsplayIds', () => {
241
- const rawQueryOneCheckboxFilterMoreItemsToDisplayValues = buildRawQuery(
242
+ const rawQueryOneCheckboxFilterMoreItemsToDisplayValues = buildRawQuery({
242
243
  docType,
243
244
  operator,
244
- {
245
+ searchValues: {
245
246
  searchValuesText,
246
247
  searchValuesCheckboxSelectRange,
247
248
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
248
249
  },
249
- {
250
+ filterData: {
250
251
  filterValues: {
251
252
  checkboxFilters: ['sponsored'],
252
253
  listFilterValues: {
@@ -261,21 +262,21 @@ describe('build raw query', () => {
261
262
  },
262
263
  id,
263
264
  itemsToDisplay
264
- );
265
+ });
265
266
 
266
267
  expect(rawQueryOneCheckboxFilterMoreItemsToDisplayValues).toEqual(RAW_QUERY_ITEMS_TO_DISPLAY);
267
268
  });
268
269
 
269
270
  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(
271
+ const rawQueryOneCheckboxFilterMoreValues = buildRawQuery({
271
272
  docType,
272
273
  operator,
273
- {
274
+ searchValues: {
274
275
  searchValuesText,
275
276
  searchValuesCheckboxSelectRange,
276
277
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
277
278
  },
278
- {
279
+ filterData: {
279
280
  filterValues: {
280
281
  checkboxFilters: ['featured'],
281
282
  listFilterValues: { 'authors.firstname': ['John', 'Paul'], price: ['33'] }
@@ -285,7 +286,7 @@ describe('build raw query', () => {
285
286
  stringProps: ['author.firstname']
286
287
  },
287
288
  id
288
- );
289
+ });
289
290
 
290
291
  expect(rawQueryOneCheckboxFilterMoreValues).toEqual(
291
292
  RAW_QUERY_ONE_CHECKBOX_FILTERS_AND_OTHER_FILTERS_OR_OPERATOR
@@ -293,15 +294,15 @@ describe('build raw query', () => {
293
294
  });
294
295
 
295
296
  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(
297
+ const rawQueryOneCheckboxFilterMoreItemsToDisplayValues = buildRawQuery({
297
298
  docType,
298
299
  operator,
299
- {
300
+ searchValues: {
300
301
  searchValuesText,
301
302
  searchValuesCheckboxSelectRange,
302
303
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
303
304
  },
304
- {
305
+ filterData: {
305
306
  filterValues: {
306
307
  checkboxFilters: ['sponsored'],
307
308
  listFilterValues: { metaTitle: ['meta', 'more-meta'], slug: ['slug-link'] }
@@ -312,7 +313,7 @@ describe('build raw query', () => {
312
313
  },
313
314
  id,
314
315
  itemsToDisplay
315
- );
316
+ });
316
317
 
317
318
  expect(rawQueryOneCheckboxFilterMoreItemsToDisplayValues).toEqual(
318
319
  RAW_QUERY_OR_OPERATOR_ITEMS_TO_DISPLAY
@@ -320,15 +321,15 @@ describe('build raw query', () => {
320
321
  });
321
322
 
322
323
  it('should return corresponding query when there are items to display and should apply sort is passed as true', () => {
323
- const rawQueryWithShouldApplySort = buildRawQuery(
324
+ const rawQueryWithShouldApplySort = buildRawQuery({
324
325
  docType,
325
326
  operator,
326
- {
327
+ searchValues: {
327
328
  searchValuesText,
328
329
  searchValuesCheckboxSelectRange,
329
330
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
330
331
  },
331
- {
332
+ filterData: {
332
333
  filterValues: {
333
334
  checkboxFilters: ['sponsored'],
334
335
  listFilterValues: { url: ['/url', '/alternative-url'], date: ['29-03-2020'] }
@@ -339,27 +340,119 @@ describe('build raw query', () => {
339
340
  },
340
341
  id,
341
342
  itemsToDisplay,
342
- true
343
- );
343
+ shouldApplySort: true
344
+ });
344
345
 
345
346
  expect(rawQueryWithShouldApplySort).toEqual(RAW_QUERY_WITH_SHOULD_APPLY_SORT);
346
347
  });
347
348
 
348
349
  it('should return query with aggs if requested', () => {
349
- const queryWithAggs = buildRawQuery(
350
+ const queryWithAggs = buildRawQuery({
350
351
  docType,
351
352
  operator,
352
- {
353
+ searchValues: {
353
354
  searchValuesText,
354
355
  searchValuesCheckboxSelectRange,
355
356
  searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
356
357
  },
357
358
  filterData,
358
359
  id,
359
- [],
360
- true,
361
- { shouldReturnAggs: true, isAZ: true }
362
- );
360
+ itemsToDisplay: [],
361
+ shouldApplySort: true,
362
+ azOptions: { shouldReturnAggs: true, isAZ: true }
363
+ });
364
+
365
+ expect(queryWithAggs).toEqual(RAW_QUERY_WITH_AGGS);
366
+ });
367
+
368
+ it('should return query with aggs if requested using custom az param', () => {
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
+ });
390
+
391
+ it('should handle filters with search where custom sort is also set', () => {
392
+ const queryWithAggs = buildRawQuery({
393
+ docType,
394
+ operator,
395
+ searchValues: {
396
+ searchValuesText,
397
+ searchValuesCheckboxSelectRange,
398
+ searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
399
+ },
400
+ filterData,
401
+ id,
402
+ itemsToDisplay: [],
403
+ shouldApplySort: true,
404
+ azOptions: {
405
+ shouldReturnAggs: false,
406
+ isAZ: false,
407
+ sortProperties: [{ isScore: true }]
408
+ }
409
+ });
410
+
411
+ expect(JSON.stringify(queryWithAggs)).not.toContain('sort');
412
+ });
413
+
414
+ it('should handle search filters with az listing using custom sort', () => {
415
+ const queryWithAggs = buildRawQuery({
416
+ docType,
417
+ operator,
418
+ searchValues: {
419
+ searchValuesText,
420
+ searchValuesCheckboxSelectRange,
421
+ searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
422
+ },
423
+ filterData,
424
+ id,
425
+ itemsToDisplay: [],
426
+ shouldApplySort: true,
427
+ azOptions: {
428
+ shouldReturnAggs: true,
429
+ isAZ: true,
430
+ sortProperties: [{ isScore: true }, { propsToDisplay: [customProperty] }]
431
+ }
432
+ });
433
+
434
+ expect(JSON.stringify(queryWithAggs)).toContain(`${customProperty}.keyword`);
435
+ });
436
+
437
+ it('should handle search filters with az listing using custom default', () => {
438
+ const queryWithAggs = buildRawQuery({
439
+ docType,
440
+ operator,
441
+ searchValues: {
442
+ searchValuesText,
443
+ searchValuesCheckboxSelectRange,
444
+ searchValuesCheckboxOr: searchValuesCheckboxOrEmpty
445
+ },
446
+ filterData,
447
+ id,
448
+ itemsToDisplay: [],
449
+ shouldApplySort: true,
450
+ azOptions: {
451
+ shouldReturnAggs: true,
452
+ isAZ: true,
453
+ sortProperties: [{ isScore: true }]
454
+ }
455
+ });
363
456
 
364
457
  expect(queryWithAggs).toEqual(RAW_QUERY_WITH_AGGS);
365
458
  });
@@ -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
+ }