@shopgate/webpack 7.30.3-beta.1 → 7.30.3-beta.3

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 (42) hide show
  1. package/local-packages/pwa-extension-kit/src/components/ProductCharacteristics/__snapshots__/spec.jsx.snap +428 -0
  2. package/local-packages/pwa-extension-kit/src/components/ProductCharacteristics/index.jsx +7 -0
  3. package/local-packages/pwa-extension-kit/src/components/ProductCharacteristics/spec.jsx +128 -0
  4. package/local-packages/pwa-extension-kit/src/components/README.md +38 -0
  5. package/local-packages/pwa-extension-kit/src/components/index.js +8 -0
  6. package/local-packages/pwa-extension-kit/src/components/index.spec.js +11 -0
  7. package/local-packages/pwa-extension-kit/src/connectors/README.md +222 -0
  8. package/local-packages/pwa-extension-kit/src/connectors/index.js +23 -0
  9. package/local-packages/pwa-extension-kit/src/connectors/index.spec.js +29 -0
  10. package/local-packages/pwa-extension-kit/src/connectors/selectors/user.js +24 -0
  11. package/local-packages/pwa-extension-kit/src/connectors/withHistoryActions.jsx +75 -0
  12. package/local-packages/pwa-extension-kit/src/connectors/withHistoryActions.spec.jsx +72 -0
  13. package/local-packages/pwa-extension-kit/src/connectors/withPageProductId.jsx +61 -0
  14. package/local-packages/pwa-extension-kit/src/connectors/withPageProductId.spec.jsx +73 -0
  15. package/local-packages/pwa-extension-kit/src/connectors/withPageState.jsx +49 -0
  16. package/local-packages/pwa-extension-kit/src/connectors/withPageState.spec.jsx +59 -0
  17. package/local-packages/pwa-extension-kit/src/connectors/withProductContext.jsx +38 -0
  18. package/local-packages/pwa-extension-kit/src/connectors/withProductContext.spec.jsx +55 -0
  19. package/local-packages/pwa-extension-kit/src/connectors/withThemeComponents.jsx +37 -0
  20. package/local-packages/pwa-extension-kit/src/connectors/withThemeComponents.spec.jsx +43 -0
  21. package/local-packages/pwa-extension-kit/src/connectors/withUser.jsx +61 -0
  22. package/local-packages/pwa-extension-kit/src/connectors/withUser.spec.jsx +101 -0
  23. package/local-packages/pwa-extension-kit/src/env/README.md +28 -0
  24. package/local-packages/pwa-extension-kit/src/env/helpers/index.js +7 -0
  25. package/local-packages/pwa-extension-kit/src/env/helpers/index.spec.js +12 -0
  26. package/local-packages/pwa-extension-kit/src/env/helpers/isIOSTheme.js +10 -0
  27. package/local-packages/pwa-extension-kit/src/env/helpers/isIOSTheme.spec.js +16 -0
  28. package/local-packages/pwa-extension-kit/src/env/index.js +7 -0
  29. package/local-packages/pwa-extension-kit/src/env/index.spec.js +13 -0
  30. package/local-packages/pwa-extension-kit/src/helpers/README.md +30 -0
  31. package/local-packages/pwa-extension-kit/src/helpers/TaggedLogger.js +50 -0
  32. package/local-packages/pwa-extension-kit/src/helpers/TaggedLogger.spec.js +41 -0
  33. package/local-packages/pwa-extension-kit/src/helpers/_getConsole.js +4 -0
  34. package/local-packages/pwa-extension-kit/src/helpers/index.js +7 -0
  35. package/local-packages/pwa-extension-kit/src/helpers/index.spec.js +12 -0
  36. package/local-packages/pwa-extension-kit/src/index.js +16 -0
  37. package/local-packages/pwa-extension-kit/src/index.spec.js +16 -0
  38. package/local-packages/pwa-extension-kit/src/proptypes/README.md +9 -0
  39. package/local-packages/pwa-extension-kit/src/proptypes/User.js +15 -0
  40. package/local-packages/pwa-extension-kit/src/proptypes/index.js +7 -0
  41. package/package.json +1 -1
  42. package/webpack.config.js +7 -15
