@shopgate/pwa-common 7.30.0-alpha.8 → 7.30.0-beta.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.
- package/App.js +28 -13
- package/actions/app/handleUniversalLink.js +0 -2
- package/collections/AuthRoutes.js +15 -13
- package/collections/Configuration.js +11 -10
- package/collections/EmbeddedMedia.js +21 -19
- package/collections/PersistedReducers.js +11 -9
- package/collections/Redirects.js +15 -13
- package/collections/media-providers/MediaProvider.js +23 -21
- package/collections/media-providers/Vimeo.js +28 -22
- package/collections/media-providers/YouTube.js +17 -10
- package/components/Backdrop/index.js +15 -13
- package/components/Backdrop/spec.js +3 -2
- package/components/Button/index.js +41 -29
- package/components/Button/spec.js +16 -10
- package/components/Checkbox/index.js +36 -28
- package/components/Checkbox/spec.js +40 -27
- package/components/Consume/index.js +4 -1
- package/components/CountdownTimer/index.js +27 -20
- package/components/CountdownTimer/spec.js +39 -38
- package/components/Drawer/index.js +31 -23
- package/components/Drawer/spec.js +7 -6
- package/components/Dropdown/index.js +27 -18
- package/components/Ellipsis/index.js +5 -3
- package/components/Ellipsis/spec.js +5 -3
- package/components/EmbeddedMedia/index.js +9 -6
- package/components/EmbeddedMedia/spec.js +11 -2
- package/components/ErrorBoundary/index.js +26 -16
- package/components/Grid/components/Item/index.js +13 -6
- package/components/Grid/components/Item/spec.js +4 -3
- package/components/Grid/index.js +13 -6
- package/components/Grid/spec.js +4 -3
- package/components/HtmlSanitizer/index.js +42 -45
- package/components/HtmlSanitizer/spec.js +31 -21
- package/components/I18n/components/FormatDate/index.js +11 -4
- package/components/I18n/components/FormatDate/spec.js +22 -14
- package/components/I18n/components/FormatNumber/index.js +8 -6
- package/components/I18n/components/FormatNumber/spec.js +10 -5
- package/components/I18n/components/FormatPrice/index.js +5 -3
- package/components/I18n/components/FormatPrice/spec.js +22 -14
- package/components/I18n/components/FormatTime/index.js +11 -4
- package/components/I18n/components/FormatTime/spec.js +22 -14
- package/components/I18n/components/I18nProvider/index.js +18 -11
- package/components/I18n/components/I18nProvider/spec.js +2 -1
- package/components/I18n/components/Placeholder/index.js +10 -3
- package/components/I18n/components/Placeholder/spec.js +12 -5
- package/components/I18n/components/Translate/index.js +12 -8
- package/components/I18n/components/Translate/spec.js +9 -6
- package/components/Icon/index.js +2 -1
- package/components/Image/Image.js +23 -21
- package/components/Image/ImageInner.js +2 -1
- package/components/InfiniteContainer/index.js +59 -53
- package/components/InfiniteContainer/spec.js +10 -5
- package/components/Input/components/MultiLineInput.js +33 -26
- package/components/Input/components/SimpleInput.js +70 -54
- package/components/Input/index.js +7 -17
- package/components/Input/spec.js +12 -11
- package/components/KeyboardConsumer/index.js +19 -13
- package/components/Link/index.js +28 -20
- package/components/Link/spec.js +13 -9
- package/components/List/components/Item/index.js +5 -3
- package/components/List/index.js +5 -3
- package/components/List/spec.js +6 -9
- package/components/Loading/index.js +1 -3
- package/components/Modal/index.js +13 -10
- package/components/ModalContainer/spec.js +24 -20
- package/components/Picker/components/Button/index.js +18 -12
- package/components/Picker/components/List/index.js +19 -16
- package/components/Picker/components/Modal/index.js +34 -25
- package/components/Picker/index.js +44 -33
- package/components/Picker/spec.js +4 -1
- package/components/Portal/index.js +26 -17
- package/components/ProductCharacteristics/index.js +65 -57
- package/components/RangeSlider/components/Handle/index.js +7 -5
- package/components/RangeSlider/index.js +98 -84
- package/components/Route/RouteNotFound.js +30 -19
- package/components/Route/index.js +31 -21
- package/components/Router/index.js +51 -34
- package/components/ScannerContainer/index.js +17 -10
- package/components/Select/components/Item/index.js +5 -3
- package/components/Select/index.js +59 -47
- package/components/Select/spec.js +7 -6
- package/components/SelectBox/components/Item/index.js +23 -13
- package/components/SelectBox/index.js +83 -80
- package/components/SelectBox/spec.js +8 -5
- package/components/SurroundPortals/index.js +15 -11
- package/components/Swiper/components/SwiperItem/index.js +6 -5
- package/components/Swiper/components/SwiperItem/spec.js +12 -4
- package/components/Swiper/index.js +23 -20
- package/components/Toaster/index.js +4 -1
- package/components/Transition/index.js +19 -12
- package/components/Widgets/components/Widget/index.js +27 -16
- package/components/Widgets/components/Widget/spec.js +6 -5
- package/components/Widgets/components/WidgetGrid/index.js +27 -19
- package/components/Widgets/components/WidgetGrid/spec.js +5 -4
- package/components/Widgets/index.js +33 -26
- package/components/Widgets/spec.js +32 -18
- package/helpers/data/index.js +1 -1
- package/helpers/portals/portalCollection.js +13 -10
- package/helpers/redux/mutable.js +2 -2
- package/package.json +5 -6
- package/providers/loading/index.js +71 -57
- package/providers/toast/index.js +39 -28
- package/reducers/modal/index.js +1 -1
- package/store/index.js +1 -1
- package/subscriptions/helpers/buildRegisterUrl.js +1 -0
- package/components/Input/components/DateInput.js +0 -273
|
@@ -2,8 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import Grid from "../../../Grid";
|
|
4
4
|
import Widget from "./index";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
jest.mock('react', () => ({
|
|
6
|
-
...
|
|
7
|
+
...jest.requireActual('react'),
|
|
7
8
|
Suspense: function Suspense({
|
|
8
9
|
children
|
|
9
10
|
}) {
|
|
@@ -15,7 +16,7 @@ jest.mock('react', () => ({
|
|
|
15
16
|
* A dummy component.
|
|
16
17
|
* @returns {JSX}
|
|
17
18
|
*/
|
|
18
|
-
const MyComponent = () => /*#__PURE__*/
|
|
19
|
+
const MyComponent = () => /*#__PURE__*/_jsx("div", {});
|
|
19
20
|
const widgets = {
|
|
20
21
|
'@shopgate/commerce-widgets/image': MyComponent
|
|
21
22
|
};
|
|
@@ -28,7 +29,7 @@ describe('<Widget />', () => {
|
|
|
28
29
|
width: 12,
|
|
29
30
|
height: 6
|
|
30
31
|
};
|
|
31
|
-
const wrapper = mount(/*#__PURE__*/
|
|
32
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Widget, {
|
|
32
33
|
config: config,
|
|
33
34
|
component: widgets[config.type]
|
|
34
35
|
}));
|
|
@@ -43,7 +44,7 @@ describe('<Widget />', () => {
|
|
|
43
44
|
width: 6,
|
|
44
45
|
height: 6
|
|
45
46
|
};
|
|
46
|
-
const wrapper = mount(/*#__PURE__*/
|
|
47
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Widget, {
|
|
47
48
|
config: config,
|
|
48
49
|
component: widgets[config.type],
|
|
49
50
|
cellSize: 100
|
|
@@ -60,7 +61,7 @@ describe('<Widget />', () => {
|
|
|
60
61
|
width: 12,
|
|
61
62
|
height: 6
|
|
62
63
|
};
|
|
63
|
-
const wrapper = mount(/*#__PURE__*/
|
|
64
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Widget, {
|
|
64
65
|
config: config,
|
|
65
66
|
component: widgets[config.type]
|
|
66
67
|
}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { Component } from 'react';
|
|
2
3
|
import isEqual from 'lodash/isEqual';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
@@ -9,12 +10,18 @@ import shouldShowWidget from "../../helpers/shouldShowWidget";
|
|
|
9
10
|
/**
|
|
10
11
|
* The WidgetGrid component.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
let WidgetGrid = /*#__PURE__*/function (_Component) {
|
|
15
|
+
function WidgetGrid() {
|
|
16
|
+
return _Component.apply(this, arguments) || this;
|
|
17
|
+
}
|
|
18
|
+
_inheritsLoose(WidgetGrid, _Component);
|
|
19
|
+
var _proto = WidgetGrid.prototype;
|
|
13
20
|
/**
|
|
14
21
|
* @param {Object} nextProps The next component props.
|
|
15
22
|
* @return {boolean}
|
|
16
23
|
*/
|
|
17
|
-
shouldComponentUpdate(nextProps) {
|
|
24
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
18
25
|
if (!isEqual(this.props.components, nextProps.components)) return true;
|
|
19
26
|
if (!isEqual(this.props.config, nextProps.config)) return true;
|
|
20
27
|
return false;
|
|
@@ -23,8 +30,8 @@ class WidgetGrid extends Component {
|
|
|
23
30
|
/**
|
|
24
31
|
* Render the component.
|
|
25
32
|
* @return {JSX}
|
|
26
|
-
|
|
27
|
-
render() {
|
|
33
|
+
*/;
|
|
34
|
+
_proto.render = function render() {
|
|
28
35
|
const {
|
|
29
36
|
components,
|
|
30
37
|
config
|
|
@@ -36,21 +43,22 @@ class WidgetGrid extends Component {
|
|
|
36
43
|
// TODO: This should not happen within every render call.
|
|
37
44
|
// Sort the widgets by row. This has to happen to take care of the z-index flow.
|
|
38
45
|
const widgets = sortBy(config, ['row']).filter(w => shouldShowWidget(w.settings));
|
|
39
|
-
return /*#__PURE__*/
|
|
40
|
-
className: `${styles} common__widgets__widget-grid
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
|
|
46
|
+
return /*#__PURE__*/_jsx("div", {
|
|
47
|
+
className: `${styles} common__widgets__widget-grid`,
|
|
48
|
+
children: Object.keys(widgets).map(key => {
|
|
49
|
+
const widget = widgets[key];
|
|
50
|
+
const widgetKey = `w${key}`;
|
|
51
|
+
// Map to the correct widget component using the `type` key inside the widget.
|
|
52
|
+
const WidgetComponent = components[widget.type];
|
|
53
|
+
return /*#__PURE__*/_jsx(Widget, {
|
|
54
|
+
config: widget,
|
|
55
|
+
component: WidgetComponent
|
|
56
|
+
}, widgetKey);
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
return WidgetGrid;
|
|
61
|
+
}(Component);
|
|
54
62
|
WidgetGrid.defaultProps = {
|
|
55
63
|
config: []
|
|
56
64
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import WidgetGrid from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
jest.mock('react', () => ({
|
|
5
|
-
...
|
|
6
|
+
...jest.requireActual('react'),
|
|
6
7
|
Suspense: function Suspense({
|
|
7
8
|
children
|
|
8
9
|
}) {
|
|
@@ -14,7 +15,7 @@ jest.mock('react', () => ({
|
|
|
14
15
|
* A mock Image component.
|
|
15
16
|
* @returns {JSX}
|
|
16
17
|
*/
|
|
17
|
-
const Image = () => /*#__PURE__*/
|
|
18
|
+
const Image = () => /*#__PURE__*/_jsx("div", {});
|
|
18
19
|
const components = {
|
|
19
20
|
'@shopgate/commerce-widgets/image': Image
|
|
20
21
|
};
|
|
@@ -31,7 +32,7 @@ describe('<WidgetGrid />', () => {
|
|
|
31
32
|
},
|
|
32
33
|
type: '@shopgate/commerce-widgets/image'
|
|
33
34
|
}];
|
|
34
|
-
const wrapper = mount(/*#__PURE__*/
|
|
35
|
+
const wrapper = mount(/*#__PURE__*/_jsx(WidgetGrid, {
|
|
35
36
|
config: config,
|
|
36
37
|
components: components
|
|
37
38
|
}));
|
|
@@ -39,7 +40,7 @@ describe('<WidgetGrid />', () => {
|
|
|
39
40
|
expect(wrapper.find(Image).length).toEqual(1);
|
|
40
41
|
});
|
|
41
42
|
it('should not render without a `config` prop', () => {
|
|
42
|
-
const wrapper = mount(/*#__PURE__*/
|
|
43
|
+
const wrapper = mount(/*#__PURE__*/_jsx(WidgetGrid, {
|
|
43
44
|
components: components
|
|
44
45
|
}));
|
|
45
46
|
expect(wrapper).toMatchSnapshot();
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { Component } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import isEqual from 'lodash/isEqual';
|
|
4
5
|
import { withThemeWidgets } from '@shopgate/engage/core/hocs';
|
|
5
6
|
import WidgetGrid from "./components/WidgetGrid";
|
|
6
7
|
import shouldShowWidget from "./helpers/shouldShowWidget";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
const WIDGET_GRID_TYPE = '@shopgate/commerce-widgets/widget-grid';
|
|
8
10
|
const GRID_COLUMNS = 12; // One grid row has 12 columns. // TODO: is it deprecated since css grid?
|
|
9
11
|
|
|
@@ -23,23 +25,26 @@ const createGridWrapper = (key, config, components) => (/*#__PURE__*/React.creat
|
|
|
23
25
|
/**
|
|
24
26
|
* The widgets component.
|
|
25
27
|
*/
|
|
26
|
-
|
|
28
|
+
let Widgets = /*#__PURE__*/function (_Component) {
|
|
27
29
|
/**
|
|
28
30
|
* @param {Object} props The component props.
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
32
|
+
function Widgets(props) {
|
|
33
|
+
var _this;
|
|
34
|
+
_this = _Component.call(this, props) || this;
|
|
35
|
+
if (_this.hasSchedulableWidgets()) {
|
|
36
|
+
_this.startAutoRerender();
|
|
35
37
|
}
|
|
38
|
+
return _this;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* @param {Object} nextProps The next component props.
|
|
40
43
|
* @return {JSX}
|
|
41
44
|
*/
|
|
42
|
-
|
|
45
|
+
_inheritsLoose(Widgets, _Component);
|
|
46
|
+
var _proto = Widgets.prototype;
|
|
47
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
43
48
|
if (!isEqual(this.props.themeWidgets, nextProps.themeWidgets)) {
|
|
44
49
|
return true;
|
|
45
50
|
}
|
|
@@ -51,8 +56,8 @@ class Widgets extends Component {
|
|
|
51
56
|
|
|
52
57
|
/**
|
|
53
58
|
* Component will unmount lifecycle method.
|
|
54
|
-
|
|
55
|
-
componentWillUnmount() {
|
|
59
|
+
*/;
|
|
60
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
56
61
|
this.stopAutoRerender();
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -60,15 +65,15 @@ class Widgets extends Component {
|
|
|
60
65
|
* Checks if any widget is schedulable.
|
|
61
66
|
* @param {Array} widgets Array of widgets.
|
|
62
67
|
* @returns {boolean}
|
|
63
|
-
|
|
64
|
-
hasSchedulableWidgets() {
|
|
68
|
+
*/;
|
|
69
|
+
_proto.hasSchedulableWidgets = function hasSchedulableWidgets() {
|
|
65
70
|
return (this.props.widgets || []).some(widget => widget.settings.plan);
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
/**
|
|
69
74
|
* Sets auto re-render.
|
|
70
|
-
|
|
71
|
-
startAutoRerender() {
|
|
75
|
+
*/;
|
|
76
|
+
_proto.startAutoRerender = function startAutoRerender() {
|
|
72
77
|
const minutesToRoundedHour = 60 - new Date().getMinutes();
|
|
73
78
|
const nextRerenderIn = minutesToRoundedHour * 60000;
|
|
74
79
|
this.autoReloadTimeout = setTimeout(() => this.doAutoRerender(), nextRerenderIn);
|
|
@@ -77,15 +82,15 @@ class Widgets extends Component {
|
|
|
77
82
|
/**
|
|
78
83
|
* Stops auto re-render. Must be called before component is unmounted to avoid
|
|
79
84
|
* memory leak.
|
|
80
|
-
|
|
81
|
-
stopAutoRerender() {
|
|
85
|
+
*/;
|
|
86
|
+
_proto.stopAutoRerender = function stopAutoRerender() {
|
|
82
87
|
clearTimeout(this.autoReloadTimeout);
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
/**
|
|
86
91
|
* Forces re-render and sets another timeout for next cycle.
|
|
87
|
-
|
|
88
|
-
doAutoRerender() {
|
|
92
|
+
*/;
|
|
93
|
+
_proto.doAutoRerender = function doAutoRerender() {
|
|
89
94
|
this.forceUpdate();
|
|
90
95
|
this.startAutoRerender();
|
|
91
96
|
}
|
|
@@ -93,8 +98,8 @@ class Widgets extends Component {
|
|
|
93
98
|
/**
|
|
94
99
|
* Create array of elements from widget configuration.
|
|
95
100
|
* @returns {Array} Array of JSX elements.
|
|
96
|
-
|
|
97
|
-
createArrayOfElements() {
|
|
101
|
+
*/;
|
|
102
|
+
_proto.createArrayOfElements = function createArrayOfElements() {
|
|
98
103
|
const {
|
|
99
104
|
widgets = [],
|
|
100
105
|
themeWidgets: components
|
|
@@ -128,8 +133,8 @@ class Widgets extends Component {
|
|
|
128
133
|
|
|
129
134
|
/**
|
|
130
135
|
* @return {JSX}
|
|
131
|
-
|
|
132
|
-
render() {
|
|
136
|
+
*/;
|
|
137
|
+
_proto.render = function render() {
|
|
133
138
|
const {
|
|
134
139
|
widgets,
|
|
135
140
|
themeWidgets: components
|
|
@@ -137,11 +142,13 @@ class Widgets extends Component {
|
|
|
137
142
|
if (!widgets) {
|
|
138
143
|
return null;
|
|
139
144
|
}
|
|
140
|
-
return /*#__PURE__*/
|
|
141
|
-
className: "common__widgets"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
+
return /*#__PURE__*/_jsx("div", {
|
|
146
|
+
className: "common__widgets",
|
|
147
|
+
children: this.createArrayOfElements(widgets, components)
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
return Widgets;
|
|
151
|
+
}(Component);
|
|
145
152
|
Widgets.defaultProps = {
|
|
146
153
|
widgets: null
|
|
147
154
|
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import { ThemeResourcesProvider } from '@shopgate/engage/core/providers';
|
|
4
4
|
import Widgets from "./index";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
jest.useFakeTimers();
|
|
6
7
|
jest.mock('@shopgate/pwa-common/context', () => ({
|
|
7
8
|
ThemeContext: {
|
|
@@ -15,7 +16,7 @@ jest.mock('@shopgate/pwa-common/context', () => ({
|
|
|
15
16
|
* A mock Image component.
|
|
16
17
|
* @returns {JSX}
|
|
17
18
|
*/
|
|
18
|
-
const Image = () => /*#__PURE__*/
|
|
19
|
+
const Image = () => /*#__PURE__*/_jsx("img", {
|
|
19
20
|
alt: ""
|
|
20
21
|
});
|
|
21
22
|
/* eslint-disable react/prop-types */
|
|
@@ -26,9 +27,10 @@ const Image = () => /*#__PURE__*/React.createElement("img", {
|
|
|
26
27
|
*/
|
|
27
28
|
const WidgetGrid = ({
|
|
28
29
|
children
|
|
29
|
-
}) => /*#__PURE__*/
|
|
30
|
-
className: "widget-grid"
|
|
31
|
-
|
|
30
|
+
}) => /*#__PURE__*/_jsx("div", {
|
|
31
|
+
className: "widget-grid",
|
|
32
|
+
children: children
|
|
33
|
+
});
|
|
32
34
|
/* eslint-enable react/prop-types */
|
|
33
35
|
|
|
34
36
|
const components = {
|
|
@@ -42,12 +44,13 @@ const components = {
|
|
|
42
44
|
* @param {Object[]} widgets Widgets to be rendered.
|
|
43
45
|
* @returns {JSX.Element}
|
|
44
46
|
*/
|
|
45
|
-
const createWrapper = widgets => mount(/*#__PURE__*/
|
|
47
|
+
const createWrapper = widgets => mount(/*#__PURE__*/_jsx(ThemeResourcesProvider, {
|
|
46
48
|
widgets: components,
|
|
47
|
-
components: {}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})
|
|
49
|
+
components: {},
|
|
50
|
+
children: /*#__PURE__*/_jsx(Widgets, {
|
|
51
|
+
widgets: widgets
|
|
52
|
+
})
|
|
53
|
+
}));
|
|
51
54
|
describe('<Widgets />', () => {
|
|
52
55
|
it('should render a grid if height is defined', () => {
|
|
53
56
|
const widgets = [{
|
|
@@ -137,11 +140,15 @@ describe('<Widgets />', () => {
|
|
|
137
140
|
expect(wrapper.find('img').length).toBe(1);
|
|
138
141
|
});
|
|
139
142
|
it('should schedule a re-render when widget is scheduled', () => {
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
// Use a fixed point in time so "next full hour" is deterministic.
|
|
144
|
+
// Pick a time that's not exactly on the hour.
|
|
145
|
+
const base = new Date('2023-01-01T10:37:00.000Z');
|
|
146
|
+
jest.setSystemTime(base);
|
|
147
|
+
const minutesToNextFullHour = 60 - base.getMinutes(); // 23
|
|
148
|
+
const msToNextFullHour = minutesToNextFullHour * 60000; // 23 * 60_000
|
|
149
|
+
|
|
142
150
|
const scheduledFromMs = Date.now() + msToNextFullHour - 1;
|
|
143
151
|
const scheduledToMs = Date.now() + minutesToNextFullHour + 1000;
|
|
144
|
-
/* eslint-disable camelcase */
|
|
145
152
|
const widgets = [{
|
|
146
153
|
col: 0,
|
|
147
154
|
row: 0,
|
|
@@ -158,19 +165,26 @@ describe('<Widgets />', () => {
|
|
|
158
165
|
},
|
|
159
166
|
type: '@shopgate/commerce-widgets/image'
|
|
160
167
|
}];
|
|
161
|
-
/* eslint-enable camelcase */
|
|
162
168
|
const wrapper = createWrapper(widgets);
|
|
163
169
|
const instance = wrapper.find('Widgets').instance();
|
|
170
|
+
const clearSpy = jest.spyOn(global, 'clearTimeout');
|
|
164
171
|
instance.forceUpdate = jest.fn();
|
|
172
|
+
|
|
173
|
+
// Before the schedule hits, the image should not render yet.
|
|
165
174
|
expect(wrapper.find(Image).exists()).toBe(false);
|
|
175
|
+
|
|
176
|
+
// 1) Advance to the next full hour -> first forced update.
|
|
166
177
|
jest.advanceTimersByTime(msToNextFullHour);
|
|
167
178
|
expect(instance.forceUpdate).toHaveBeenCalledTimes(1);
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
jest.advanceTimersByTime(
|
|
179
|
+
|
|
180
|
+
// 2) The component should schedule the next tick for +60 min.
|
|
181
|
+
jest.advanceTimersByTime(60 * 60000);
|
|
171
182
|
expect(instance.forceUpdate).toHaveBeenCalledTimes(2);
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
|
|
184
|
+
// Unmount triggers cleanup of any pending timeouts.
|
|
185
|
+
wrapper.unmount();
|
|
186
|
+
expect(clearSpy).toHaveBeenCalled();
|
|
187
|
+
clearSpy.mockRestore();
|
|
174
188
|
});
|
|
175
189
|
it('should render only wrapper when widgets array is empty', () => {
|
|
176
190
|
const widgets = [];
|
package/helpers/data/index.js
CHANGED
|
@@ -194,7 +194,7 @@ export const validateSelectorParams = (selector, defaultResult = null) => (...pa
|
|
|
194
194
|
if (params.some(param => param === null || typeof param === 'undefined')) {
|
|
195
195
|
return defaultResult;
|
|
196
196
|
}
|
|
197
|
-
return selector(
|
|
197
|
+
return selector.apply(void 0, params);
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
/**
|
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The portals collection.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
let PortalCollection = /*#__PURE__*/function () {
|
|
5
|
+
function PortalCollection() {}
|
|
6
|
+
var _proto = PortalCollection.prototype;
|
|
5
7
|
/**
|
|
6
8
|
* Returns the portal definitions.
|
|
7
9
|
* @return {Object}
|
|
8
10
|
*/
|
|
9
|
-
getPortals() {
|
|
11
|
+
_proto.getPortals = function getPortals() {
|
|
10
12
|
return this.portals;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Registers the portal definitions.
|
|
15
17
|
* @param {Object} [portals={}] The portals to register.
|
|
16
|
-
|
|
17
|
-
registerPortals(portals = {}) {
|
|
18
|
+
*/;
|
|
19
|
+
_proto.registerPortals = function registerPortals(portals = {}) {
|
|
18
20
|
this.portals = portals;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Registers the portal config.
|
|
23
25
|
* @param {Object} [config={}] The portals config.
|
|
24
|
-
|
|
25
|
-
registerConfig(config = {}) {
|
|
26
|
+
*/;
|
|
27
|
+
_proto.registerConfig = function registerConfig(config = {}) {
|
|
26
28
|
this.config = config;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Returns the portal config.
|
|
31
33
|
* @return {Object}
|
|
32
|
-
|
|
33
|
-
getConfig() {
|
|
34
|
+
*/;
|
|
35
|
+
_proto.getConfig = function getConfig() {
|
|
34
36
|
return this.config;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
+
};
|
|
38
|
+
return PortalCollection;
|
|
39
|
+
}();
|
|
37
40
|
export default new PortalCollection();
|
package/helpers/redux/mutable.js
CHANGED
|
@@ -88,7 +88,7 @@ export const mutable = func => {
|
|
|
88
88
|
if (steps.length > 0) {
|
|
89
89
|
mutatedArgs = steps.reduce((acc, step, i, arr) => {
|
|
90
90
|
// Call next step func in the pipeline with mutated args
|
|
91
|
-
let res = step(
|
|
91
|
+
let res = step.apply(void 0, acc);
|
|
92
92
|
|
|
93
93
|
// Keep params unchanged if the step did not perform any change action at all
|
|
94
94
|
if (!isObject(res)) {
|
|
@@ -132,7 +132,7 @@ export const mutable = func => {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// Call the actual mutable
|
|
135
|
-
return current(
|
|
135
|
+
return current.apply(void 0, mutatedArgs);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common",
|
|
3
|
-
"version": "7.30.0-
|
|
3
|
+
"version": "7.30.0-beta.1",
|
|
4
4
|
"description": "Common library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@redux-devtools/extension": "^3.3.0",
|
|
19
19
|
"@sentry/browser": "6.0.1",
|
|
20
|
-
"@shopgate/pwa-benchmark": "7.30.0-
|
|
20
|
+
"@shopgate/pwa-benchmark": "7.30.0-beta.1",
|
|
21
21
|
"@virtuous/conductor": "~2.5.0",
|
|
22
22
|
"@virtuous/react-conductor": "~2.5.0",
|
|
23
23
|
"@virtuous/redux-persister": "1.1.0-beta.7",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"gsap": "^3.6.0",
|
|
28
28
|
"history": "^4.9.0",
|
|
29
29
|
"intl-messageformat": "^7.8.3",
|
|
30
|
-
"jsdom": "11.12.0",
|
|
31
30
|
"path-match": "^1.2.4",
|
|
32
31
|
"react-dotdotdot": "~1.3.0",
|
|
33
32
|
"react-helmet": "^6.1.0",
|
|
@@ -42,11 +41,11 @@
|
|
|
42
41
|
"url-search-params": "^0.10.0"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@shopgate/pwa-core": "7.30.0-
|
|
44
|
+
"@shopgate/pwa-core": "7.30.0-beta.1",
|
|
46
45
|
"@types/react-portal": "^3.0.9",
|
|
47
46
|
"lodash": "^4.17.21",
|
|
48
47
|
"prop-types": "~15.8.1",
|
|
49
|
-
"react": "
|
|
50
|
-
"react-dom": "
|
|
48
|
+
"react": "^17.0.2",
|
|
49
|
+
"react-dom": "^17.0.2"
|
|
51
50
|
}
|
|
52
51
|
}
|