@blaze-cms/react-page-builder 0.133.0-project-admin-customisations.0 → 0.134.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 (93) hide show
  1. package/CHANGELOG.md +90 -5
  2. package/lib/components/Banner/AdSlotRender.js +12 -3
  3. package/lib/components/Banner/AdSlotRender.js.map +1 -1
  4. package/lib/components/Banner/Banner.js +4 -7
  5. package/lib/components/Banner/Banner.js.map +1 -1
  6. package/lib/components/Banner/BannerRender.js +5 -1
  7. package/lib/components/Banner/BannerRender.js.map +1 -1
  8. package/lib/components/Button.js +3 -1
  9. package/lib/components/Button.js.map +1 -1
  10. package/lib/components/ContentGroupSection/ContentGroupSection.js +4 -1
  11. package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  12. package/lib/components/List/helpers/get-sort-props.js +9 -6
  13. package/lib/components/List/helpers/get-sort-props.js.map +1 -1
  14. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +2 -2
  15. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  16. package/lib/components/SearchFilter/SearchFilterContainer.js +58 -22
  17. package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  18. package/lib/components/SearchFilter/helpers/build-filters-query.js +18 -16
  19. package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
  20. package/lib/components/SearchFilter/helpers/build-url-query.js +3 -2
  21. package/lib/components/SearchFilter/helpers/build-url-query.js.map +1 -1
  22. package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +33 -0
  23. package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
  24. package/lib/components/SearchFilter/helpers/get-updated-filter-by.js +38 -0
  25. package/lib/components/SearchFilter/helpers/get-updated-filter-by.js.map +1 -0
  26. package/lib/components/SearchFilter/helpers/index.js +8 -1
  27. package/lib/components/SearchFilter/helpers/index.js.map +1 -1
  28. package/lib/components/SocialFollow/sf.config.js +2 -1
  29. package/lib/components/SocialFollow/sf.config.js.map +1 -1
  30. package/lib/helpers/build-raw-query.js +7 -6
  31. package/lib/helpers/build-raw-query.js.map +1 -1
  32. package/lib/helpers/build-sort-values.js +4 -1
  33. package/lib/helpers/build-sort-values.js.map +1 -1
  34. package/lib-es/components/Banner/AdSlotRender.js +12 -3
  35. package/lib-es/components/Banner/AdSlotRender.js.map +1 -1
  36. package/lib-es/components/Banner/Banner.js +4 -7
  37. package/lib-es/components/Banner/Banner.js.map +1 -1
  38. package/lib-es/components/Banner/BannerRender.js +6 -2
  39. package/lib-es/components/Banner/BannerRender.js.map +1 -1
  40. package/lib-es/components/Button.js +2 -1
  41. package/lib-es/components/Button.js.map +1 -1
  42. package/lib-es/components/ContentGroupSection/ContentGroupSection.js +8 -4
  43. package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  44. package/lib-es/components/List/helpers/get-sort-props.js +9 -6
  45. package/lib-es/components/List/helpers/get-sort-props.js.map +1 -1
  46. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +3 -3
  47. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  48. package/lib-es/components/SearchFilter/SearchFilterContainer.js +54 -13
  49. package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  50. package/lib-es/components/SearchFilter/helpers/build-filters-query.js +18 -16
  51. package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
  52. package/lib-es/components/SearchFilter/helpers/build-url-query.js +1 -2
  53. package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +1 -1
  54. package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +21 -0
  55. package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
  56. package/lib-es/components/SearchFilter/helpers/get-updated-filter-by.js +19 -0
  57. package/lib-es/components/SearchFilter/helpers/get-updated-filter-by.js.map +1 -0
  58. package/lib-es/components/SearchFilter/helpers/index.js +3 -2
  59. package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
  60. package/lib-es/components/SocialFollow/sf.config.js +3 -2
  61. package/lib-es/components/SocialFollow/sf.config.js.map +1 -1
  62. package/lib-es/helpers/build-raw-query.js +5 -4
  63. package/lib-es/helpers/build-raw-query.js.map +1 -1
  64. package/lib-es/helpers/build-sort-values.js +1 -1
  65. package/lib-es/helpers/build-sort-values.js.map +1 -1
  66. package/package.json +12 -12
  67. package/src/components/Banner/AdSlotRender.js +9 -5
  68. package/src/components/Banner/Banner.js +9 -11
  69. package/src/components/Banner/BannerRender.js +4 -0
  70. package/src/components/Button.js +6 -1
  71. package/src/components/ContentGroupSection/ContentGroupSection.js +1 -1
  72. package/src/components/List/helpers/get-sort-props.js +4 -6
  73. package/src/components/SearchFilter/SearchFilter/SearchFilter.js +6 -3
  74. package/src/components/SearchFilter/SearchFilterContainer.js +42 -14
  75. package/src/components/SearchFilter/helpers/build-filters-query.js +23 -20
  76. package/src/components/SearchFilter/helpers/build-url-query.js +1 -3
  77. package/src/components/SearchFilter/helpers/get-initial-filter-values.js +24 -0
  78. package/src/components/SearchFilter/helpers/get-updated-filter-by.js +18 -0
  79. package/src/components/SearchFilter/helpers/index.js +5 -3
  80. package/src/components/SocialFollow/sf.config.js +2 -2
  81. package/src/helpers/build-raw-query.js +5 -1
  82. package/src/helpers/build-sort-values.js +1 -1
  83. package/tests/unit/src/components/Banner/AdSlotRender.test.js +6 -11
  84. package/tests/unit/src/components/Banner/__snapshots__/AdSlotRender.test.js.snap +45 -25
  85. package/tests/unit/src/components/Banner/__snapshots__/BannerRender.test.js.snap +8 -3
  86. package/tests/unit/src/components/List/helpers/get-sort-props.test.js +23 -0
  87. package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +6 -0
  88. package/tests/unit/src/components/SearchFilter/helpers/get-updated-filter-by.test.js +28 -0
  89. package/tests/unit/src/components/SocialFollow/__snapshots__/SocialFollow.test.js.snap +1 -1
  90. package/tests/unit/src/helpers/build-raw-query.test.js +70 -1
  91. package/tests/unit/src/helpers/build-sort-values.test.js +20 -0
  92. package/tests/unit/src/helpers/get-generic-render-variables.test.js +25 -0
  93. /package/tests/unit/src/components/SearchFilter/helpers/{build-new-query.test.js → build-new-url.test.js} +0 -0