@@ -0,0 +1,428 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`components/ProductCharacteristics should render 1`] = `
4
+ <Component
5
+ render={
6
+ [MockFunction] {
7
+ "calls": Array [
8
+ Array [
9
+ Object {
10
+ "charRef": Object {
11
+ "current": null,
12
+ },
13
+ "disabled": false,
14
+ "highlight": false,
15
+ "id": "1",
16
+ "key": "1",
17
+ "label": "Color",
18
+ "select": [Function],
19
+ "selected": null,
20
+ "values": Array [
21
+ Object {
22
+ "id": "1",
23
+ "label": "BLACK-WHITE (9000)",
24
+ "selectable": true,
25
+ },
26
+ Object {
27
+ "id": "2",
28
+ "label": "RED-WHITE (1000)",
29
+ "selectable": true,
30
+ },
31
+ ],
32
+ },
33
+ ],
34
+ Array [
35
+ Object {
36
+ "charRef": Object {
37
+ "current": null,
38
+ },
39
+ "disabled": true,
40
+ "highlight": false,
41
+ "id": "2",
42
+ "key": "2",
43
+ "label": "Size",
44
+ "select": [Function],
45
+ "selected": null,
46
+ "values": Array [
47
+ Object {
48
+ "id": "11",
49
+ "label": "7",
50
+ "selectable": true,
51
+ },
52
+ Object {
53
+ "id": "12",
54
+ "label": "7.5",
55
+ "selectable": true,
56
+ },
57
+ ],
58
+ },
59
+ ],
60
+ ],
61
+ "results": undefined,
62
+ }
63
+ }
64
+ >
65
+ <WithProductContext
66
+ WrappedComponent={[Function]}
67
+ render={
68
+ [MockFunction] {
69
+ "calls": Array [
70
+ Array [
71
+ Object {
72
+ "charRef": Object {
73
+ "current": null,
74
+ },
75
+ "disabled": false,
76
+ "highlight": false,
77
+ "id": "1",
78
+ "key": "1",
79
+ "label": "Color",
80
+ "select": [Function],
81
+ "selected": null,
82
+ "values": Array [
83
+ Object {
84
+ "id": "1",
85
+ "label": "BLACK-WHITE (9000)",
86
+ "selectable": true,
87
+ },
88
+ Object {
89
+ "id": "2",
90
+ "label": "RED-WHITE (1000)",
91
+ "selectable": true,
92
+ },
93
+ ],
94
+ },
95
+ ],
96
+ Array [
97
+ Object {
98
+ "charRef": Object {
99
+ "current": null,
100
+ },
101
+ "disabled": true,
102
+ "highlight": false,
103
+ "id": "2",
104
+ "key": "2",
105
+ "label": "Size",
106
+ "select": [Function],
107
+ "selected": null,
108
+ "values": Array [
109
+ Object {
110
+ "id": "11",
111
+ "label": "7",
112
+ "selectable": true,
113
+ },
114
+ Object {
115
+ "id": "12",
116
+ "label": "7.5",
117
+ "selectable": true,
118
+ },
119
+ ],
120
+ },
121
+ ],
122
+ ],
123
+ "results": undefined,
124
+ }
125
+ }
126
+ >
127
+ <Theme>
128
+ <Component
129
+ AppBar={[Function]}
130
+ Drawer={[Function]}
131
+ View={[Function]}
132
+ contexts={
133
+ Object {
134
+ "ProductContext": Object {
135
+ "Consumer": [Function],
136
+ },
137
+ }
138
+ }
139
+ >
140
+ <Consumer>
141
+ <Component
142
+ conditioner={
143
+ Conditioner {
144
+ "conditioners": Map {
145
+ "product-variants" => [Function],
146
+ },
147
+ }
148
+ }
149
+ options={Object {}}
150
+ productId="123"
151
+ variantId="123-45"
152
+ >
153
+ <Component
154
+ productContext={
155
+ Object {
156
+ "conditioner": Conditioner {
157
+ "conditioners": Map {
158
+ "product-variants" => [Function],
159
+ },
160
+ },
161
+ "options": Object {},
162
+ "productId": "123",
163
+ "variantId": "123-45",
164
+ }
165
+ }
166
+ render={
167
+ [MockFunction] {
168
+ "calls": Array [
169
+ Array [
170
+ Object {
171
+ "charRef": Object {
172
+ "current": null,
173
+ },
174
+ "disabled": false,
175
+ "highlight": false,
176
+ "id": "1",
177
+ "key": "1",
178
+ "label": "Color",
179
+ "select": [Function],
180
+ "selected": null,
181
+ "values": Array [
182
+ Object {
183
+ "id": "1",
184
+ "label": "BLACK-WHITE (9000)",
185
+ "selectable": true,
186
+ },
187
+ Object {
188
+ "id": "2",
189
+ "label": "RED-WHITE (1000)",
190
+ "selectable": true,
191
+ },
192
+ ],
193
+ },
194
+ ],
195
+ Array [
196
+ Object {
197
+ "charRef": Object {
198
+ "current": null,
199
+ },
200
+ "disabled": true,
201
+ "highlight": false,
202
+ "id": "2",
203
+ "key": "2",
204
+ "label": "Size",
205
+ "select": [Function],
206
+ "selected": null,
207
+ "values": Array [
208
+ Object {
209
+ "id": "11",
210
+ "label": "7",
211
+ "selectable": true,
212
+ },
213
+ Object {
214
+ "id": "12",
215
+ "label": "7.5",
216
+ "selectable": true,
217
+ },
218
+ ],
219
+ },
220
+ ],
221
+ ],
222
+ "results": undefined,
223
+ }
224
+ }
225
+ >
226
+ <Component
227
+ conditioner={
228
+ Conditioner {
229
+ "conditioners": Map {
230
+ "product-variants" => [Function],
231
+ },
232
+ }
233
+ }
234
+ options={Object {}}
235
+ productId="123"
236
+ render={
237
+ [MockFunction] {
238
+ "calls": Array [
239
+ Array [
240
+ Object {
241
+ "charRef": Object {
242
+ "current": null,
243
+ },
244
+ "disabled": false,
245
+ "highlight": false,
246
+ "id": "1",
247
+ "key": "1",
248
+ "label": "Color",
249
+ "select": [Function],
250
+ "selected": null,
251
+ "values": Array [
252
+ Object {
253
+ "id": "1",
254
+ "label": "BLACK-WHITE (9000)",
255
+ "selectable": true,
256
+ },
257
+ Object {
258
+ "id": "2",
259
+ "label": "RED-WHITE (1000)",
260
+ "selectable": true,
261
+ },
262
+ ],
263
+ },
264
+ ],
265
+ Array [
266
+ Object {
267
+ "charRef": Object {
268
+ "current": null,
269
+ },
270
+ "disabled": true,
271
+ "highlight": false,
272
+ "id": "2",
273
+ "key": "2",
274
+ "label": "Size",
275
+ "select": [Function],
276
+ "selected": null,
277
+ "values": Array [
278
+ Object {
279
+ "id": "11",
280
+ "label": "7",
281
+ "selectable": true,
282
+ },
283
+ Object {
284
+ "id": "12",
285
+ "label": "7.5",
286
+ "selectable": true,
287
+ },
288
+ ],
289
+ },
290
+ ],
291
+ ],
292
+ "results": undefined,
293
+ }
294
+ }
295
+ variantId="123-45"
296
+ >
297
+ <ProductCharacteristics
298
+ conditioner={
299
+ Conditioner {
300
+ "conditioners": Map {
301
+ "product-variants" => [Function],
302
+ },
303
+ }
304
+ }
305
+ finishTimeout={0}
306
+ navigate={[Function]}
307
+ options={Object {}}
308
+ productId="123"
309
+ render={
310
+ [MockFunction] {
311
+ "calls": Array [
312
+ Array [
313
+ Object {
314
+ "charRef": Object {
315
+ "current": null,
316
+ },
317
+ "disabled": false,
318
+ "highlight": false,
319
+ "id": "1",
320
+ "key": "1",
321
+ "label": "Color",
322
+ "select": [Function],
323
+ "selected": null,
324
+ "values": Array [
325
+ Object {
326
+ "id": "1",
327
+ "label": "BLACK-WHITE (9000)",
328
+ "selectable": true,
329
+ },
330
+ Object {
331
+ "id": "2",
332
+ "label": "RED-WHITE (1000)",
333
+ "selectable": true,
334
+ },
335
+ ],
336
+ },
337
+ ],
338
+ Array [
339
+ Object {
340
+ "charRef": Object {
341
+ "current": null,
342
+ },
343
+ "disabled": true,
344
+ "highlight": false,
345
+ "id": "2",
346
+ "key": "2",
347
+ "label": "Size",
348
+ "select": [Function],
349
+ "selected": null,
350
+ "values": Array [
351
+ Object {
352
+ "id": "11",
353
+ "label": "7",
354
+ "selectable": true,
355
+ },
356
+ Object {
357
+ "id": "12",
358
+ "label": "7.5",
359
+ "selectable": true,
360
+ },
361
+ ],
362
+ },
363
+ ],
364
+ ],
365
+ "results": undefined,
366
+ }
367
+ }
368
+ variantId="123-45"
369
+ variants={
370
+ Object {
371
+ "characteristics": Array [
372
+ Object {
373
+ "id": "1",
374
+ "label": "Color",
375
+ "values": Array [
376
+ Object {
377
+ "id": "1",
378
+ "label": "BLACK-WHITE (9000)",
379
+ },
380
+ Object {
381
+ "id": "2",
382
+ "label": "RED-WHITE (1000)",
383
+ },
384
+ ],
385
+ },
386
+ Object {
387
+ "id": "2",
388
+ "label": "Size",
389
+ "values": Array [
390
+ Object {
391
+ "id": "11",
392
+ "label": "7",
393
+ },
394
+ Object {
395
+ "id": "12",
396
+ "label": "7.5",
397
+ },
398
+ ],
399
+ },
400
+ ],
401
+ "products": Array [
402
+ Object {
403
+ "characteristics": Object {
404
+ "1": "1",
405
+ "2": "11",
406
+ },
407
+ "id": "32050590001000",
408
+ },
409
+ Object {
410
+ "characteristics": Object {
411
+ "1": "2",
412
+ "2": "12",
413
+ },
414
+ "id": "32050590000950",
415
+ },
416
+ ],
417
+ }
418
+ }
419
+ />
420
+ </Component>
421
+ </Component>
422
+ </Component>
423
+ </Consumer>
424
+ </Component>
425
+ </Theme>
426
+ </WithProductContext>
427
+ </Component>
428
+ `;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import BaseProductCharacteristics from '@shopgate/pwa-common/components/ProductCharacteristics';
3
+ import withProductContext from '../../connectors/withProductContext';
4
+
5
+ export default withProductContext(({ productContext, ...otherProps }) => (
6
+ <BaseProductCharacteristics {...productContext} {...otherProps} />
7
+ ));
@@ -0,0 +1,128 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import Conditioner from '@shopgate/pwa-core/classes/Conditioner';
4
+ import ProductCharacteristics from './index';
5
+
6
+ const mockedConditioner = new Conditioner();
7
+ const mockedMapStateToPropsResult = {
8
+ variants: {
9
+ products: [{
10
+ id: '32050590001000',
11
+ characteristics: { 1: '1', 2: '11' },
12
+ }, {
13
+ id: '32050590000950',
14
+ characteristics: { 1: '2', 2: '12' },
15
+ }],
16
+ characteristics: [
17
+ {
18
+ id: '1',
19
+ label: 'Color',
20
+ values: [
21
+ { id: '1', label: 'BLACK-WHITE (9000)' },
22
+ { id: '2', label: 'RED-WHITE (1000)' }],
23
+ },
24
+ {
25
+ id: '2',
26
+ label: 'Size',
27
+ values: [
28
+ { id: '11', label: '7' }, { id: '12', label: '7.5' },
29
+ ],
30
+ }],
31
+ },
32
+ };
33
+ jest.mock('react-redux', () => ({
34
+ connect: mapStateToProps => Component => props => (
35
+ <Component
36
+ variants={mockedMapStateToPropsResult.variants}
37
+ {...props}
38
+ />
39
+ ),
40
+ }));
41
+
42
+ jest.mock('@shopgate/pwa-common/context', () => ({
43
+ // eslint-disable-next-line react/prop-types
44
+ Theme: ({ children, ...otherProps }) => {
45
+ const Child = children;
46
+
47
+ const props = {
48
+ AppBar: () => null,
49
+ Drawer: () => null,
50
+ View: () => null,
51
+ contexts: {
52
+ ProductContext: {
53
+ // eslint-disable-next-line react/prop-types
54
+ Consumer: ({ children: ContextChildren, ...contextProps }) => (
55
+ <ContextChildren
56
+ options={{}}
57
+ productId="123"
58
+ variantId="123-45"
59
+ conditioner={mockedConditioner}
60
+ {...contextProps}
61
+ />
62
+ ),
63
+ },
64
+ },
65
+ ...otherProps,
66
+ };
67
+
68
+ return (
69
+ <Child {...props} />
70
+ );
71
+ },
72
+ }));
73
+
74
+ describe('components/ProductCharacteristics', () => {
75
+ it('should render', () => {
76
+ const component = mount((
77
+ <ProductCharacteristics render={jest.fn()} />
78
+ ));
79
+
80
+ expect(component).toMatchSnapshot();
81
+ });
82
+
83
+ it('should call render prop', () => {
84
+ const renderer = jest.fn();
85
+
86
+ mount((
87
+ <ProductCharacteristics render={renderer} />
88
+ ));
89
+
90
+ const expected1 = {
91
+ charRef: { current: null },
92
+ disabled: false,
93
+ highlight: false,
94
+ id: '1',
95
+ key: '1',
96
+ label: 'Color',
97
+ selected: null,
98
+ values: [
99
+ { id: '1', label: 'BLACK-WHITE (9000)', selectable: true },
100
+ { id: '2', label: 'RED-WHITE (1000)', selectable: true },
101
+ ],
102
+ };
103
+
104
+ const expected2 = {
105
+ charRef: { current: null },
106
+ disabled: true,
107
+ highlight: false,
108
+ id: '2',
109
+ key: '2',
110
+ label: 'Size',
111
+ selected: null,
112
+ values: [
113
+ { id: '11', label: '7', selectable: true },
114
+ { id: '12', label: '7.5', selectable: true },
115
+ ],
116
+ };
117
+
118
+ expect(renderer).toHaveBeenCalledTimes(2);
119
+
120
+ const args1 = renderer.mock.calls[0][0];
121
+ expect(typeof args1.select).toBe('function');
122
+ expect(args1).toMatchObject(expected1);
123
+
124
+ const args2 = renderer.mock.calls[1][0];
125
+ expect(typeof args2.select).toBe('function');
126
+ expect(args2).toMatchObject(expected2);
127
+ });
128
+ });
@@ -0,0 +1,38 @@
1
+ # Shopgate Connect - PWA Extension Kit - /components - Common Components
2
+ ## Purpose
3
+
4
+ ## Available components
5
+ ### ProductCharacteristics
6
+ Component that can be used to change the UI of the characteristics/variant selection
7
+
8
+ #### Possible usage
9
+ Everywhere as a React component rendered within the PWA app.
10
+
11
+ #### Props
12
+ - `render (function)` - Render Prop [read documentation](https://reactjs.org/docs/render-props.html)
13
+ - `disabled (bool)` - Characteristic should not be clickable
14
+ - `highlight (bool)` - Info if the current characteristic should be highlighted because it's the first unselected one
15
+ - `select (function)` - Function that needs to be called to select a new value
16
+ - `selected (string)` - Current selected characteristic
17
+ - `id (string)` - Id of the characteristics
18
+ - `label (string)` - Label of the characteristic
19
+ - `values (array)` - Values of the characteristic
20
+
21
+
22
+ #### Example usage
23
+ ```jsx
24
+ import React, { Component } from 'react'
25
+ import { ProductCharacteristics } from '@shopgate/pwa-extension-kit/components';
26
+
27
+ class MyComponent extends Component {
28
+ renderer = (props) => <CustomCharacteristics {...props} />;
29
+
30
+ render() {
31
+ return (
32
+ <ProductCharacteristics render={this.renderer}/>
33
+ );
34
+ }
35
+ }
36
+
37
+ export default MyComponent;
38
+ ```
@@ -0,0 +1,8 @@
1
+ import ProductCharacteristics from './ProductCharacteristics';
2
+
3
+ export { ProductCharacteristics };
4
+
5
+ export default {
6
+ ProductCharacteristics,
7
+ };
8
+
@@ -0,0 +1,11 @@
1
+ import components, { ProductCharacteristics } from './index';
2
+ describe('components', () => {
3
+ it('should export all functions as default', () => {
4
+ expect(typeof components).toBe('object');
5
+ expect(typeof components.ProductCharacteristics).toBe('function');
6
+ });
7
+
8
+ it('should export as named export', () => {
9
+ expect(typeof ProductCharacteristics).toBe('function');
10
+ });
11
+ });