@labdigital/commercetools-mock 0.6.5 → 0.8.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.
- package/dist/index.d.ts +409 -3
- package/dist/index.global.js +49983 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +4835 -6
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4803 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -17
- package/src/ctMock.ts +5 -0
- package/src/helpers.ts +39 -0
- package/src/lib/projectionSearchFilter.test.ts +183 -0
- package/src/lib/projectionSearchFilter.ts +347 -0
- package/src/priceSelector.test.ts +96 -0
- package/src/priceSelector.ts +109 -0
- package/src/product-projection-search.ts +345 -0
- package/src/projectAPI.ts +19 -20
- package/src/repositories/category.ts +36 -0
- package/src/repositories/channel.ts +104 -0
- package/src/repositories/customer-group.ts +37 -0
- package/src/repositories/discount-code.ts +37 -0
- package/src/repositories/helpers.ts +46 -4
- package/src/repositories/product-discount.ts +181 -0
- package/src/repositories/product-projection.ts +30 -59
- package/src/repositories/product-type.ts +88 -6
- package/src/repositories/product.ts +49 -9
- package/src/repositories/shipping-method.ts +31 -0
- package/src/repositories/store.ts +43 -3
- package/src/repositories/type.ts +19 -0
- package/src/services/custom-object.test.ts +2 -2
- package/src/services/product-discount.ts +33 -0
- package/src/services/product-projection.test.ts +329 -107
- package/src/services/product.test.ts +12 -0
- package/src/storage.ts +116 -58
- package/src/types.ts +9 -2
- package/dist/commercetools-mock.cjs.development.js +0 -4382
- package/dist/commercetools-mock.cjs.development.js.map +0 -1
- package/dist/commercetools-mock.cjs.production.min.js +0 -2
- package/dist/commercetools-mock.cjs.production.min.js.map +0 -1
- package/dist/commercetools-mock.esm.js +0 -4374
- package/dist/commercetools-mock.esm.js.map +0 -1
- package/dist/constants.d.ts +0 -2
- package/dist/ctMock.d.ts +0 -32
- package/dist/exceptions.d.ts +0 -12
- package/dist/helpers.d.ts +0 -6
- package/dist/lib/expandParser.d.ts +0 -15
- package/dist/lib/filterParser.d.ts +0 -1
- package/dist/lib/haversine.d.ts +0 -8
- package/dist/lib/masking.d.ts +0 -1
- package/dist/lib/predicateParser.d.ts +0 -11
- package/dist/lib/proxy.d.ts +0 -1
- package/dist/oauth/errors.d.ts +0 -8
- package/dist/oauth/helpers.d.ts +0 -2
- package/dist/oauth/server.d.ts +0 -12
- package/dist/oauth/store.d.ts +0 -14
- package/dist/projectAPI.d.ts +0 -12
- package/dist/repositories/abstract.d.ts +0 -33
- package/dist/repositories/cart-discount.d.ts +0 -9
- package/dist/repositories/cart.d.ts +0 -21
- package/dist/repositories/category.d.ts +0 -18
- package/dist/repositories/channel.d.ts +0 -6
- package/dist/repositories/custom-object.d.ts +0 -8
- package/dist/repositories/customer-group.d.ts +0 -11
- package/dist/repositories/customer.d.ts +0 -11
- package/dist/repositories/discount-code.d.ts +0 -8
- package/dist/repositories/errors.d.ts +0 -2
- package/dist/repositories/extension.d.ts +0 -8
- package/dist/repositories/helpers.d.ts +0 -10
- package/dist/repositories/inventory-entry.d.ts +0 -14
- package/dist/repositories/my-order.d.ts +0 -6
- package/dist/repositories/order.d.ts +0 -26
- package/dist/repositories/payment.d.ts +0 -23
- package/dist/repositories/product-projection.d.ts +0 -10
- package/dist/repositories/product-type.d.ts +0 -10
- package/dist/repositories/product.d.ts +0 -11
- package/dist/repositories/project.d.ts +0 -8
- package/dist/repositories/shipping-method.d.ts +0 -10
- package/dist/repositories/shopping-list.d.ts +0 -6
- package/dist/repositories/state.d.ts +0 -8
- package/dist/repositories/store.d.ts +0 -10
- package/dist/repositories/subscription.d.ts +0 -6
- package/dist/repositories/tax-category.d.ts +0 -10
- package/dist/repositories/type.d.ts +0 -8
- package/dist/repositories/zone.d.ts +0 -8
- package/dist/server.d.ts +0 -1
- package/dist/services/abstract.d.ts +0 -20
- package/dist/services/cart-discount.d.ts +0 -9
- package/dist/services/cart.d.ts +0 -12
- package/dist/services/category.d.ts +0 -9
- package/dist/services/channel.d.ts +0 -9
- package/dist/services/custom-object.d.ts +0 -13
- package/dist/services/customer-group.d.ts +0 -9
- package/dist/services/customer.d.ts +0 -10
- package/dist/services/discount-code.d.ts +0 -9
- package/dist/services/extension.d.ts +0 -9
- package/dist/services/inventory-entry.d.ts +0 -9
- package/dist/services/my-cart.d.ts +0 -11
- package/dist/services/my-customer.d.ts +0 -13
- package/dist/services/my-order.d.ts +0 -10
- package/dist/services/my-payment.d.ts +0 -9
- package/dist/services/order.d.ts +0 -12
- package/dist/services/payment.d.ts +0 -9
- package/dist/services/product-projection.d.ts +0 -11
- package/dist/services/product-type.d.ts +0 -11
- package/dist/services/product.d.ts +0 -9
- package/dist/services/project.d.ts +0 -11
- package/dist/services/shipping-method.d.ts +0 -10
- package/dist/services/shopping-list.d.ts +0 -9
- package/dist/services/state.d.ts +0 -9
- package/dist/services/store.d.ts +0 -11
- package/dist/services/subscription.d.ts +0 -9
- package/dist/services/tax-category.d.ts +0 -11
- package/dist/services/type.d.ts +0 -9
- package/dist/services/zone.d.ts +0 -9
- package/dist/storage.d.ts +0 -56
- package/dist/types.d.ts +0 -89
- package/dist/validate.d.ts +0 -7482
- package/src/lib/filterParser.test.ts +0 -15
- package/src/lib/filterParser.ts +0 -17
|
@@ -1,167 +1,389 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ProductDraft,
|
|
3
|
+
ProductProjection,
|
|
4
|
+
ProductProjectionPagedSearchResponse,
|
|
5
|
+
ProductType,
|
|
6
|
+
ProductTypeDraft,
|
|
7
|
+
} from '@commercetools/platform-sdk'
|
|
2
8
|
import supertest from 'supertest'
|
|
9
|
+
import * as timekeeper from 'timekeeper'
|
|
3
10
|
import { CommercetoolsMock } from '../index'
|
|
4
|
-
import
|
|
11
|
+
import { Writable } from 'types'
|
|
5
12
|
|
|
6
13
|
const ctMock = new CommercetoolsMock()
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
let productType: ProductType
|
|
16
|
+
let productProjection: ProductProjection
|
|
17
|
+
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
timekeeper.freeze(new Date('2022-07-22T13:31:49.840Z'))
|
|
20
|
+
|
|
21
|
+
// Create the product type
|
|
22
|
+
{
|
|
23
|
+
const draft: ProductTypeDraft = {
|
|
24
|
+
name: 'Default Product Type',
|
|
25
|
+
description: 'Product type for testing',
|
|
26
|
+
}
|
|
27
|
+
const response = await supertest(ctMock.app)
|
|
28
|
+
.post('/dummy/product-types')
|
|
29
|
+
.send(draft)
|
|
12
30
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
expect(response.ok).toBe(true)
|
|
32
|
+
productType = response.body
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Create the product
|
|
36
|
+
{
|
|
37
|
+
const productDraft: Writable<ProductDraft> = {
|
|
38
|
+
publish: true,
|
|
39
|
+
key: 'my-product-key',
|
|
16
40
|
masterVariant: {
|
|
17
|
-
sku: '
|
|
41
|
+
sku: 'my-sku',
|
|
42
|
+
prices: [
|
|
43
|
+
{
|
|
44
|
+
value: {
|
|
45
|
+
currencyCode: 'EUR',
|
|
46
|
+
centAmount: 1789,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
attributes: [
|
|
51
|
+
{
|
|
52
|
+
name: 'number',
|
|
53
|
+
value: 4 as any,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
18
56
|
},
|
|
57
|
+
variants: [
|
|
58
|
+
{
|
|
59
|
+
sku: 'my-other-sku',
|
|
60
|
+
prices: [
|
|
61
|
+
{
|
|
62
|
+
value: {
|
|
63
|
+
currencyCode: 'EUR',
|
|
64
|
+
centAmount: 91789,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
attributes: [
|
|
69
|
+
{
|
|
70
|
+
name: 'number',
|
|
71
|
+
value: 50 as any,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
19
76
|
name: {
|
|
20
77
|
'nl-NL': 'test product',
|
|
21
78
|
},
|
|
22
79
|
productType: {
|
|
23
80
|
typeId: 'product-type',
|
|
24
|
-
id:
|
|
81
|
+
id: productType.id,
|
|
25
82
|
},
|
|
26
83
|
slug: {
|
|
27
84
|
'nl-NL': 'test-product',
|
|
28
85
|
},
|
|
29
86
|
}
|
|
87
|
+
|
|
30
88
|
const response = await supertest(ctMock.app)
|
|
31
|
-
.post('/dummy/
|
|
32
|
-
.send(
|
|
89
|
+
.post('/dummy/products')
|
|
90
|
+
.send(productDraft)
|
|
91
|
+
expect(response.ok).toBe(true)
|
|
92
|
+
const product = response.body
|
|
33
93
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
lastModifiedAt:
|
|
39
|
-
name: {
|
|
40
|
-
'nl-NL': 'test product',
|
|
41
|
-
},
|
|
42
|
-
slug: {
|
|
43
|
-
'nl-NL': 'test-product',
|
|
44
|
-
},
|
|
45
|
-
categories: [],
|
|
94
|
+
// Create the expected ProductProjection object
|
|
95
|
+
productProjection = {
|
|
96
|
+
id: product.id,
|
|
97
|
+
createdAt: '2022-07-22T13:31:49.840Z',
|
|
98
|
+
lastModifiedAt: '2022-07-22T13:31:49.840Z',
|
|
46
99
|
version: 1,
|
|
47
100
|
masterVariant: {
|
|
48
|
-
id:
|
|
49
|
-
sku: '
|
|
101
|
+
id: 1,
|
|
102
|
+
sku: 'my-sku',
|
|
103
|
+
prices: [
|
|
104
|
+
{
|
|
105
|
+
id: product.masterData.current.masterVariant.prices[0].id,
|
|
106
|
+
value: {
|
|
107
|
+
type: 'centPrecision',
|
|
108
|
+
currencyCode: 'EUR',
|
|
109
|
+
centAmount: 1789,
|
|
110
|
+
fractionDigits: 2,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
assets: [],
|
|
115
|
+
images: [],
|
|
116
|
+
attributes: productDraft.masterVariant?.attributes,
|
|
50
117
|
},
|
|
118
|
+
variants: [
|
|
119
|
+
{
|
|
120
|
+
id: 2,
|
|
121
|
+
sku: 'my-other-sku',
|
|
122
|
+
prices: [
|
|
123
|
+
{
|
|
124
|
+
id: product.masterData.current.variants[0].prices[0].id,
|
|
125
|
+
value: {
|
|
126
|
+
type: 'centPrecision',
|
|
127
|
+
currencyCode: 'EUR',
|
|
128
|
+
centAmount: 91789,
|
|
129
|
+
fractionDigits: 2,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
assets: [],
|
|
134
|
+
images: [],
|
|
135
|
+
attributes: productDraft.variants![0].attributes,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
name: productDraft.name,
|
|
139
|
+
slug: productDraft.slug,
|
|
140
|
+
categories: [],
|
|
51
141
|
productType: {
|
|
52
|
-
id: 'some-uuid',
|
|
53
142
|
typeId: 'product-type',
|
|
143
|
+
id: productType.id,
|
|
54
144
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
afterEach(async () => {
|
|
150
|
+
timekeeper.reset()
|
|
58
151
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
152
|
+
const response = await supertest(ctMock.app)
|
|
153
|
+
.delete(`/dummy/products/${productProjection.id}`)
|
|
154
|
+
.send()
|
|
155
|
+
expect(response.ok).toBe(true)
|
|
156
|
+
const product = response.body
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
// Test the general product projection implementation
|
|
160
|
+
describe('Product Projection Search - Generic', () => {
|
|
161
|
+
test('Pagination', async () => {
|
|
162
|
+
{
|
|
163
|
+
const response = await supertest(ctMock.app)
|
|
164
|
+
.get('/dummy/product-projections/search')
|
|
165
|
+
.query({
|
|
166
|
+
limit: 50,
|
|
64
167
|
})
|
|
65
|
-
|
|
168
|
+
|
|
169
|
+
const result: ProductProjectionPagedSearchResponse = response.body
|
|
170
|
+
expect(result).toEqual({
|
|
171
|
+
count: 1,
|
|
172
|
+
limit: 50,
|
|
173
|
+
offset: 0,
|
|
174
|
+
total: 1,
|
|
175
|
+
facets: {},
|
|
176
|
+
results: [productProjection],
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
{
|
|
180
|
+
const response = await supertest(ctMock.app)
|
|
181
|
+
.get('/dummy/product-projections/search')
|
|
182
|
+
.query({
|
|
183
|
+
limit: 50,
|
|
184
|
+
offset: 50,
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
const projection: ProductProjection = response.body
|
|
188
|
+
expect(projection).toEqual({
|
|
189
|
+
count: 1,
|
|
190
|
+
limit: 50,
|
|
191
|
+
offset: 50,
|
|
192
|
+
total: 0,
|
|
193
|
+
facets: {},
|
|
194
|
+
results: [],
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
test('Get 404 when not found by key with expand', async () => {
|
|
200
|
+
const response = await supertest(ctMock.app)
|
|
201
|
+
.get('/dummy/product-projections/key=DOESNOTEXIST')
|
|
202
|
+
.query({
|
|
203
|
+
expand: ['categories[*]'],
|
|
204
|
+
})
|
|
66
205
|
|
|
67
206
|
expect(response.status).toBe(404)
|
|
68
207
|
})
|
|
69
208
|
})
|
|
70
209
|
|
|
71
|
-
describe('Product Projection Search', () => {
|
|
72
|
-
|
|
73
|
-
ctMock.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
210
|
+
describe('Product Projection Search - Filters', () => {
|
|
211
|
+
test('variants.sku', async () => {
|
|
212
|
+
const response = await supertest(ctMock.app)
|
|
213
|
+
.get('/dummy/product-projections/search')
|
|
214
|
+
.query({
|
|
215
|
+
filter: ['variants.sku:"my-sku"'],
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
const result: ProductProjectionPagedSearchResponse = response.body
|
|
219
|
+
expect(result).toMatchObject({
|
|
220
|
+
count: 1,
|
|
221
|
+
results: [
|
|
222
|
+
{
|
|
223
|
+
masterVariant: { sku: 'my-sku' },
|
|
224
|
+
},
|
|
225
|
+
],
|
|
87
226
|
})
|
|
88
227
|
})
|
|
89
228
|
|
|
90
|
-
test('
|
|
91
|
-
const response = await supertest(ctMock.app)
|
|
92
|
-
'/dummy/product-projections/search
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
229
|
+
test('variants.attributes.range - match', async () => {
|
|
230
|
+
const response = await supertest(ctMock.app)
|
|
231
|
+
.get('/dummy/product-projections/search')
|
|
232
|
+
.query({
|
|
233
|
+
filter: ['variants.attributes.number:range(0 TO 10)'],
|
|
234
|
+
})
|
|
97
235
|
|
|
98
|
-
const
|
|
99
|
-
expect(
|
|
236
|
+
const result: ProductProjectionPagedSearchResponse = response.body
|
|
237
|
+
expect(result).toMatchObject({
|
|
100
238
|
count: 1,
|
|
101
|
-
limit: 20,
|
|
102
|
-
offset: 0,
|
|
103
|
-
total: 1,
|
|
104
239
|
results: [
|
|
105
240
|
{
|
|
106
|
-
|
|
107
|
-
createdAt: '',
|
|
108
|
-
id: '',
|
|
109
|
-
lastModifiedAt: '',
|
|
110
|
-
masterVariant: { id: 1, sku: '1337' },
|
|
111
|
-
name: { 'nl-NL': 'test-prod' },
|
|
112
|
-
productType: { id: 'fake', typeId: 'product-type' },
|
|
113
|
-
slug: {},
|
|
114
|
-
variants: [],
|
|
115
|
-
version: 1,
|
|
241
|
+
masterVariant: { sku: 'my-sku' },
|
|
116
242
|
},
|
|
117
243
|
],
|
|
118
244
|
})
|
|
119
245
|
})
|
|
120
246
|
|
|
121
|
-
test('
|
|
122
|
-
const response = await supertest(ctMock.app)
|
|
123
|
-
'/dummy/product-projections/search
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
offset: 100,
|
|
128
|
-
})
|
|
129
|
-
)
|
|
247
|
+
test('variants.attributes.range - mismatch', async () => {
|
|
248
|
+
const response = await supertest(ctMock.app)
|
|
249
|
+
.get('/dummy/product-projections/search')
|
|
250
|
+
.query({
|
|
251
|
+
filter: ['variants.attributes.number:range(5 TO 10)'],
|
|
252
|
+
})
|
|
130
253
|
|
|
131
|
-
const
|
|
132
|
-
expect(
|
|
133
|
-
count:
|
|
134
|
-
limit: 50,
|
|
135
|
-
offset: 100,
|
|
136
|
-
total: 0,
|
|
254
|
+
const result: ProductProjectionPagedSearchResponse = response.body
|
|
255
|
+
expect(result).toMatchObject({
|
|
256
|
+
count: 0,
|
|
137
257
|
results: [],
|
|
138
258
|
})
|
|
139
259
|
})
|
|
260
|
+
})
|
|
140
261
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
262
|
+
describe('Product Projection Search - Facets', () => {
|
|
263
|
+
test('termExpr - variants.attributes.number', async () => {
|
|
264
|
+
const response = await supertest(ctMock.app)
|
|
265
|
+
.get('/dummy/product-projections/search')
|
|
266
|
+
.query({
|
|
267
|
+
facet: ['variants.attributes.number'],
|
|
268
|
+
})
|
|
148
269
|
|
|
149
|
-
const
|
|
150
|
-
expect(
|
|
270
|
+
const result: ProductProjectionPagedSearchResponse = response.body
|
|
271
|
+
expect(result).toMatchObject({
|
|
151
272
|
count: 1,
|
|
152
|
-
|
|
273
|
+
facets: {
|
|
274
|
+
'variants.attributes.number': {
|
|
275
|
+
type: 'terms',
|
|
276
|
+
dataType: 'text',
|
|
277
|
+
missing: 0,
|
|
278
|
+
total: 2,
|
|
279
|
+
terms: [
|
|
280
|
+
{
|
|
281
|
+
term: '4.0',
|
|
282
|
+
count: 1,
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
term: '50.0',
|
|
286
|
+
count: 1,
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
results: [
|
|
292
|
+
{
|
|
293
|
+
masterVariant: { sku: 'my-sku' },
|
|
294
|
+
},
|
|
295
|
+
],
|
|
153
296
|
})
|
|
154
297
|
})
|
|
155
298
|
|
|
156
|
-
test('
|
|
157
|
-
const response = await supertest(ctMock.app)
|
|
158
|
-
'/dummy/product-projections/search'
|
|
159
|
-
|
|
299
|
+
test('filterExpr - variants.attributes.number', async () => {
|
|
300
|
+
const response = await supertest(ctMock.app)
|
|
301
|
+
.get('/dummy/product-projections/search')
|
|
302
|
+
.query({
|
|
303
|
+
facet: ['variants.attributes.number:3,4'],
|
|
304
|
+
})
|
|
160
305
|
|
|
161
|
-
const
|
|
162
|
-
expect(
|
|
306
|
+
const result: ProductProjectionPagedSearchResponse = response.body
|
|
307
|
+
expect(result).toMatchObject({
|
|
163
308
|
count: 1,
|
|
164
|
-
|
|
309
|
+
facets: {
|
|
310
|
+
'variants.attributes.number': {
|
|
311
|
+
type: 'filter',
|
|
312
|
+
count: 1,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
results: [
|
|
316
|
+
{
|
|
317
|
+
masterVariant: { sku: 'my-sku' },
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
test('rangeExpr - variants.attributes.number', async () => {
|
|
324
|
+
const response = await supertest(ctMock.app)
|
|
325
|
+
.get('/dummy/product-projections/search')
|
|
326
|
+
.query({
|
|
327
|
+
facet: [
|
|
328
|
+
'variants.attributes.number:range(* TO 5), (5 TO 25), (25 TO 100)',
|
|
329
|
+
],
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
const result: ProductProjectionPagedSearchResponse = response.body
|
|
333
|
+
expect(result).toMatchObject({
|
|
334
|
+
count: 1,
|
|
335
|
+
facets: {
|
|
336
|
+
'variants.attributes.number': {
|
|
337
|
+
type: 'range',
|
|
338
|
+
dataType: 'number',
|
|
339
|
+
ranges: [
|
|
340
|
+
{
|
|
341
|
+
type: 'double',
|
|
342
|
+
from: 0.0,
|
|
343
|
+
fromStr: '',
|
|
344
|
+
to: 5.0,
|
|
345
|
+
toStr: '5.0',
|
|
346
|
+
count: 1,
|
|
347
|
+
// totalCount: 1,
|
|
348
|
+
total: 4.0,
|
|
349
|
+
min: 4.0,
|
|
350
|
+
max: 4.0,
|
|
351
|
+
mean: 4.0,
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
type: 'double',
|
|
355
|
+
from: 5.0,
|
|
356
|
+
fromStr: '5.0',
|
|
357
|
+
to: 25.0,
|
|
358
|
+
toStr: '25.0',
|
|
359
|
+
count: 0,
|
|
360
|
+
// totalCount: 0,
|
|
361
|
+
total: 0.0,
|
|
362
|
+
min: 0.0,
|
|
363
|
+
max: 0.0,
|
|
364
|
+
mean: 0.0,
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
type: 'double',
|
|
368
|
+
from: 25.0,
|
|
369
|
+
fromStr: '25.0',
|
|
370
|
+
to: 100.0,
|
|
371
|
+
toStr: '100.0',
|
|
372
|
+
count: 1,
|
|
373
|
+
// totalCount: 1,
|
|
374
|
+
total: 50,
|
|
375
|
+
min: 50.0,
|
|
376
|
+
max: 50.0,
|
|
377
|
+
mean: 50.0,
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
results: [
|
|
383
|
+
{
|
|
384
|
+
masterVariant: { sku: 'my-sku' },
|
|
385
|
+
},
|
|
386
|
+
],
|
|
165
387
|
})
|
|
166
388
|
})
|
|
167
389
|
})
|
|
@@ -18,6 +18,7 @@ describe('Product', () => {
|
|
|
18
18
|
slug: {
|
|
19
19
|
'nl-NL': 'test-product',
|
|
20
20
|
},
|
|
21
|
+
masterVariant: {},
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const response = await supertest(ctMock.app)
|
|
@@ -37,10 +38,21 @@ describe('Product', () => {
|
|
|
37
38
|
'nl-NL': 'test-product',
|
|
38
39
|
},
|
|
39
40
|
categories: [],
|
|
41
|
+
masterVariant: {
|
|
42
|
+
assets: [],
|
|
43
|
+
attributes: [],
|
|
44
|
+
id: 1,
|
|
45
|
+
images: [],
|
|
46
|
+
},
|
|
47
|
+
variants: [],
|
|
40
48
|
},
|
|
41
49
|
hasStagedChanges: true,
|
|
42
50
|
published: false,
|
|
43
51
|
},
|
|
52
|
+
productType: {
|
|
53
|
+
typeId: 'product-type',
|
|
54
|
+
id: 'some-uuid',
|
|
55
|
+
},
|
|
44
56
|
version: 1,
|
|
45
57
|
})
|
|
46
58
|
})
|