@@ -3,13 +3,18 @@
3
3
  exports[`Banner render component AdSlot loading should change class and remove responsive styles after loaded events 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
- class="ad-slot ad-slot-loaded banner-sizeId"
7
- style="min-height: 250px;"
6
+ class="banner banner-loaded"
8
7
  >
9
8
  <div
10
- data-testid="adslot-test"
11
- role="button"
12
- />
9
+ class="ad-slot ad-slot-loaded banner-sizeId"
10
+ data-testid="ad-slot"
11
+ style="min-height: 250px;"
12
+ >
13
+ <div
14
+ data-testid="adslot-test"
15
+ role="button"
16
+ />
17
+ </div>
13
18
  </div>
14
19
  </DocumentFragment>
15
20
  `;
@@ -17,44 +22,59 @@ exports[`Banner render component AdSlot loading should change class and remove r
17
22
  exports[`Banner render component AdSlot loading should change class and remove responsive styles after loaded events 2`] = `
18
23
  <DocumentFragment>
19
24
  <div
20
- class="ad-slot ad-slot-empty banner-sizeId"
21
- style=""
25
+ class="banner banner-empty"
22
26
  >
23
27
  <div
24
- data-testid="adslot-test"
25
- role="button"
26
- />
28
+ class="ad-slot ad-slot-empty banner-sizeId"
29
+ data-testid="ad-slot"
30
+ style=""
31
+ >
32
+ <div
33
+ data-testid="adslot-test"
34
+ role="button"
35
+ />
36
+ </div>
27
37
  </div>
28
38
  </DocumentFragment>
29
39
  `;
30
40
 
31
41
  exports[`Banner render component AdSlot loading should render AdSlot 1`] = `
32
42
  <DocumentFragment>
33
- <style>
34
- @media(min-width:320px){.banner-sizeId{min-height:100px;}
35
- @media(min-width:728px){.banner-sizeId{min-height:100px;}
36
- @media(min-width:970px){.banner-sizeId{min-height:250px;}
37
- </style>
38
43
  <div
39
- class="ad-slot ad-slot-loading banner-sizeId"
44
+ class="banner banner-loading"
40
45
  >
46
+ <style>
47
+ @media(min-width:320px){.banner-sizeId{min-height:100px;}
48
+ @media(min-width:728px){.banner-sizeId{min-height:100px;}
49
+ @media(min-width:970px){.banner-sizeId{min-height:250px;}
50
+ </style>
41
51
  <div
42
- data-testid="adslot-test"
43
- role="button"
44
- />
52
+ class="ad-slot ad-slot-loading banner-sizeId"
53
+ data-testid="ad-slot"
54
+ >
55
+ <div
56
+ data-testid="adslot-test"
57
+ role="button"
58
+ />
59
+ </div>
45
60
  </div>
46
61
  </DocumentFragment>
47
62
  `;
48
63
 
49
64
  exports[`Banner render component should not render AdSlot if shouldShowBanner=false but should render styles and wrapper 1`] = `
50
65
  <DocumentFragment>
51
- <style>
52
- @media(min-width:320px){.banner-sizeId{min-height:100px;}
66
+ <div
67
+ class="banner banner-loading"
68
+ >
69
+ <style>
70
+ @media(min-width:320px){.banner-sizeId{min-height:100px;}
53
71
  @media(min-width:728px){.banner-sizeId{min-height:100px;}
54
72
  @media(min-width:970px){.banner-sizeId{min-height:250px;}
55
- </style>
56
- <div
57
- class="ad-slot ad-slot-loading banner-sizeId"
58
- />
73
+ </style>
74
+ <div
75
+ class="ad-slot ad-slot-loading banner-sizeId"
76
+ data-testid="ad-slot"
77
+ />
78
+ </div>
59
79
  </DocumentFragment>
60
80
  `;
@@ -2,9 +2,14 @@
2
2
 
3
3
  exports[`Banner render component should render 1`] = `
4
4
  <DocumentFragment>
5
- <style />
6
5
  <div
7
- class="ad-slot ad-slot-loading banner-sizeId"
8
- />
6
+ class="banner banner-loading"
7
+ >
8
+ <style />
9
+ <div
10
+ class="ad-slot ad-slot-loading banner-sizeId"
11
+ data-testid="ad-slot"
12
+ />
13
+ </div>
9
14
  </DocumentFragment>
10
15
  `;
@@ -60,6 +60,29 @@ describe('getSortProps helper function', () => {
60
60
  ]);
61
61
  });
62
62
 
63
+ it('should add score sort as first value if has textSearch but no sort applied', () => {
64
+ const { updatedSortProperties } = getSortProps({
65
+ ...props,
66
+ isTextSearchFilterApplied: true
67
+ });
68
+ expect(updatedSortProperties).toEqual([{ isScore: true }, ...sortProperties]);
69
+ });
70
+
71
+ it('should add default sort and score sort as first value if has textSearch and no other sort', () => {
72
+ const { updatedSortProperties } = getSortProps({
73
+ ...props,
74
+ sortProperties: [],
75
+ isTextSearchFilterApplied: true
76
+ });
77
+ expect(updatedSortProperties).toEqual([
78
+ { isScore: true },
79
+ {
80
+ propsToDisplay: props.defaultSortBy,
81
+ sort: props.defaultSort
82
+ }
83
+ ]);
84
+ });
85
+
63
86
  it('should use old style sort', () => {
64
87
  const { sortbyFilters, updatedSortProperties } = getSortProps({
65
88
  ...props,
@@ -11,6 +11,7 @@ const mockedProps = [
11
11
  ];
12
12
 
13
13
  describe('buildUrlQuery helper function', () => {
14
+ const noProps = buildUrlQuery();
14
15
  const simpleExample = buildUrlQuery(...mockedProps[0]);
15
16
  const withTextSearch = buildUrlQuery(...mockedProps[1]);
16
17
  const withSearchAndRange = buildUrlQuery(...mockedProps[2]);
@@ -20,6 +21,11 @@ describe('buildUrlQuery helper function', () => {
20
21
  anotherQuery: '123'
21
22
  });
22
23
 
24
+ it('should not break if no params are passed', () => {
25
+ expect(typeof noProps).toBe('string');
26
+ expect(noProps).toEqual('');
27
+ });
28
+
23
29
  it('should always return a string', () => {
24
30
  expect(typeof simpleExample).toBe('string');
25
31
  });
@@ -0,0 +1,28 @@
1
+ import getUpdatedFilterBy from '../../../../../../src/components/SearchFilter/helpers/get-updated-filter-by';
2
+
3
+ const mockedFilterByProperty = ['categoryId/product', 'subjectIds/product'];
4
+
5
+ const mockedParentData = {
6
+ id: 'abc123d',
7
+ categoryId: null,
8
+ subjectIds: ['subjectid123s']
9
+ };
10
+
11
+ describe('getUpdatedFilterBy helper', () => {
12
+ const mockedFilterBy = [1, 2, 3];
13
+ const noParentData = getUpdatedFilterBy(mockedFilterBy, [], {});
14
+ const withFilterBy = getUpdatedFilterBy(mockedFilterBy, [], { id: '123' });
15
+ const withUpdatedFilterBy = getUpdatedFilterBy([], mockedFilterByProperty, mockedParentData);
16
+
17
+ it('should return current filterBy and filterByProperty if no parentData or if filterBy values exist', () => {
18
+ expect(noParentData).toEqual({ updatedFilterBy: mockedFilterBy, updatedFilterByProperty: [] });
19
+ expect(withFilterBy).toEqual({ updatedFilterBy: mockedFilterBy, updatedFilterByProperty: [] });
20
+ });
21
+
22
+ it('should return updated filterBy based on parent data matchess', () => {
23
+ expect(withUpdatedFilterBy).toEqual({
24
+ updatedFilterBy: ['subjectIds/subjectid123s'],
25
+ updatedFilterByProperty: mockedFilterByProperty
26
+ });
27
+ });
28
+ });
@@ -61,7 +61,7 @@ exports[`SocialFollow component should render without throwing an error and matc
61
61
  xmlns="http://www.w3.org/2000/svg"
62
62
  >
63
63
  <path
64
- d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"
64
+ d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"
65
65
  />
66
66
  </svg>
67
67
  </i>
@@ -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 {
@@ -365,7 +366,6 @@ describe('build raw query', () => {
365
366
  });
366
367
 
367
368
  it('should return query with aggs if requested using custom az param', () => {
368
- const customProperty = 'lastname';
369
369
  const queryWithAggs = buildRawQuery({
370
370
  docType,
371
371
  operator,
@@ -387,4 +387,73 @@ describe('build raw query', () => {
387
387
 
388
388
  expect(JSON.stringify(queryWithAggs)).toContain(`${customProperty}.keyword`);
389
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
+ });
456
+
457
+ expect(queryWithAggs).toEqual(RAW_QUERY_WITH_AGGS);
458
+ });
390
459
  });
@@ -31,4 +31,24 @@ describe('buildSortValues helper function', () => {
31
31
  );
32
32
  expect(withUseSortObject).toEqual({ 'slug.keyword': 'asc' });
33
33
  });
34
+
35
+ it('should filter out duplicate sort values', () => {
36
+ const sort = buildSortValues(
37
+ [
38
+ {
39
+ propsToDisplay: ['slug'],
40
+ sort: 'ASC',
41
+ label: ''
42
+ },
43
+ {
44
+ propsToDisplay: ['slug'],
45
+ sort: 'ASC',
46
+ label: ''
47
+ }
48
+ ],
49
+ [],
50
+ ['name', 'slug', 'metaTitle']
51
+ );
52
+ expect(sort).toEqual({ sort: 'slug.keyword:asc' });
53
+ });
34
54
  });
@@ -122,4 +122,29 @@ describe('get card/list render variables', () => {
122
122
 
123
123
  expect(sort).toEqual('tag.name.keyword:asc');
124
124
  });
125
+
126
+ it('should handle multiple sort properties', () => {
127
+ const sortProperties = [
128
+ {
129
+ propsToDisplay: ['featured'],
130
+ sort: 'DESC',
131
+ label: '',
132
+ status: 'show'
133
+ },
134
+ {
135
+ propsToDisplay: ['date'],
136
+ sort: 'DESC',
137
+ label: '',
138
+ items: null,
139
+ status: 'show'
140
+ }
141
+ ];
142
+ const { sort } = getGenericRenderVariables({
143
+ relations: [{ localField: 'tag', entityIdentifier: 'tags' }],
144
+ filterProps: mockedProps({ sort: '', sortby: '', sortProperties }),
145
+ stringProps: ['tags.name']
146
+ });
147
+
148
+ expect(sort).toEqual('featured:desc,date:desc');
149
+ });
125
150
  });