@blaze-cms/react-page-builder 0.123.0-alpha.9 → 0.123.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 (75) hide show
  1. package/CHANGELOG.md +99 -801
  2. package/lib/components/Card/Card.js +20 -6
  3. package/lib/components/Card/Card.js.map +1 -1
  4. package/lib/components/Card/CardContainer.js +20 -4
  5. package/lib/components/Card/CardContainer.js.map +1 -1
  6. package/lib/components/CarouselWrapper.js +12 -5
  7. package/lib/components/CarouselWrapper.js.map +1 -1
  8. package/lib/components/DataSummary/helpers/get-link-based-on-value.js +4 -0
  9. package/lib/components/DataSummary/helpers/get-link-based-on-value.js.map +1 -1
  10. package/lib/components/List/components/Cards/CardsRenderItem.js +23 -4
  11. package/lib/components/List/components/Cards/CardsRenderItem.js.map +1 -1
  12. package/lib/components/Menu/Menu.js +4 -3
  13. package/lib/components/Menu/Menu.js.map +1 -1
  14. package/lib/components/SearchContent/index.js +29 -23
  15. package/lib/components/SearchContent/index.js.map +1 -1
  16. package/lib/components/SearchFilter/SearchFilter/FiltersList.js +16 -11
  17. package/lib/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
  18. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +15 -50
  19. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  20. package/lib/components/SearchFilter/components/Select.js +22 -10
  21. package/lib/components/SearchFilter/components/Select.js.map +1 -1
  22. package/lib/components/index.js +5 -0
  23. package/lib/components/index.js.map +1 -1
  24. package/lib/constants/index.js +5 -2
  25. package/lib/constants/index.js.map +1 -1
  26. package/lib-es/components/Card/Card.js +18 -4
  27. package/lib-es/components/Card/Card.js.map +1 -1
  28. package/lib-es/components/Card/CardContainer.js +21 -5
  29. package/lib-es/components/Card/CardContainer.js.map +1 -1
  30. package/lib-es/components/CarouselWrapper.js +12 -5
  31. package/lib-es/components/CarouselWrapper.js.map +1 -1
  32. package/lib-es/components/DataSummary/helpers/get-link-based-on-value.js +5 -1
  33. package/lib-es/components/DataSummary/helpers/get-link-based-on-value.js.map +1 -1
  34. package/lib-es/components/List/components/Cards/CardsRenderItem.js +23 -4
  35. package/lib-es/components/List/components/Cards/CardsRenderItem.js.map +1 -1
  36. package/lib-es/components/Menu/Menu.js +4 -3
  37. package/lib-es/components/Menu/Menu.js.map +1 -1
  38. package/lib-es/components/SearchContent/index.js +26 -22
  39. package/lib-es/components/SearchContent/index.js.map +1 -1
  40. package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js +20 -16
  41. package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
  42. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +10 -40
  43. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  44. package/lib-es/components/SearchFilter/components/Select.js +22 -6
  45. package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
  46. package/lib-es/components/index.js +4 -1
  47. package/lib-es/components/index.js.map +1 -1
  48. package/lib-es/constants/index.js +3 -1
  49. package/lib-es/constants/index.js.map +1 -1
  50. package/package.json +3 -3
  51. package/src/components/Card/Card.js +28 -3
  52. package/src/components/Card/CardContainer.js +18 -2
  53. package/src/components/CarouselWrapper.js +8 -5
  54. package/src/components/DataSummary/helpers/get-link-based-on-value.js +9 -1
  55. package/src/components/List/components/Cards/CardsRenderItem.js +22 -3
  56. package/src/components/Menu/Menu.js +4 -3
  57. package/src/components/SearchContent/index.js +24 -18
  58. package/src/components/SearchFilter/SearchFilter/FiltersList.js +5 -2
  59. package/src/components/SearchFilter/SearchFilter/SearchFilter.js +113 -148
  60. package/src/components/SearchFilter/components/Select.js +29 -6
  61. package/src/components/index.js +2 -1
  62. package/src/constants/index.js +3 -1
  63. package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +10 -10
  64. package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +8 -8
  65. package/tests/unit/src/components/Card/__snapshots__/CardRender.test.js.snap +2 -2
  66. package/tests/unit/src/components/Card/mockData.js +2 -0
  67. package/tests/unit/src/components/DataSummary/helpers/get-link-based-on-value.test.js +29 -0
  68. package/tests/unit/src/components/List/components/Cards/__snapshots__/CardsRender.test.js.snap +12 -12
  69. package/tests/unit/src/components/Menu/Menu.test.js +3 -1
  70. package/tests/unit/src/components/Menu/__snapshots__/Menu.test.js.snap +3 -0
  71. package/tests/unit/src/components/SearchFilter/SearchFilter/SearchFilter.test.js +64 -86
  72. package/tests/unit/src/components/SearchFilter/SearchFilter/__snapshots__/SearchFilter.test.js.snap +133 -61
  73. package/tests/unit/src/components/SearchFilter/components/Select.test.js +58 -4
  74. package/tests/unit/src/components/SearchFilter/components/__snapshots__/Select.test.js.snap +28 -5
  75. package/tests/unit/src/components/__snapshots__/index.test.js.snap +4 -0
@@ -26,7 +26,7 @@ exports[`CardContainer component should render with carousel if option is enable
26
26
  />
27
27
  </div>
28
28
  <div
29
- class="card__content-wrapper card__content-wrapper--portrait"
29
+ class="card__content-wrapper card__content-wrapper--portrait "
30
30
  >
31
31
  <div
32
32
  class="card__content card__content--portrait"
@@ -37,7 +37,7 @@ exports[`CardContainer component should render with carousel if option is enable
37
37
  page
38
38
  </div>
39
39
  <h2
40
- class="card__title card__title--portrait"
40
+ class="card__title card__title--portrait "
41
41
  >
42
42
  <a
43
43
  href="/nautors-swan/swan-78"
@@ -63,7 +63,7 @@ exports[`CardContainer component should render with carousel if option is enable
63
63
  />
64
64
  </div>
65
65
  <div
66
- class="card__content-wrapper card__content-wrapper--portrait"
66
+ class="card__content-wrapper card__content-wrapper--portrait "
67
67
  >
68
68
  <div
69
69
  class="card__content card__content--portrait"
@@ -74,7 +74,7 @@ exports[`CardContainer component should render with carousel if option is enable
74
74
  page
75
75
  </div>
76
76
  <h2
77
- class="card__title card__title--portrait"
77
+ class="card__title card__title--portrait "
78
78
  >
79
79
  <a
80
80
  href="/nautors-swan/swan-98"
@@ -110,7 +110,7 @@ exports[`CardContainer component should render without throwing error and match
110
110
  />
111
111
  </div>
112
112
  <div
113
- class="card__content-wrapper card__content-wrapper--portrait"
113
+ class="card__content-wrapper card__content-wrapper--portrait "
114
114
  >
115
115
  <div
116
116
  class="card__content card__content--portrait"
@@ -121,7 +121,7 @@ exports[`CardContainer component should render without throwing error and match
121
121
  page
122
122
  </div>
123
123
  <h2
124
- class="card__title card__title--portrait"
124
+ class="card__title card__title--portrait "
125
125
  >
126
126
  <a
127
127
  href="/nautors-swan/swan-78"
@@ -147,7 +147,7 @@ exports[`CardContainer component should render without throwing error and match
147
147
  />
148
148
  </div>
149
149
  <div
150
- class="card__content-wrapper card__content-wrapper--portrait"
150
+ class="card__content-wrapper card__content-wrapper--portrait "
151
151
  >
152
152
  <div
153
153
  class="card__content card__content--portrait"
@@ -158,7 +158,7 @@ exports[`CardContainer component should render without throwing error and match
158
158
  page
159
159
  </div>
160
160
  <h2
161
- class="card__title card__title--portrait"
161
+ class="card__title card__title--portrait "
162
162
  >
163
163
  <a
164
164
  href="/nautors-swan/swan-98"
@@ -21,7 +21,7 @@ exports[`CardRender component should render without throwing an error and match
21
21
  </a>
22
22
  </div>
23
23
  <div
24
- class="card__content-wrapper card__content-wrapper--portrait"
24
+ class="card__content-wrapper card__content-wrapper--portrait "
25
25
  >
26
26
  <div
27
27
  class="card__content card__content--portrait"
@@ -33,7 +33,7 @@ exports[`CardRender component should render without throwing an error and match
33
33
  Card page cat
34
34
  </a>
35
35
  <h2
36
- class="card__title card__title--portrait"
36
+ class="card__title card__title--portrait "
37
37
  >
38
38
  <a
39
39
  href="/card-page"
@@ -12,6 +12,7 @@ const cardDataMockedOptions = {
12
12
  caption: ''
13
13
  }
14
14
  },
15
+ arrowSize: 14,
15
16
  yacht: {
16
17
  builders_list: "| Nautor's Swan |",
17
18
  length_overall: 23.99,
@@ -24,6 +25,7 @@ const cardDataMockedOptions = {
24
25
  name: 'Swan 98',
25
26
  url: '/nautors-swan/swan-98',
26
27
  category: null,
28
+ arrowSize: 14,
27
29
  image: {
28
30
  url:
29
31
  'https://cdn-events.boatinternational.com/files/2020/04/2f8c4030-879c-11ea-aab3-6d01477a82d7-Swan 98 - 1.jpg',
@@ -26,4 +26,33 @@ describe('Get link based on value', () => {
26
26
  });
27
27
  expect.hasAssertions();
28
28
  });
29
+
30
+ it('should return tel: link for phone numbers', () => {
31
+ const examples = [
32
+ '+385 (0) 98 398 831',
33
+ '123456781211',
34
+ '+44123123566345',
35
+ '07789793111',
36
+ '555-456',
37
+ '123/1123',
38
+ '+32 (0) 3231 5055',
39
+ '+32 3 219 08 91'
40
+ ];
41
+ examples.forEach(example => {
42
+ expect(getLinkBasedOnValue(example)).toEqual(`tel:${example}`);
43
+ });
44
+ });
45
+
46
+ it('should not add tel: link for short numbers', () => {
47
+ const examples = [
48
+ '123',
49
+ '2010',
50
+ '123456',
51
+ '11m',
52
+ 'string with number +44123123566345 in the middle'
53
+ ];
54
+ examples.forEach(example => {
55
+ expect(getLinkBasedOnValue(example)).toEqual('');
56
+ });
57
+ });
29
58
  });
@@ -20,13 +20,13 @@ exports[`CardsRender component should render based on listData received 1`] = `
20
20
  class="card card--portrait"
21
21
  >
22
22
  <div
23
- class="card__content-wrapper card__content-wrapper--portrait"
23
+ class="card__content-wrapper card__content-wrapper--portrait "
24
24
  >
25
25
  <div
26
26
  class="card__content card__content--portrait"
27
27
  >
28
28
  <h2
29
- class="card__title card__title--portrait"
29
+ class="card__title card__title--portrait "
30
30
  >
31
31
  item 1
32
32
  </h2>
@@ -41,13 +41,13 @@ exports[`CardsRender component should render based on listData received 1`] = `
41
41
  class="card card--portrait"
42
42
  >
43
43
  <div
44
- class="card__content-wrapper card__content-wrapper--portrait"
44
+ class="card__content-wrapper card__content-wrapper--portrait "
45
45
  >
46
46
  <div
47
47
  class="card__content card__content--portrait"
48
48
  >
49
49
  <h2
50
- class="card__title card__title--portrait"
50
+ class="card__title card__title--portrait "
51
51
  >
52
52
  item 1
53
53
  </h2>
@@ -62,13 +62,13 @@ exports[`CardsRender component should render based on listData received 1`] = `
62
62
  class="card card--portrait"
63
63
  >
64
64
  <div
65
- class="card__content-wrapper card__content-wrapper--portrait"
65
+ class="card__content-wrapper card__content-wrapper--portrait "
66
66
  >
67
67
  <div
68
68
  class="card__content card__content--portrait"
69
69
  >
70
70
  <h2
71
- class="card__title card__title--portrait"
71
+ class="card__title card__title--portrait "
72
72
  >
73
73
  item 1
74
74
  </h2>
@@ -95,13 +95,13 @@ exports[`CardsRender component should render without wrapper, when requested 1`]
95
95
  class="card card--portrait"
96
96
  >
97
97
  <div
98
- class="card__content-wrapper card__content-wrapper--portrait"
98
+ class="card__content-wrapper card__content-wrapper--portrait "
99
99
  >
100
100
  <div
101
101
  class="card__content card__content--portrait"
102
102
  >
103
103
  <h2
104
- class="card__title card__title--portrait"
104
+ class="card__title card__title--portrait "
105
105
  >
106
106
  item 1
107
107
  </h2>
@@ -116,13 +116,13 @@ exports[`CardsRender component should render without wrapper, when requested 1`]
116
116
  class="card card--portrait"
117
117
  >
118
118
  <div
119
- class="card__content-wrapper card__content-wrapper--portrait"
119
+ class="card__content-wrapper card__content-wrapper--portrait "
120
120
  >
121
121
  <div
122
122
  class="card__content card__content--portrait"
123
123
  >
124
124
  <h2
125
- class="card__title card__title--portrait"
125
+ class="card__title card__title--portrait "
126
126
  >
127
127
  item 1
128
128
  </h2>
@@ -137,13 +137,13 @@ exports[`CardsRender component should render without wrapper, when requested 1`]
137
137
  class="card card--portrait"
138
138
  >
139
139
  <div
140
- class="card__content-wrapper card__content-wrapper--portrait"
140
+ class="card__content-wrapper card__content-wrapper--portrait "
141
141
  >
142
142
  <div
143
143
  class="card__content card__content--portrait"
144
144
  >
145
145
  <h2
146
- class="card__title card__title--portrait"
146
+ class="card__title card__title--portrait "
147
147
  >
148
148
  item 1
149
149
  </h2>
@@ -3,6 +3,8 @@ import { render } from '@blaze-cms/tools/test-helpers/test-functions';
3
3
  import '@testing-library/jest-dom/extend-expect';
4
4
  import Menu from '../../../../../src/components/Menu';
5
5
 
6
+ jest.mock('../../../../../src/components/SearchContent', () => () => 'Search Component');
7
+
6
8
  const props = {
7
9
  collapse: false,
8
10
  modifier: 'menu-mod',
@@ -10,7 +12,7 @@ const props = {
10
12
  };
11
13
 
12
14
  describe('Menu component', () => {
13
- it('should render without throwing an error and match snapshot', () => {
15
+ it.skip('should render without throwing an error and match snapshot', () => {
14
16
  const { asFragment } = render(Menu, props);
15
17
  expect(asFragment()).toMatchSnapshot();
16
18
  });
@@ -13,6 +13,9 @@ exports[`Menu component should render without throwing an error and match snapsh
13
13
  >
14
14
  only child
15
15
  </div>
16
+ <li>
17
+ Search Component
18
+ </li>
16
19
  </ul>
17
20
  </div>
18
21
  </DocumentFragment>
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
- import { render, screen, fireEvent } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom';
4
4
  import SearchFilter from '../../../../../../src/components/SearchFilter/SearchFilter';
5
- import { TABLET_WIDTH } from '../../../../../../src/components/SearchFilter/constants';
6
5
 
7
6
  // TODO DELETE WHEN UTIL WILL BE MERGED & USE IMPORT COMMENTED ABOVE
8
7
  const renderComponent = (Component, props) => {
@@ -28,118 +27,97 @@ const mockedProps = {
28
27
  displaySearchFilter: false
29
28
  };
30
29
 
31
- const customGlobal = global;
32
- const defaultWidth = global.innerWidth;
33
-
34
- afterAll(() => {
35
- customGlobal.innerWidth = defaultWidth;
36
- });
37
-
38
30
  describe('SearchFilter component', () => {
39
31
  it('should be defined', () => {
40
32
  expect(SearchFilter).toBeDefined();
41
33
  });
42
34
 
43
- describe('when the device is mobile', () => {
44
- beforeEach(() => {
45
- customGlobal.innerWidth = TABLET_WIDTH;
46
- fireEvent(customGlobal, new Event('resize'));
35
+ describe('when isCollapsedOnResponsive = true, displaySearchFilter = false', () => {
36
+ const specificMockedProps = {
37
+ ...mockedProps,
38
+ isCollapsedOnResponsive: true,
39
+ displaySearchFilter: false
40
+ };
41
+
42
+ it('should NOT render form', () => {
43
+ renderComponent(SearchFilter, specificMockedProps);
44
+ expect(screen.queryByRole('form')).not.toBeInTheDocument();
47
45
  });
48
46
 
49
- describe('when isCollapsedOnResponsive = true, displaySearchFilter = false', () => {
50
- const specificMockedProps = {
51
- ...mockedProps,
52
- isCollapsedOnResponsive: true,
53
- displaySearchFilter: false
54
- };
55
-
56
- it('should NOT render form', () => {
57
- renderComponent(SearchFilter, specificMockedProps);
58
- expect(screen.queryByRole('form')).not.toBeInTheDocument();
59
- });
60
-
61
- it('should render the mobile refine button', () => {
62
- renderComponent(SearchFilter, specificMockedProps);
63
- expect(screen.queryByTestId('refine-mobile')).toBeInTheDocument();
64
- });
47
+ it('should render the mobile refine button', () => {
48
+ renderComponent(SearchFilter, specificMockedProps);
49
+ expect(screen.queryByTestId('refine-mobile')).toBeInTheDocument();
65
50
  });
51
+ });
66
52
 
67
- describe('when isCollapsedOnResponsive = false, displaySearchFilter = true', () => {
68
- const specificMockedProps = {
69
- ...mockedProps,
70
- isCollapsedOnResponsive: false,
71
- displaySearchFilter: true
72
- };
73
-
74
- it('should NOT render form', () => {
75
- renderComponent(SearchFilter, specificMockedProps);
76
- expect(screen.queryByRole('form')).not.toBeInTheDocument();
77
- });
53
+ describe('when isCollapsedOnResponsive = false, displaySearchFilter = true', () => {
54
+ const specificMockedProps = {
55
+ ...mockedProps,
56
+ isCollapsedOnResponsive: false,
57
+ displaySearchFilter: true
58
+ };
59
+
60
+ it('should NOT render form', () => {
61
+ renderComponent(SearchFilter, specificMockedProps);
62
+ expect(screen.queryByRole('form')).not.toBeInTheDocument();
78
63
  });
64
+ });
65
+
66
+ describe('when isCollapsedOnResponsive = false, displaySearchFilter = false', () => {
67
+ const specificMockedProps = {
68
+ ...mockedProps,
69
+ isCollapsedOnResponsive: false,
70
+ displaySearchFilter: false
71
+ };
79
72
 
80
- describe('when isCollapsedOnResponsive = false, displaySearchFilter = false', () => {
81
- const specificMockedProps = {
82
- ...mockedProps,
83
- isCollapsedOnResponsive: false,
84
- displaySearchFilter: false
85
- };
86
-
87
- it('should render without throwing error and match snapshot', () => {
88
- const { asFragment } = renderComponent(SearchFilter, specificMockedProps);
89
- expect(asFragment()).toMatchSnapshot();
90
- });
91
-
92
- it('should render form', () => {
93
- renderComponent(SearchFilter, specificMockedProps);
94
-
95
- const formId = `filter-${specificMockedProps.name}-form`;
96
- const form = screen.getByTestId(formId);
97
- expect(form).toBeInTheDocument();
98
- });
73
+ it('should render without throwing error and match snapshot', () => {
74
+ const { asFragment } = renderComponent(SearchFilter, specificMockedProps);
75
+ expect(asFragment()).toMatchSnapshot();
99
76
  });
100
77
 
101
- describe('when isCollapsedOnResponsive = true, displaySearchFilter = true', () => {
102
- const specificMockedProps = {
103
- ...mockedProps,
104
- isCollapsedOnResponsive: true,
105
- displaySearchFilter: true
106
- };
107
-
108
- it('should render without throwing error and match snapshot', () => {
109
- const { asFragment } = renderComponent(SearchFilter, specificMockedProps);
110
- expect(asFragment()).toMatchSnapshot();
111
- });
112
-
113
- it('should render form', () => {
114
- renderComponent(SearchFilter, specificMockedProps);
115
-
116
- const formId = `filter-${specificMockedProps.name}-form`;
117
- const form = screen.getByTestId(formId);
118
- expect(form).toBeInTheDocument();
119
- });
78
+ it('should render form', () => {
79
+ renderComponent(SearchFilter, specificMockedProps);
80
+
81
+ const formId = `filter-${specificMockedProps.name}-form`;
82
+ const form = screen.getByTestId(formId);
83
+ expect(form).toBeInTheDocument();
120
84
  });
121
85
  });
122
86
 
123
- describe('when the device is desktop', () => {
124
- beforeEach(() => {
125
- customGlobal.innerWidth = TABLET_WIDTH + 10;
126
- fireEvent(customGlobal, new Event('resize'));
127
- });
87
+ describe('when isCollapsedOnResponsive = true, displaySearchFilter = true', () => {
88
+ const specificMockedProps = {
89
+ ...mockedProps,
90
+ isCollapsedOnResponsive: true,
91
+ displaySearchFilter: true
92
+ };
128
93
 
129
94
  it('should render without throwing error and match snapshot', () => {
130
- const { asFragment } = renderComponent(SearchFilter, mockedProps);
95
+ const { asFragment } = renderComponent(SearchFilter, specificMockedProps);
131
96
  expect(asFragment()).toMatchSnapshot();
132
97
  });
133
98
 
134
99
  it('should render form', () => {
135
- renderComponent(SearchFilter, mockedProps);
100
+ renderComponent(SearchFilter, specificMockedProps);
136
101
 
137
- const formId = `filter-${mockedProps.name}-form`;
102
+ const formId = `filter-${specificMockedProps.name}-form`;
138
103
  const form = screen.getByTestId(formId);
139
104
  expect(form).toBeInTheDocument();
140
105
  });
141
106
  });
142
107
 
108
+ it('should render without throwing error and match snapshot', () => {
109
+ const { asFragment } = renderComponent(SearchFilter, mockedProps);
110
+ expect(asFragment()).toMatchSnapshot();
111
+ });
112
+
113
+ it('should render form', () => {
114
+ renderComponent(SearchFilter, mockedProps);
115
+
116
+ const formId = `filter-${mockedProps.name}-form`;
117
+ const form = screen.getByTestId(formId);
118
+ expect(form).toBeInTheDocument();
119
+ });
120
+
143
121
  describe('when groupAfterMobile > 0 and groupAfterDesktop = 0', () => {
144
122
  const specificMockedProps = {
145
123
  ...mockedProps,