@labdigital/commercetools-mock 2.17.1 → 2.18.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.cjs +4186 -3974
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +266 -413
- package/dist/index.d.ts +266 -413
- package/dist/index.js +4186 -3974
- package/dist/index.js.map +1 -1
- package/package.json +44 -46
- package/src/constants.ts +2 -2
- package/src/ctMock.test.ts +11 -11
- package/src/ctMock.ts +141 -127
- package/src/deprecation.ts +8 -0
- package/src/exceptions.ts +17 -15
- package/src/helpers.ts +32 -32
- package/src/index.test.ts +128 -128
- package/src/index.ts +3 -3
- package/src/lib/expandParser.ts +13 -13
- package/src/lib/haversine.test.ts +9 -9
- package/src/lib/haversine.ts +11 -11
- package/src/lib/masking.ts +11 -11
- package/src/lib/parser.ts +2 -2
- package/src/lib/password.ts +23 -3
- package/src/lib/predicateParser.test.ts +185 -183
- package/src/lib/predicateParser.ts +234 -234
- package/src/lib/projectionSearchFilter.test.ts +103 -101
- package/src/lib/projectionSearchFilter.ts +152 -150
- package/src/lib/proxy.ts +5 -5
- package/src/oauth/errors.ts +4 -4
- package/src/oauth/helpers.ts +6 -6
- package/src/oauth/server.test.ts +86 -86
- package/src/oauth/server.ts +158 -144
- package/src/oauth/store.ts +44 -43
- package/src/priceSelector.test.ts +35 -35
- package/src/priceSelector.ts +30 -30
- package/src/product-projection-search.ts +136 -134
- package/src/projectAPI.test.ts +7 -7
- package/src/projectAPI.ts +24 -22
- package/src/repositories/abstract.ts +168 -116
- package/src/repositories/associate-role.ts +90 -77
- package/src/repositories/attribute-group.ts +51 -40
- package/src/repositories/business-unit.ts +168 -148
- package/src/repositories/cart/actions.ts +489 -0
- package/src/repositories/cart/helpers.ts +30 -0
- package/src/repositories/cart/index.ts +180 -0
- package/src/repositories/cart-discount/actions.ts +148 -0
- package/src/repositories/cart-discount/index.ts +86 -0
- package/src/repositories/category/actions.ts +231 -0
- package/src/repositories/category/index.ts +52 -0
- package/src/repositories/channel.ts +88 -90
- package/src/repositories/custom-object.ts +46 -45
- package/src/repositories/customer/actions.ts +165 -0
- package/src/repositories/customer/index.ts +79 -0
- package/src/repositories/customer-group.ts +66 -55
- package/src/repositories/discount-code/actions.ts +149 -0
- package/src/repositories/discount-code/index.ts +50 -0
- package/src/repositories/errors.ts +10 -10
- package/src/repositories/extension.ts +64 -62
- package/src/repositories/helpers.ts +117 -118
- package/src/repositories/index.ts +80 -79
- package/src/repositories/inventory-entry/actions.ts +84 -0
- package/src/repositories/inventory-entry/index.ts +44 -0
- package/src/repositories/my-customer.ts +114 -0
- package/src/repositories/my-order.ts +8 -8
- package/src/repositories/order/actions.ts +281 -0
- package/src/repositories/{order.test.ts → order/index.test.ts} +77 -77
- package/src/repositories/order/index.ts +260 -0
- package/src/repositories/order-edit.ts +10 -23
- package/src/repositories/payment/actions.ts +305 -0
- package/src/repositories/payment/helpers.ts +17 -0
- package/src/repositories/payment/index.ts +56 -0
- package/src/repositories/product/actions.ts +943 -0
- package/src/repositories/product/helpers.ts +98 -0
- package/src/repositories/product/index.ts +130 -0
- package/src/repositories/product-discount.ts +127 -117
- package/src/repositories/product-projection.ts +56 -62
- package/src/repositories/product-selection.ts +31 -28
- package/src/repositories/product-type.ts +136 -134
- package/src/repositories/project.ts +133 -118
- package/src/repositories/quote-request.ts +7 -19
- package/src/repositories/quote.ts +7 -22
- package/src/repositories/review.ts +13 -26
- package/src/repositories/shipping-method/actions.ts +198 -0
- package/src/repositories/shipping-method/helpers.ts +10 -0
- package/src/repositories/shipping-method/index.ts +138 -0
- package/src/repositories/shopping-list/actions.ts +295 -0
- package/src/repositories/shopping-list/index.ts +122 -0
- package/src/repositories/staged-quote.ts +7 -20
- package/src/repositories/standalone-price.ts +57 -44
- package/src/repositories/state.ts +113 -68
- package/src/repositories/store.ts +106 -94
- package/src/repositories/subscription.ts +46 -22
- package/src/repositories/tax-category/actions.ts +94 -0
- package/src/repositories/tax-category/helpers.ts +8 -0
- package/src/repositories/tax-category/index.ts +25 -0
- package/src/repositories/type/actions.ts +162 -0
- package/src/repositories/type/index.ts +24 -0
- package/src/repositories/zone.ts +62 -58
- package/src/server.ts +9 -9
- package/src/services/abstract.ts +75 -72
- package/src/services/associate-roles.test.ts +27 -27
- package/src/services/associate-roles.ts +7 -7
- package/src/services/attribute-group.ts +7 -7
- package/src/services/business-units.test.ts +28 -28
- package/src/services/business-units.ts +7 -7
- package/src/services/cart-discount.test.ts +199 -199
- package/src/services/cart-discount.ts +7 -7
- package/src/services/cart.test.ts +261 -261
- package/src/services/cart.ts +22 -21
- package/src/services/category.test.ts +121 -121
- package/src/services/category.ts +7 -7
- package/src/services/channel.ts +7 -7
- package/src/services/custom-object.test.ts +130 -130
- package/src/services/custom-object.ts +34 -31
- package/src/services/customer-group.ts +7 -7
- package/src/services/customer.test.ts +205 -205
- package/src/services/customer.ts +23 -36
- package/src/services/discount-code.ts +7 -7
- package/src/services/extension.ts +7 -7
- package/src/services/index.ts +85 -81
- package/src/services/inventory-entry.test.ts +106 -106
- package/src/services/inventory-entry.ts +7 -7
- package/src/services/my-cart.test.ts +56 -56
- package/src/services/my-cart.ts +20 -20
- package/src/services/my-customer.test.ts +155 -104
- package/src/services/my-customer.ts +61 -75
- package/src/services/my-order.ts +16 -16
- package/src/services/my-payment.test.ts +40 -40
- package/src/services/my-payment.ts +7 -7
- package/src/services/my-shopping-list.ts +7 -7
- package/src/services/order.test.ts +243 -243
- package/src/services/order.ts +23 -18
- package/src/services/payment.test.ts +40 -40
- package/src/services/payment.ts +7 -7
- package/src/services/product-discount.ts +7 -7
- package/src/services/product-projection.test.ts +190 -190
- package/src/services/product-projection.ts +34 -32
- package/src/services/product-selection.test.ts +19 -19
- package/src/services/product-selection.ts +7 -7
- package/src/services/product-type.test.ts +38 -38
- package/src/services/product-type.ts +7 -7
- package/src/services/product.test.ts +658 -656
- package/src/services/product.ts +7 -7
- package/src/services/project.test.ts +24 -24
- package/src/services/project.ts +17 -17
- package/src/services/reviews.ts +7 -7
- package/src/services/shipping-method.test.ts +78 -78
- package/src/services/shipping-method.ts +16 -16
- package/src/services/shopping-list.test.ts +170 -170
- package/src/services/shopping-list.ts +7 -7
- package/src/services/standalone-price.test.ts +112 -112
- package/src/services/standalone-price.ts +7 -7
- package/src/services/state.test.ts +30 -30
- package/src/services/state.ts +7 -7
- package/src/services/store.test.ts +40 -40
- package/src/services/store.ts +7 -7
- package/src/services/subscription.ts +7 -7
- package/src/services/tax-category.test.ts +43 -43
- package/src/services/tax-category.ts +7 -7
- package/src/services/type.ts +7 -7
- package/src/services/zone.ts +7 -7
- package/src/shippingCalculator.test.ts +43 -43
- package/src/shippingCalculator.ts +23 -23
- package/src/storage/abstract.ts +36 -34
- package/src/storage/in-memory.ts +237 -233
- package/src/storage/index.ts +2 -2
- package/src/types.ts +91 -91
- package/src/repositories/cart-discount.ts +0 -219
- package/src/repositories/cart.ts +0 -659
- package/src/repositories/category.ts +0 -256
- package/src/repositories/customer.ts +0 -228
- package/src/repositories/discount-code.ts +0 -181
- package/src/repositories/inventory-entry.ts +0 -109
- package/src/repositories/order.ts +0 -514
- package/src/repositories/payment.ts +0 -342
- package/src/repositories/product.ts +0 -1106
- package/src/repositories/shipping-method.ts +0 -312
- package/src/repositories/shopping-list.ts +0 -392
- package/src/repositories/tax-category.ts +0 -111
- package/src/repositories/type.ts +0 -172
|
@@ -12,112 +12,112 @@ import type {
|
|
|
12
12
|
StateDraft,
|
|
13
13
|
TaxCategory,
|
|
14
14
|
TaxCategoryDraft,
|
|
15
|
-
} from
|
|
16
|
-
import assert from
|
|
17
|
-
import supertest from
|
|
18
|
-
import { beforeAll, beforeEach, describe, expect, test } from
|
|
19
|
-
import { CommercetoolsMock } from
|
|
15
|
+
} from "@commercetools/platform-sdk";
|
|
16
|
+
import assert from "assert";
|
|
17
|
+
import supertest from "supertest";
|
|
18
|
+
import { beforeAll, beforeEach, describe, expect, test } from "vitest";
|
|
19
|
+
import { CommercetoolsMock } from "../index";
|
|
20
20
|
|
|
21
21
|
const productTypeDraft: ProductTypeDraft = {
|
|
22
|
-
key:
|
|
23
|
-
name:
|
|
24
|
-
description:
|
|
25
|
-
}
|
|
22
|
+
key: "test-product-type",
|
|
23
|
+
name: "Test Product Type",
|
|
24
|
+
description: "Test Product Type description",
|
|
25
|
+
};
|
|
26
26
|
|
|
27
27
|
const categoryDraft1: CategoryDraft = {
|
|
28
|
-
key:
|
|
28
|
+
key: "category-1",
|
|
29
29
|
name: {
|
|
30
|
-
|
|
30
|
+
"nl-NL": "Category One",
|
|
31
31
|
},
|
|
32
32
|
slug: {
|
|
33
|
-
|
|
33
|
+
"nl-NL": "category_1",
|
|
34
34
|
},
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
const categoryDraft2: CategoryDraft = {
|
|
38
|
-
key:
|
|
38
|
+
key: "category-2",
|
|
39
39
|
name: {
|
|
40
|
-
|
|
40
|
+
"nl-NL": "Category Two",
|
|
41
41
|
},
|
|
42
42
|
slug: {
|
|
43
|
-
|
|
43
|
+
"nl-NL": "category_2",
|
|
44
44
|
},
|
|
45
|
-
}
|
|
45
|
+
};
|
|
46
46
|
|
|
47
47
|
const taxcategoryDraft1: TaxCategoryDraft = {
|
|
48
|
-
name:
|
|
49
|
-
key:
|
|
50
|
-
}
|
|
48
|
+
name: "Tax category 1",
|
|
49
|
+
key: "tax-category-1",
|
|
50
|
+
};
|
|
51
51
|
|
|
52
52
|
const taxcategoryDraft2: TaxCategoryDraft = {
|
|
53
|
-
name:
|
|
54
|
-
key:
|
|
55
|
-
}
|
|
53
|
+
name: "Tax category 2",
|
|
54
|
+
key: "tax-category-2",
|
|
55
|
+
};
|
|
56
56
|
|
|
57
57
|
const productState1Draft: StateDraft = {
|
|
58
|
-
key:
|
|
59
|
-
type:
|
|
58
|
+
key: "initial-state",
|
|
59
|
+
type: "ProductState",
|
|
60
60
|
initial: true,
|
|
61
61
|
name: {
|
|
62
|
-
|
|
62
|
+
"nl-NL": "Initial state",
|
|
63
63
|
},
|
|
64
64
|
description: {
|
|
65
|
-
|
|
65
|
+
"nl-NL": "Product initial state",
|
|
66
66
|
},
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
68
|
|
|
69
69
|
const productState2Draft: StateDraft = {
|
|
70
|
-
key:
|
|
71
|
-
type:
|
|
70
|
+
key: "another-state",
|
|
71
|
+
type: "ProductState",
|
|
72
72
|
initial: true,
|
|
73
73
|
name: {
|
|
74
|
-
|
|
74
|
+
"nl-NL": "Another state",
|
|
75
75
|
},
|
|
76
76
|
description: {
|
|
77
|
-
|
|
77
|
+
"nl-NL": "Product another state",
|
|
78
78
|
},
|
|
79
|
-
}
|
|
79
|
+
};
|
|
80
80
|
|
|
81
81
|
const publishedProductDraft: ProductDraft = {
|
|
82
82
|
name: {
|
|
83
|
-
|
|
83
|
+
"nl-NL": "test published product",
|
|
84
84
|
},
|
|
85
85
|
description: {
|
|
86
|
-
|
|
86
|
+
"nl-NL": "Test published product description",
|
|
87
87
|
},
|
|
88
88
|
productType: {
|
|
89
|
-
typeId:
|
|
90
|
-
key:
|
|
89
|
+
typeId: "product-type",
|
|
90
|
+
key: "test-product-type",
|
|
91
91
|
},
|
|
92
92
|
categories: [
|
|
93
93
|
{
|
|
94
|
-
typeId:
|
|
95
|
-
key:
|
|
94
|
+
typeId: "category",
|
|
95
|
+
key: "category-1",
|
|
96
96
|
},
|
|
97
97
|
],
|
|
98
98
|
taxCategory: {
|
|
99
|
-
typeId:
|
|
99
|
+
typeId: "tax-category",
|
|
100
100
|
key: taxcategoryDraft1.key,
|
|
101
101
|
},
|
|
102
102
|
state: {
|
|
103
|
-
typeId:
|
|
104
|
-
key:
|
|
103
|
+
typeId: "state",
|
|
104
|
+
key: "initial-state",
|
|
105
105
|
},
|
|
106
106
|
masterVariant: {
|
|
107
|
-
key:
|
|
108
|
-
sku:
|
|
107
|
+
key: "master-variant-key",
|
|
108
|
+
sku: "1337",
|
|
109
109
|
attributes: [
|
|
110
110
|
{
|
|
111
|
-
name:
|
|
112
|
-
value:
|
|
111
|
+
name: "test",
|
|
112
|
+
value: "test",
|
|
113
113
|
},
|
|
114
114
|
],
|
|
115
115
|
prices: [
|
|
116
116
|
{
|
|
117
|
-
key:
|
|
118
|
-
country:
|
|
117
|
+
key: "base_price_eur",
|
|
118
|
+
country: "NL",
|
|
119
119
|
value: {
|
|
120
|
-
currencyCode:
|
|
120
|
+
currencyCode: "EUR",
|
|
121
121
|
centAmount: 1000,
|
|
122
122
|
},
|
|
123
123
|
},
|
|
@@ -125,20 +125,20 @@ const publishedProductDraft: ProductDraft = {
|
|
|
125
125
|
},
|
|
126
126
|
variants: [
|
|
127
127
|
{
|
|
128
|
-
key:
|
|
129
|
-
sku:
|
|
128
|
+
key: "variant-1-key",
|
|
129
|
+
sku: "1338",
|
|
130
130
|
attributes: [
|
|
131
131
|
{
|
|
132
|
-
name:
|
|
133
|
-
value:
|
|
132
|
+
name: "test2",
|
|
133
|
+
value: "test2",
|
|
134
134
|
},
|
|
135
135
|
],
|
|
136
136
|
prices: [
|
|
137
137
|
{
|
|
138
|
-
key:
|
|
139
|
-
country:
|
|
138
|
+
key: "base_price_eur",
|
|
139
|
+
country: "NL",
|
|
140
140
|
value: {
|
|
141
|
-
currencyCode:
|
|
141
|
+
currencyCode: "EUR",
|
|
142
142
|
centAmount: 2000,
|
|
143
143
|
},
|
|
144
144
|
},
|
|
@@ -146,61 +146,61 @@ const publishedProductDraft: ProductDraft = {
|
|
|
146
146
|
},
|
|
147
147
|
],
|
|
148
148
|
slug: {
|
|
149
|
-
|
|
149
|
+
"nl-NL": "test-published-product",
|
|
150
150
|
},
|
|
151
151
|
metaTitle: {
|
|
152
|
-
|
|
152
|
+
"nl-NL": "Unpublished product (meta title)",
|
|
153
153
|
},
|
|
154
154
|
metaDescription: {
|
|
155
|
-
|
|
155
|
+
"nl-NL": "Unpublished product description (meta description)",
|
|
156
156
|
},
|
|
157
157
|
metaKeywords: {
|
|
158
|
-
|
|
158
|
+
"nl-NL": "Test product (meta Keywords)",
|
|
159
159
|
},
|
|
160
160
|
publish: true,
|
|
161
|
-
}
|
|
161
|
+
};
|
|
162
162
|
|
|
163
163
|
const unpublishedProductDraft: ProductDraft = {
|
|
164
|
-
key:
|
|
164
|
+
key: "test-unpublished-product",
|
|
165
165
|
name: {
|
|
166
|
-
|
|
166
|
+
"nl-NL": "test unpublished product",
|
|
167
167
|
},
|
|
168
168
|
description: {
|
|
169
|
-
|
|
169
|
+
"nl-NL": "Test published product description",
|
|
170
170
|
},
|
|
171
171
|
productType: {
|
|
172
|
-
typeId:
|
|
173
|
-
key:
|
|
172
|
+
typeId: "product-type",
|
|
173
|
+
key: "test-product-type",
|
|
174
174
|
},
|
|
175
175
|
categories: [
|
|
176
176
|
{
|
|
177
|
-
typeId:
|
|
178
|
-
key:
|
|
177
|
+
typeId: "category",
|
|
178
|
+
key: "category-1",
|
|
179
179
|
},
|
|
180
180
|
],
|
|
181
181
|
taxCategory: {
|
|
182
|
-
typeId:
|
|
182
|
+
typeId: "tax-category",
|
|
183
183
|
key: taxcategoryDraft1.key,
|
|
184
184
|
},
|
|
185
185
|
state: {
|
|
186
|
-
typeId:
|
|
187
|
-
key:
|
|
186
|
+
typeId: "state",
|
|
187
|
+
key: "initial-state",
|
|
188
188
|
},
|
|
189
189
|
masterVariant: {
|
|
190
|
-
key:
|
|
191
|
-
sku:
|
|
190
|
+
key: "master-variant-key",
|
|
191
|
+
sku: "2337",
|
|
192
192
|
attributes: [
|
|
193
193
|
{
|
|
194
|
-
name:
|
|
195
|
-
value:
|
|
194
|
+
name: "test",
|
|
195
|
+
value: "test",
|
|
196
196
|
},
|
|
197
197
|
],
|
|
198
198
|
prices: [
|
|
199
199
|
{
|
|
200
|
-
key:
|
|
201
|
-
country:
|
|
200
|
+
key: "base_price_eur",
|
|
201
|
+
country: "NL",
|
|
202
202
|
value: {
|
|
203
|
-
currencyCode:
|
|
203
|
+
currencyCode: "EUR",
|
|
204
204
|
centAmount: 1000,
|
|
205
205
|
},
|
|
206
206
|
},
|
|
@@ -208,20 +208,20 @@ const unpublishedProductDraft: ProductDraft = {
|
|
|
208
208
|
},
|
|
209
209
|
variants: [
|
|
210
210
|
{
|
|
211
|
-
key:
|
|
212
|
-
sku:
|
|
211
|
+
key: "variant-1-key",
|
|
212
|
+
sku: "2338",
|
|
213
213
|
attributes: [
|
|
214
214
|
{
|
|
215
|
-
name:
|
|
216
|
-
value:
|
|
215
|
+
name: "test2",
|
|
216
|
+
value: "test2",
|
|
217
217
|
},
|
|
218
218
|
],
|
|
219
219
|
prices: [
|
|
220
220
|
{
|
|
221
|
-
key:
|
|
222
|
-
country:
|
|
221
|
+
key: "base_price_eur",
|
|
222
|
+
country: "NL",
|
|
223
223
|
value: {
|
|
224
|
-
currencyCode:
|
|
224
|
+
currencyCode: "EUR",
|
|
225
225
|
centAmount: 2000,
|
|
226
226
|
},
|
|
227
227
|
},
|
|
@@ -229,145 +229,145 @@ const unpublishedProductDraft: ProductDraft = {
|
|
|
229
229
|
},
|
|
230
230
|
],
|
|
231
231
|
slug: {
|
|
232
|
-
|
|
232
|
+
"nl-NL": "test-unpublished-product",
|
|
233
233
|
},
|
|
234
234
|
metaTitle: {
|
|
235
|
-
|
|
235
|
+
"nl-NL": "Unpublished product (meta title)",
|
|
236
236
|
},
|
|
237
237
|
metaDescription: {
|
|
238
|
-
|
|
238
|
+
"nl-NL": "Unpublished product description (meta description)",
|
|
239
239
|
},
|
|
240
240
|
metaKeywords: {
|
|
241
|
-
|
|
241
|
+
"nl-NL": "Test product (meta Keywords)",
|
|
242
242
|
},
|
|
243
243
|
publish: false,
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
let productType: ProductType
|
|
247
|
-
let category1: Category
|
|
248
|
-
let category2: Category
|
|
249
|
-
let taxCategory1: TaxCategory
|
|
250
|
-
let taxCategory2: TaxCategory
|
|
251
|
-
let productState1: State
|
|
252
|
-
let productState2: State
|
|
253
|
-
|
|
254
|
-
async function beforeAllProductTests(mock) {
|
|
255
|
-
let response
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
let productType: ProductType;
|
|
247
|
+
let category1: Category;
|
|
248
|
+
let category2: Category;
|
|
249
|
+
let taxCategory1: TaxCategory;
|
|
250
|
+
let taxCategory2: TaxCategory;
|
|
251
|
+
let productState1: State;
|
|
252
|
+
let productState2: State;
|
|
253
|
+
|
|
254
|
+
async function beforeAllProductTests(mock: CommercetoolsMock) {
|
|
255
|
+
let response;
|
|
256
256
|
// Create Product Type
|
|
257
257
|
response = await supertest(mock.app)
|
|
258
|
-
.post(
|
|
259
|
-
.send(productTypeDraft)
|
|
258
|
+
.post("/dummy/product-types")
|
|
259
|
+
.send(productTypeDraft);
|
|
260
260
|
|
|
261
|
-
expect(response.status).toBe(201)
|
|
262
|
-
productType = response.body
|
|
261
|
+
expect(response.status).toBe(201);
|
|
262
|
+
productType = response.body;
|
|
263
263
|
|
|
264
264
|
// Create Category 1
|
|
265
265
|
response = await supertest(mock.app)
|
|
266
|
-
.post(
|
|
267
|
-
.send(categoryDraft1)
|
|
266
|
+
.post("/dummy/categories")
|
|
267
|
+
.send(categoryDraft1);
|
|
268
268
|
|
|
269
|
-
expect(response.status).toBe(201)
|
|
270
|
-
category1 = response.body
|
|
269
|
+
expect(response.status).toBe(201);
|
|
270
|
+
category1 = response.body;
|
|
271
271
|
|
|
272
272
|
// Create Category 2
|
|
273
273
|
response = await supertest(mock.app)
|
|
274
|
-
.post(
|
|
275
|
-
.send(categoryDraft2)
|
|
274
|
+
.post("/dummy/categories")
|
|
275
|
+
.send(categoryDraft2);
|
|
276
276
|
|
|
277
|
-
expect(response.status).toBe(201)
|
|
278
|
-
category2 = response.body
|
|
277
|
+
expect(response.status).toBe(201);
|
|
278
|
+
category2 = response.body;
|
|
279
279
|
|
|
280
280
|
// Create Tax Category 1
|
|
281
281
|
response = await supertest(mock.app)
|
|
282
|
-
.post(
|
|
283
|
-
.send(taxcategoryDraft1)
|
|
282
|
+
.post("/dummy/tax-categories")
|
|
283
|
+
.send(taxcategoryDraft1);
|
|
284
284
|
|
|
285
|
-
expect(response.status).toBe(201)
|
|
286
|
-
taxCategory1 = response.body
|
|
285
|
+
expect(response.status).toBe(201);
|
|
286
|
+
taxCategory1 = response.body;
|
|
287
287
|
|
|
288
288
|
// Create Tax Category 2
|
|
289
289
|
response = await supertest(mock.app)
|
|
290
|
-
.post(
|
|
291
|
-
.send(taxcategoryDraft2)
|
|
290
|
+
.post("/dummy/tax-categories")
|
|
291
|
+
.send(taxcategoryDraft2);
|
|
292
292
|
|
|
293
|
-
expect(response.status).toBe(201)
|
|
294
|
-
taxCategory2 = response.body
|
|
293
|
+
expect(response.status).toBe(201);
|
|
294
|
+
taxCategory2 = response.body;
|
|
295
295
|
|
|
296
296
|
// Create Product State 1
|
|
297
297
|
response = await supertest(mock.app)
|
|
298
|
-
.post(
|
|
299
|
-
.send(productState1Draft)
|
|
298
|
+
.post("/dummy/states")
|
|
299
|
+
.send(productState1Draft);
|
|
300
300
|
|
|
301
|
-
expect(response.status).toBe(201)
|
|
302
|
-
productState1 = response.body
|
|
301
|
+
expect(response.status).toBe(201);
|
|
302
|
+
productState1 = response.body;
|
|
303
303
|
|
|
304
304
|
// Create Product State 2
|
|
305
305
|
response = await supertest(mock.app)
|
|
306
|
-
.post(
|
|
307
|
-
.send(productState2Draft)
|
|
306
|
+
.post("/dummy/states")
|
|
307
|
+
.send(productState2Draft);
|
|
308
308
|
|
|
309
|
-
expect(response.status).toBe(201)
|
|
310
|
-
productState2 = response.body
|
|
309
|
+
expect(response.status).toBe(201);
|
|
310
|
+
productState2 = response.body;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
describe(
|
|
314
|
-
const ctMock = new CommercetoolsMock()
|
|
313
|
+
describe("Product", () => {
|
|
314
|
+
const ctMock = new CommercetoolsMock();
|
|
315
315
|
beforeAll(async () => {
|
|
316
|
-
await beforeAllProductTests(ctMock)
|
|
317
|
-
})
|
|
316
|
+
await beforeAllProductTests(ctMock);
|
|
317
|
+
});
|
|
318
318
|
|
|
319
|
-
test(
|
|
320
|
-
assert(productType,
|
|
319
|
+
test("Create product", async () => {
|
|
320
|
+
assert(productType, "product type not created");
|
|
321
321
|
|
|
322
322
|
const response = await supertest(ctMock.app)
|
|
323
|
-
.post(
|
|
324
|
-
.send(unpublishedProductDraft)
|
|
323
|
+
.post("/dummy/products")
|
|
324
|
+
.send(unpublishedProductDraft);
|
|
325
325
|
|
|
326
326
|
const productData: ProductData = {
|
|
327
327
|
name: {
|
|
328
|
-
|
|
328
|
+
"nl-NL": "test unpublished product",
|
|
329
329
|
},
|
|
330
330
|
description: {
|
|
331
|
-
|
|
331
|
+
"nl-NL": "Test published product description",
|
|
332
332
|
},
|
|
333
333
|
slug: {
|
|
334
|
-
|
|
334
|
+
"nl-NL": "test-unpublished-product",
|
|
335
335
|
},
|
|
336
336
|
categories: [
|
|
337
337
|
{
|
|
338
338
|
id: category1.id,
|
|
339
|
-
typeId:
|
|
339
|
+
typeId: "category",
|
|
340
340
|
},
|
|
341
341
|
],
|
|
342
342
|
metaTitle: {
|
|
343
|
-
|
|
343
|
+
"nl-NL": "Unpublished product (meta title)",
|
|
344
344
|
},
|
|
345
345
|
metaDescription: {
|
|
346
|
-
|
|
346
|
+
"nl-NL": "Unpublished product description (meta description)",
|
|
347
347
|
},
|
|
348
348
|
metaKeywords: {
|
|
349
|
-
|
|
349
|
+
"nl-NL": "Test product (meta Keywords)",
|
|
350
350
|
},
|
|
351
351
|
masterVariant: {
|
|
352
352
|
id: 1,
|
|
353
|
-
key:
|
|
354
|
-
sku:
|
|
353
|
+
key: "master-variant-key",
|
|
354
|
+
sku: "2337",
|
|
355
355
|
assets: [],
|
|
356
356
|
attributes: [
|
|
357
357
|
{
|
|
358
|
-
name:
|
|
359
|
-
value:
|
|
358
|
+
name: "test",
|
|
359
|
+
value: "test",
|
|
360
360
|
},
|
|
361
361
|
],
|
|
362
362
|
prices: [
|
|
363
363
|
{
|
|
364
364
|
id: expect.anything(),
|
|
365
|
-
key:
|
|
366
|
-
country:
|
|
365
|
+
key: "base_price_eur",
|
|
366
|
+
country: "NL",
|
|
367
367
|
value: {
|
|
368
|
-
type:
|
|
368
|
+
type: "centPrecision",
|
|
369
369
|
centAmount: 1000,
|
|
370
|
-
currencyCode:
|
|
370
|
+
currencyCode: "EUR",
|
|
371
371
|
fractionDigits: 2,
|
|
372
372
|
},
|
|
373
373
|
},
|
|
@@ -376,26 +376,26 @@ describe('Product', () => {
|
|
|
376
376
|
},
|
|
377
377
|
variants: [
|
|
378
378
|
{
|
|
379
|
-
key:
|
|
380
|
-
sku:
|
|
379
|
+
key: "variant-1-key",
|
|
380
|
+
sku: "2338",
|
|
381
381
|
assets: [],
|
|
382
382
|
id: 2,
|
|
383
383
|
images: [],
|
|
384
384
|
attributes: [
|
|
385
385
|
{
|
|
386
|
-
name:
|
|
387
|
-
value:
|
|
386
|
+
name: "test2",
|
|
387
|
+
value: "test2",
|
|
388
388
|
},
|
|
389
389
|
],
|
|
390
390
|
prices: [
|
|
391
391
|
{
|
|
392
392
|
id: expect.anything(),
|
|
393
|
-
key:
|
|
394
|
-
country:
|
|
393
|
+
key: "base_price_eur",
|
|
394
|
+
country: "NL",
|
|
395
395
|
value: {
|
|
396
|
-
type:
|
|
396
|
+
type: "centPrecision",
|
|
397
397
|
centAmount: 2000,
|
|
398
|
-
currencyCode:
|
|
398
|
+
currencyCode: "EUR",
|
|
399
399
|
fractionDigits: 2,
|
|
400
400
|
},
|
|
401
401
|
},
|
|
@@ -403,15 +403,15 @@ describe('Product', () => {
|
|
|
403
403
|
},
|
|
404
404
|
],
|
|
405
405
|
searchKeywords: {},
|
|
406
|
-
}
|
|
406
|
+
};
|
|
407
407
|
|
|
408
408
|
expect(response.body).toEqual({
|
|
409
409
|
createdAt: expect.anything(),
|
|
410
410
|
id: expect.anything(),
|
|
411
411
|
lastModifiedAt: expect.anything(),
|
|
412
|
-
key:
|
|
412
|
+
key: "test-unpublished-product",
|
|
413
413
|
taxCategory: {
|
|
414
|
-
typeId:
|
|
414
|
+
typeId: "tax-category",
|
|
415
415
|
id: taxCategory1.id,
|
|
416
416
|
},
|
|
417
417
|
masterData: {
|
|
@@ -421,43 +421,43 @@ describe('Product', () => {
|
|
|
421
421
|
published: false,
|
|
422
422
|
},
|
|
423
423
|
productType: {
|
|
424
|
-
typeId:
|
|
424
|
+
typeId: "product-type",
|
|
425
425
|
id: productType.id,
|
|
426
426
|
},
|
|
427
427
|
state: {
|
|
428
|
-
typeId:
|
|
428
|
+
typeId: "state",
|
|
429
429
|
id: productState1.id,
|
|
430
430
|
},
|
|
431
431
|
version: 1,
|
|
432
|
-
} as Product)
|
|
433
|
-
})
|
|
434
|
-
})
|
|
432
|
+
} as Product);
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
435
|
|
|
436
|
-
describe(
|
|
437
|
-
const ctMock = new CommercetoolsMock()
|
|
438
|
-
let productPublished: Product | undefined
|
|
436
|
+
describe("Product update actions", () => {
|
|
437
|
+
const ctMock = new CommercetoolsMock();
|
|
438
|
+
let productPublished: Product | undefined;
|
|
439
439
|
beforeAll(async () => {
|
|
440
|
-
await beforeAllProductTests(ctMock)
|
|
441
|
-
})
|
|
440
|
+
await beforeAllProductTests(ctMock);
|
|
441
|
+
});
|
|
442
442
|
|
|
443
443
|
beforeEach(async () => {
|
|
444
|
-
let response
|
|
444
|
+
let response;
|
|
445
445
|
response = await supertest(ctMock.app)
|
|
446
|
-
.post(
|
|
447
|
-
.send(publishedProductDraft)
|
|
446
|
+
.post("/dummy/products")
|
|
447
|
+
.send(publishedProductDraft);
|
|
448
448
|
|
|
449
|
-
expect(response.status).toBe(201)
|
|
450
|
-
productPublished = response.body
|
|
449
|
+
expect(response.status).toBe(201);
|
|
450
|
+
productPublished = response.body;
|
|
451
451
|
|
|
452
452
|
response = await supertest(ctMock.app)
|
|
453
|
-
.post(
|
|
454
|
-
.send(unpublishedProductDraft)
|
|
453
|
+
.post("/dummy/products")
|
|
454
|
+
.send(unpublishedProductDraft);
|
|
455
455
|
|
|
456
|
-
expect(response.status).toBe(201)
|
|
457
|
-
})
|
|
456
|
+
expect(response.status).toBe(201);
|
|
457
|
+
});
|
|
458
458
|
|
|
459
|
-
test(
|
|
460
|
-
assert(productPublished,
|
|
459
|
+
test("setAttribute masterVariant (staged)", async () => {
|
|
460
|
+
assert(productPublished, "product not created");
|
|
461
461
|
|
|
462
462
|
{
|
|
463
463
|
const response = await supertest(ctMock.app)
|
|
@@ -465,21 +465,23 @@ describe('Product update actions', () => {
|
|
|
465
465
|
.send({
|
|
466
466
|
version: 1,
|
|
467
467
|
actions: [
|
|
468
|
-
{ action:
|
|
468
|
+
{ action: "setAttribute", sku: "1337", name: "foo", value: "bar" },
|
|
469
469
|
],
|
|
470
|
-
})
|
|
470
|
+
});
|
|
471
471
|
|
|
472
|
-
expect(response.status).toBe(200)
|
|
473
|
-
const product: Product = response.body
|
|
474
|
-
expect(product.version).toBe(2)
|
|
475
|
-
expect(product.masterData.hasStagedChanges).toBeTruthy()
|
|
472
|
+
expect(response.status).toBe(200);
|
|
473
|
+
const product: Product = response.body;
|
|
474
|
+
expect(product.version).toBe(2);
|
|
475
|
+
expect(product.masterData.hasStagedChanges).toBeTruthy();
|
|
476
476
|
expect(product.masterData.current.masterVariant.attributes).toHaveLength(
|
|
477
|
-
1
|
|
478
|
-
)
|
|
479
|
-
expect(product.masterData.staged.masterVariant.attributes).toHaveLength(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
477
|
+
1,
|
|
478
|
+
);
|
|
479
|
+
expect(product.masterData.staged.masterVariant.attributes).toHaveLength(
|
|
480
|
+
2,
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
const attr = response.body.masterData.staged.masterVariant.attributes[1];
|
|
484
|
+
expect(attr).toEqual({ name: "foo", value: "bar" });
|
|
483
485
|
}
|
|
484
486
|
|
|
485
487
|
// Publish
|
|
@@ -488,21 +490,21 @@ describe('Product update actions', () => {
|
|
|
488
490
|
.post(`/dummy/products/${productPublished.id}`)
|
|
489
491
|
.send({
|
|
490
492
|
version: 2,
|
|
491
|
-
actions: [{ action:
|
|
492
|
-
})
|
|
493
|
+
actions: [{ action: "publish", scope: "All" }],
|
|
494
|
+
});
|
|
493
495
|
|
|
494
|
-
expect(response.status).toBe(200)
|
|
495
|
-
const product: Product = response.body
|
|
496
|
-
expect(product.version).toBe(3)
|
|
497
|
-
expect(product.masterData.hasStagedChanges).toBeFalsy()
|
|
496
|
+
expect(response.status).toBe(200);
|
|
497
|
+
const product: Product = response.body;
|
|
498
|
+
expect(product.version).toBe(3);
|
|
499
|
+
expect(product.masterData.hasStagedChanges).toBeFalsy();
|
|
498
500
|
expect(product.masterData.current.masterVariant.attributes).toHaveLength(
|
|
499
|
-
2
|
|
500
|
-
)
|
|
501
|
+
2,
|
|
502
|
+
);
|
|
501
503
|
}
|
|
502
|
-
})
|
|
504
|
+
});
|
|
503
505
|
|
|
504
|
-
test(
|
|
505
|
-
assert(productPublished,
|
|
506
|
+
test("setAttribute masterVariant (published)", async () => {
|
|
507
|
+
assert(productPublished, "product not created");
|
|
506
508
|
|
|
507
509
|
const response = await supertest(ctMock.app)
|
|
508
510
|
.post(`/dummy/products/${productPublished.id}`)
|
|
@@ -510,227 +512,225 @@ describe('Product update actions', () => {
|
|
|
510
512
|
version: 1,
|
|
511
513
|
actions: [
|
|
512
514
|
{
|
|
513
|
-
action:
|
|
514
|
-
sku:
|
|
515
|
-
name:
|
|
516
|
-
value:
|
|
515
|
+
action: "setAttribute",
|
|
516
|
+
sku: "1337",
|
|
517
|
+
name: "foo",
|
|
518
|
+
value: "bar",
|
|
517
519
|
staged: false,
|
|
518
520
|
},
|
|
519
521
|
],
|
|
520
|
-
})
|
|
522
|
+
});
|
|
521
523
|
|
|
522
|
-
expect(response.status).toBe(200)
|
|
523
|
-
const product: Product = response.body
|
|
524
|
+
expect(response.status).toBe(200);
|
|
525
|
+
const product: Product = response.body;
|
|
524
526
|
|
|
525
527
|
// TODO: Since we auto publish it actually does two version updates. So the
|
|
526
528
|
// version should be 3
|
|
527
|
-
expect(product.version).toBe(2)
|
|
528
|
-
expect(product.masterData.hasStagedChanges).toBeFalsy()
|
|
529
|
-
expect(product.masterData.current.masterVariant.attributes).toHaveLength(2)
|
|
530
|
-
expect(product.masterData.staged.masterVariant.attributes).toHaveLength(2)
|
|
529
|
+
expect(product.version).toBe(2);
|
|
530
|
+
expect(product.masterData.hasStagedChanges).toBeFalsy();
|
|
531
|
+
expect(product.masterData.current.masterVariant.attributes).toHaveLength(2);
|
|
532
|
+
expect(product.masterData.staged.masterVariant.attributes).toHaveLength(2);
|
|
531
533
|
|
|
532
|
-
const attr = response.body.masterData.staged.masterVariant.attributes[1]
|
|
533
|
-
expect(attr).toEqual({ name:
|
|
534
|
-
})
|
|
534
|
+
const attr = response.body.masterData.staged.masterVariant.attributes[1];
|
|
535
|
+
expect(attr).toEqual({ name: "foo", value: "bar" });
|
|
536
|
+
});
|
|
535
537
|
|
|
536
|
-
test(
|
|
537
|
-
assert(productPublished,
|
|
538
|
+
test("setAttribute variant", async () => {
|
|
539
|
+
assert(productPublished, "product not created");
|
|
538
540
|
|
|
539
541
|
const response = await supertest(ctMock.app)
|
|
540
542
|
.post(`/dummy/products/${productPublished.id}`)
|
|
541
543
|
.send({
|
|
542
544
|
version: 1,
|
|
543
545
|
actions: [
|
|
544
|
-
{ action:
|
|
546
|
+
{ action: "setAttribute", sku: "1338", name: "foo", value: "bar" },
|
|
545
547
|
],
|
|
546
|
-
})
|
|
547
|
-
expect(response.status).toBe(200)
|
|
548
|
-
expect(response.body.version).toBe(2)
|
|
548
|
+
});
|
|
549
|
+
expect(response.status).toBe(200);
|
|
550
|
+
expect(response.body.version).toBe(2);
|
|
549
551
|
expect(response.body.masterData.staged.variants[0].attributes).toHaveLength(
|
|
550
|
-
2
|
|
551
|
-
)
|
|
552
|
-
const attr = response.body.masterData.staged.variants[0].attributes[1]
|
|
553
|
-
expect(attr).toEqual({ name:
|
|
554
|
-
})
|
|
552
|
+
2,
|
|
553
|
+
);
|
|
554
|
+
const attr = response.body.masterData.staged.variants[0].attributes[1];
|
|
555
|
+
expect(attr).toEqual({ name: "foo", value: "bar" });
|
|
556
|
+
});
|
|
555
557
|
|
|
556
|
-
test(
|
|
557
|
-
assert(productPublished,
|
|
558
|
+
test("setAttribute variant and publish", async () => {
|
|
559
|
+
assert(productPublished, "product not created");
|
|
558
560
|
|
|
559
561
|
const response = await supertest(ctMock.app)
|
|
560
562
|
.post(`/dummy/products/${productPublished.id}`)
|
|
561
563
|
.send({
|
|
562
564
|
version: 1,
|
|
563
565
|
actions: [
|
|
564
|
-
{ action:
|
|
565
|
-
{ action:
|
|
566
|
+
{ action: "setAttribute", sku: "1338", name: "foo", value: "bar" },
|
|
567
|
+
{ action: "publish" },
|
|
566
568
|
],
|
|
567
|
-
})
|
|
568
|
-
expect(response.status).toBe(200)
|
|
569
|
-
expect(response.body.version).toBe(3)
|
|
569
|
+
});
|
|
570
|
+
expect(response.status).toBe(200);
|
|
571
|
+
expect(response.body.version).toBe(3);
|
|
570
572
|
expect(
|
|
571
|
-
response.body.masterData.current.variants[0].attributes
|
|
572
|
-
).toHaveLength(2)
|
|
573
|
-
const attr = response.body.masterData.current.variants[0].attributes[1]
|
|
574
|
-
expect(attr).toEqual({ name:
|
|
575
|
-
})
|
|
573
|
+
response.body.masterData.current.variants[0].attributes,
|
|
574
|
+
).toHaveLength(2);
|
|
575
|
+
const attr = response.body.masterData.current.variants[0].attributes[1];
|
|
576
|
+
expect(attr).toEqual({ name: "foo", value: "bar" });
|
|
577
|
+
});
|
|
576
578
|
|
|
577
|
-
test(
|
|
578
|
-
assert(productPublished,
|
|
579
|
+
test("setAttribute overwrite", async () => {
|
|
580
|
+
assert(productPublished, "product not created");
|
|
579
581
|
|
|
580
582
|
const response = await supertest(ctMock.app)
|
|
581
583
|
.post(`/dummy/products/${productPublished.id}`)
|
|
582
584
|
.send({
|
|
583
585
|
version: 1,
|
|
584
586
|
actions: [
|
|
585
|
-
{ action:
|
|
587
|
+
{ action: "setAttribute", sku: "1337", name: "test", value: "foo" },
|
|
586
588
|
],
|
|
587
|
-
})
|
|
588
|
-
expect(response.status).toBe(200)
|
|
589
|
-
expect(response.body.version).toBe(2)
|
|
589
|
+
});
|
|
590
|
+
expect(response.status).toBe(200);
|
|
591
|
+
expect(response.body.version).toBe(2);
|
|
590
592
|
expect(
|
|
591
|
-
response.body.masterData.staged.masterVariant.attributes
|
|
592
|
-
).toHaveLength(1)
|
|
593
|
-
const attr = response.body.masterData.staged.masterVariant.attributes[0]
|
|
594
|
-
expect(attr).toEqual({ name:
|
|
595
|
-
})
|
|
596
|
-
|
|
597
|
-
test(
|
|
598
|
-
assert(productPublished,
|
|
593
|
+
response.body.masterData.staged.masterVariant.attributes,
|
|
594
|
+
).toHaveLength(1);
|
|
595
|
+
const attr = response.body.masterData.staged.masterVariant.attributes[0];
|
|
596
|
+
expect(attr).toEqual({ name: "test", value: "foo" });
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
test("setAttributeInAllVariants overwrite", async () => {
|
|
600
|
+
assert(productPublished, "product not created");
|
|
599
601
|
const response = await supertest(ctMock.app)
|
|
600
602
|
.post(`/dummy/products/${productPublished.id}`)
|
|
601
603
|
.send({
|
|
602
604
|
version: 1,
|
|
603
605
|
actions: [
|
|
604
606
|
{
|
|
605
|
-
action:
|
|
606
|
-
name:
|
|
607
|
-
value:
|
|
607
|
+
action: "setAttributeInAllVariants",
|
|
608
|
+
name: "test",
|
|
609
|
+
value: "foo",
|
|
608
610
|
},
|
|
609
611
|
],
|
|
610
|
-
})
|
|
611
|
-
expect(response.status).toBe(200)
|
|
612
|
-
|
|
613
|
-
expect(
|
|
614
|
-
|
|
615
|
-
).toHaveLength(1)
|
|
612
|
+
});
|
|
613
|
+
expect(response.status).toBe(200);
|
|
614
|
+
const product = response.body as Product;
|
|
615
|
+
expect(product.version).toBe(2);
|
|
616
|
+
expect(product.masterData.staged.masterVariant.attributes).toHaveLength(1);
|
|
616
617
|
|
|
617
618
|
const masterVariantAttr1 =
|
|
618
|
-
|
|
619
|
-
expect(masterVariantAttr1).toEqual({ name:
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
expect(variant.attributes).toHaveLength(2)
|
|
623
|
-
expect(variant.attributes[1]).toEqual({
|
|
624
|
-
name:
|
|
625
|
-
value:
|
|
626
|
-
})
|
|
627
|
-
})
|
|
628
|
-
})
|
|
629
|
-
|
|
630
|
-
test(
|
|
631
|
-
assert(productPublished,
|
|
619
|
+
product.masterData.staged.masterVariant.attributes?.[0];
|
|
620
|
+
expect(masterVariantAttr1).toEqual({ name: "test", value: "foo" });
|
|
621
|
+
|
|
622
|
+
product.masterData.staged.variants.forEach((variant) => {
|
|
623
|
+
expect(variant.attributes).toHaveLength(2);
|
|
624
|
+
expect(variant.attributes?.[1]).toEqual({
|
|
625
|
+
name: "test",
|
|
626
|
+
value: "foo",
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
test("setAttributeInAllVariants product staged", async () => {
|
|
632
|
+
assert(productPublished, "product not created");
|
|
632
633
|
const response = await supertest(ctMock.app)
|
|
633
634
|
.post(`/dummy/products/${productPublished.id}`)
|
|
634
635
|
.send({
|
|
635
636
|
version: 1,
|
|
636
637
|
actions: [
|
|
637
638
|
{
|
|
638
|
-
action:
|
|
639
|
-
name:
|
|
640
|
-
value:
|
|
639
|
+
action: "setAttributeInAllVariants",
|
|
640
|
+
name: "foo",
|
|
641
|
+
value: "bar",
|
|
641
642
|
},
|
|
642
643
|
],
|
|
643
|
-
})
|
|
644
|
-
expect(response.status).toBe(200)
|
|
645
|
-
|
|
646
|
-
expect(
|
|
647
|
-
|
|
648
|
-
).toHaveLength(2)
|
|
644
|
+
});
|
|
645
|
+
expect(response.status).toBe(200);
|
|
646
|
+
const product = response.body as Product;
|
|
647
|
+
expect(product.version).toBe(2);
|
|
648
|
+
expect(product.masterData.staged.masterVariant.attributes).toHaveLength(2);
|
|
649
649
|
const masterVariantAttr1 =
|
|
650
|
-
|
|
651
|
-
expect(masterVariantAttr1).toEqual({ name:
|
|
650
|
+
product.masterData.staged.masterVariant.attributes?.[0];
|
|
651
|
+
expect(masterVariantAttr1).toEqual({ name: "test", value: "test" });
|
|
652
652
|
|
|
653
653
|
const masterVariantAttr2 =
|
|
654
|
-
|
|
654
|
+
product.masterData.staged.masterVariant.attributes?.[1];
|
|
655
655
|
expect(masterVariantAttr2).toEqual({
|
|
656
|
-
name:
|
|
657
|
-
value:
|
|
658
|
-
})
|
|
659
|
-
|
|
660
|
-
expect(variant.attributes).toHaveLength(2)
|
|
661
|
-
expect(variant.attributes[1]).toEqual({
|
|
662
|
-
name:
|
|
663
|
-
value:
|
|
664
|
-
})
|
|
665
|
-
})
|
|
666
|
-
})
|
|
667
|
-
|
|
668
|
-
test(
|
|
669
|
-
assert(productPublished,
|
|
656
|
+
name: "foo",
|
|
657
|
+
value: "bar",
|
|
658
|
+
});
|
|
659
|
+
product.masterData.staged.variants.forEach((variant) => {
|
|
660
|
+
expect(variant.attributes).toHaveLength(2);
|
|
661
|
+
expect(variant.attributes?.[1]).toEqual({
|
|
662
|
+
name: "foo",
|
|
663
|
+
value: "bar",
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
test("setAttributeInAllVariants and publish", async () => {
|
|
669
|
+
assert(productPublished, "product not created");
|
|
670
670
|
|
|
671
671
|
const response = await supertest(ctMock.app)
|
|
672
672
|
.post(`/dummy/products/${productPublished.id}`)
|
|
673
673
|
.send({
|
|
674
674
|
version: 1,
|
|
675
675
|
actions: [
|
|
676
|
-
{ action:
|
|
677
|
-
{ action:
|
|
676
|
+
{ action: "setAttributeInAllVariants", name: "foo", value: "bar" },
|
|
677
|
+
{ action: "publish" },
|
|
678
678
|
],
|
|
679
|
-
})
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
expect(
|
|
683
|
-
|
|
684
|
-
).toHaveLength(2)
|
|
685
|
-
const attr =
|
|
686
|
-
expect(attr).toEqual({ name:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
expect(variant.attributes).toHaveLength(2)
|
|
690
|
-
expect(variant.attributes[1]).toEqual({
|
|
691
|
-
name:
|
|
692
|
-
value:
|
|
693
|
-
})
|
|
694
|
-
})
|
|
695
|
-
})
|
|
696
|
-
|
|
697
|
-
test(
|
|
698
|
-
assert(productPublished,
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
const product = response.body as Product;
|
|
682
|
+
expect(response.status).toBe(200);
|
|
683
|
+
expect(product.version).toBe(3);
|
|
684
|
+
expect(product.masterData.current.masterVariant.attributes).toHaveLength(2);
|
|
685
|
+
const attr = product.masterData.current.masterVariant.attributes?.[1];
|
|
686
|
+
expect(attr).toEqual({ name: "foo", value: "bar" });
|
|
687
|
+
|
|
688
|
+
product.masterData.current.variants.forEach((variant) => {
|
|
689
|
+
expect(variant.attributes).toHaveLength(2);
|
|
690
|
+
expect(variant.attributes?.[1]).toEqual({
|
|
691
|
+
name: "foo",
|
|
692
|
+
value: "bar",
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
test("addExternalImage variant", async () => {
|
|
698
|
+
assert(productPublished, "product not created");
|
|
699
699
|
|
|
700
700
|
const image: Image = {
|
|
701
|
-
url:
|
|
701
|
+
url: "http://example.com/image",
|
|
702
702
|
dimensions: { w: 100, h: 100 },
|
|
703
|
-
}
|
|
703
|
+
};
|
|
704
704
|
const response = await supertest(ctMock.app)
|
|
705
705
|
.post(`/dummy/products/${productPublished.id}`)
|
|
706
706
|
.send({
|
|
707
707
|
version: 1,
|
|
708
|
-
actions: [{ action:
|
|
709
|
-
})
|
|
710
|
-
expect(response.status).toBe(200)
|
|
711
|
-
expect(response.body.version).toBe(2)
|
|
712
|
-
expect(response.body.masterData.staged.variants[0].images).toHaveLength(1)
|
|
713
|
-
const attr = response.body.masterData.staged.variants[0].images[0]
|
|
714
|
-
expect(attr).toEqual(image)
|
|
715
|
-
})
|
|
716
|
-
|
|
717
|
-
test(
|
|
718
|
-
assert(productPublished,
|
|
708
|
+
actions: [{ action: "addExternalImage", sku: "1338", image }],
|
|
709
|
+
});
|
|
710
|
+
expect(response.status).toBe(200);
|
|
711
|
+
expect(response.body.version).toBe(2);
|
|
712
|
+
expect(response.body.masterData.staged.variants[0].images).toHaveLength(1);
|
|
713
|
+
const attr = response.body.masterData.staged.variants[0].images[0];
|
|
714
|
+
expect(attr).toEqual(image);
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
test("removeImage variant", async () => {
|
|
718
|
+
assert(productPublished, "product not created");
|
|
719
719
|
|
|
720
720
|
const image: Image = {
|
|
721
|
-
url:
|
|
721
|
+
url: "http://example.com/image",
|
|
722
722
|
dimensions: { w: 100, h: 100 },
|
|
723
|
-
}
|
|
723
|
+
};
|
|
724
724
|
|
|
725
725
|
{
|
|
726
726
|
const response = await supertest(ctMock.app)
|
|
727
727
|
.post(`/dummy/products/${productPublished.id}`)
|
|
728
728
|
.send({
|
|
729
729
|
version: 1,
|
|
730
|
-
actions: [{ action:
|
|
731
|
-
})
|
|
732
|
-
expect(response.status).toBe(200)
|
|
733
|
-
expect(response.body.version).toBe(2)
|
|
730
|
+
actions: [{ action: "addExternalImage", sku: "1338", image }],
|
|
731
|
+
});
|
|
732
|
+
expect(response.status).toBe(200);
|
|
733
|
+
expect(response.body.version).toBe(2);
|
|
734
734
|
}
|
|
735
735
|
|
|
736
736
|
const response = await supertest(ctMock.app)
|
|
@@ -739,28 +739,28 @@ describe('Product update actions', () => {
|
|
|
739
739
|
version: 2,
|
|
740
740
|
actions: [
|
|
741
741
|
{
|
|
742
|
-
action:
|
|
743
|
-
sku:
|
|
742
|
+
action: "removeImage",
|
|
743
|
+
sku: "1338",
|
|
744
744
|
imageUrl: image.url,
|
|
745
745
|
},
|
|
746
746
|
],
|
|
747
|
-
})
|
|
748
|
-
expect(response.status).toBe(200)
|
|
749
|
-
expect(response.body.version).toBe(3)
|
|
750
|
-
expect(response.body.masterData.staged.variants[0].images).toHaveLength(0)
|
|
751
|
-
})
|
|
747
|
+
});
|
|
748
|
+
expect(response.status).toBe(200);
|
|
749
|
+
expect(response.body.version).toBe(3);
|
|
750
|
+
expect(response.body.masterData.staged.variants[0].images).toHaveLength(0);
|
|
751
|
+
});
|
|
752
752
|
|
|
753
|
-
test(
|
|
754
|
-
assert(productPublished,
|
|
753
|
+
test("moveImageToPosition variant", async () => {
|
|
754
|
+
assert(productPublished, "product not created");
|
|
755
755
|
|
|
756
756
|
const image1: Image = {
|
|
757
|
-
url:
|
|
757
|
+
url: "http://example.com/image1",
|
|
758
758
|
dimensions: { w: 100, h: 100 },
|
|
759
|
-
}
|
|
759
|
+
};
|
|
760
760
|
const image2: Image = {
|
|
761
|
-
url:
|
|
761
|
+
url: "http://example.com/image2",
|
|
762
762
|
dimensions: { w: 100, h: 100 },
|
|
763
|
-
}
|
|
763
|
+
};
|
|
764
764
|
|
|
765
765
|
{
|
|
766
766
|
const response = await supertest(ctMock.app)
|
|
@@ -768,12 +768,12 @@ describe('Product update actions', () => {
|
|
|
768
768
|
.send({
|
|
769
769
|
version: 1,
|
|
770
770
|
actions: [
|
|
771
|
-
{ action:
|
|
772
|
-
{ action:
|
|
771
|
+
{ action: "addExternalImage", sku: "1338", image: image1 },
|
|
772
|
+
{ action: "addExternalImage", sku: "1338", image: image2 },
|
|
773
773
|
],
|
|
774
|
-
})
|
|
775
|
-
expect(response.status).toBe(200)
|
|
776
|
-
expect(response.body.version).toBe(3)
|
|
774
|
+
});
|
|
775
|
+
expect(response.status).toBe(200);
|
|
776
|
+
expect(response.body.version).toBe(3);
|
|
777
777
|
}
|
|
778
778
|
|
|
779
779
|
const response = await supertest(ctMock.app)
|
|
@@ -782,31 +782,31 @@ describe('Product update actions', () => {
|
|
|
782
782
|
version: 3,
|
|
783
783
|
actions: [
|
|
784
784
|
{
|
|
785
|
-
action:
|
|
786
|
-
sku:
|
|
785
|
+
action: "moveImageToPosition",
|
|
786
|
+
sku: "1338",
|
|
787
787
|
imageUrl: image2.url,
|
|
788
788
|
position: 0,
|
|
789
789
|
},
|
|
790
790
|
],
|
|
791
|
-
})
|
|
792
|
-
expect(response.status).toBe(200)
|
|
793
|
-
expect(response.body.version).toBe(4)
|
|
791
|
+
});
|
|
792
|
+
expect(response.status).toBe(200);
|
|
793
|
+
expect(response.body.version).toBe(4);
|
|
794
794
|
expect(response.body.masterData.staged.variants[0].images).toEqual([
|
|
795
|
-
{ url:
|
|
796
|
-
{ url:
|
|
797
|
-
])
|
|
798
|
-
})
|
|
795
|
+
{ url: "http://example.com/image2", dimensions: { w: 100, h: 100 } },
|
|
796
|
+
{ url: "http://example.com/image1", dimensions: { w: 100, h: 100 } },
|
|
797
|
+
]);
|
|
798
|
+
});
|
|
799
799
|
|
|
800
|
-
test(
|
|
801
|
-
assert(productPublished,
|
|
800
|
+
test("addPrice variant", async () => {
|
|
801
|
+
assert(productPublished, "product not created");
|
|
802
802
|
|
|
803
803
|
const priceDraft: PriceDraft = {
|
|
804
|
-
country:
|
|
804
|
+
country: "BE",
|
|
805
805
|
value: {
|
|
806
|
-
currencyCode:
|
|
806
|
+
currencyCode: "EUR",
|
|
807
807
|
centAmount: 3000,
|
|
808
808
|
},
|
|
809
|
-
}
|
|
809
|
+
};
|
|
810
810
|
|
|
811
811
|
const response = await supertest(ctMock.app)
|
|
812
812
|
.post(`/dummy/products/${productPublished.id}`)
|
|
@@ -814,49 +814,49 @@ describe('Product update actions', () => {
|
|
|
814
814
|
version: 1,
|
|
815
815
|
actions: [
|
|
816
816
|
{
|
|
817
|
-
action:
|
|
817
|
+
action: "addPrice",
|
|
818
818
|
price: priceDraft,
|
|
819
819
|
variantId: 1,
|
|
820
820
|
staged: false,
|
|
821
821
|
},
|
|
822
822
|
],
|
|
823
|
-
})
|
|
824
|
-
expect(response.status).toBe(200)
|
|
825
|
-
expect(response.body.version).toBe(2)
|
|
823
|
+
});
|
|
824
|
+
expect(response.status).toBe(200);
|
|
825
|
+
expect(response.body.version).toBe(2);
|
|
826
826
|
expect(response.body.masterData.staged.masterVariant.prices).toMatchObject([
|
|
827
827
|
{
|
|
828
|
-
country:
|
|
828
|
+
country: "NL",
|
|
829
829
|
value: {
|
|
830
|
-
currencyCode:
|
|
830
|
+
currencyCode: "EUR",
|
|
831
831
|
centAmount: 1000,
|
|
832
832
|
},
|
|
833
833
|
},
|
|
834
834
|
{
|
|
835
|
-
country:
|
|
835
|
+
country: "BE",
|
|
836
836
|
value: {
|
|
837
|
-
currencyCode:
|
|
837
|
+
currencyCode: "EUR",
|
|
838
838
|
centAmount: 3000,
|
|
839
839
|
},
|
|
840
840
|
},
|
|
841
|
-
])
|
|
841
|
+
]);
|
|
842
842
|
expect(response.body.masterData.staged.masterVariant.prices[1].id).toBe(
|
|
843
|
-
response.body.masterData.current.masterVariant.prices[1].id
|
|
844
|
-
)
|
|
845
|
-
})
|
|
843
|
+
response.body.masterData.current.masterVariant.prices[1].id,
|
|
844
|
+
);
|
|
845
|
+
});
|
|
846
846
|
|
|
847
|
-
test(
|
|
848
|
-
assert(productPublished,
|
|
847
|
+
test("changePrice variant", async () => {
|
|
848
|
+
assert(productPublished, "product not created");
|
|
849
849
|
const priceId =
|
|
850
|
-
productPublished?.masterData.current.masterVariant.prices?.[0].id
|
|
851
|
-
assert(priceId)
|
|
850
|
+
productPublished?.masterData.current.masterVariant.prices?.[0].id;
|
|
851
|
+
assert(priceId);
|
|
852
852
|
|
|
853
853
|
const priceDraft: PriceDraft = {
|
|
854
|
-
country:
|
|
854
|
+
country: "BE",
|
|
855
855
|
value: {
|
|
856
|
-
currencyCode:
|
|
856
|
+
currencyCode: "EUR",
|
|
857
857
|
centAmount: 3000,
|
|
858
858
|
},
|
|
859
|
-
}
|
|
859
|
+
};
|
|
860
860
|
|
|
861
861
|
const response = await supertest(ctMock.app)
|
|
862
862
|
.post(`/dummy/products/${productPublished.id}`)
|
|
@@ -864,31 +864,31 @@ describe('Product update actions', () => {
|
|
|
864
864
|
version: 1,
|
|
865
865
|
actions: [
|
|
866
866
|
{
|
|
867
|
-
action:
|
|
867
|
+
action: "changePrice",
|
|
868
868
|
priceId,
|
|
869
869
|
price: priceDraft,
|
|
870
870
|
},
|
|
871
871
|
],
|
|
872
|
-
})
|
|
873
|
-
expect(response.status).toBe(200)
|
|
874
|
-
expect(response.body.version).toBe(2)
|
|
872
|
+
});
|
|
873
|
+
expect(response.status).toBe(200);
|
|
874
|
+
expect(response.body.version).toBe(2);
|
|
875
875
|
expect(response.body.masterData.staged.masterVariant.prices).toMatchObject([
|
|
876
876
|
{
|
|
877
877
|
id: priceId,
|
|
878
|
-
country:
|
|
878
|
+
country: "BE",
|
|
879
879
|
value: {
|
|
880
|
-
currencyCode:
|
|
880
|
+
currencyCode: "EUR",
|
|
881
881
|
centAmount: 3000,
|
|
882
882
|
},
|
|
883
883
|
},
|
|
884
|
-
])
|
|
885
|
-
})
|
|
884
|
+
]);
|
|
885
|
+
});
|
|
886
886
|
|
|
887
|
-
test(
|
|
888
|
-
assert(productPublished,
|
|
887
|
+
test("removePrice variant", async () => {
|
|
888
|
+
assert(productPublished, "product not created");
|
|
889
889
|
const priceId =
|
|
890
|
-
productPublished?.masterData.current.masterVariant.prices?.[0].id
|
|
891
|
-
assert(priceId)
|
|
890
|
+
productPublished?.masterData.current.masterVariant.prices?.[0].id;
|
|
891
|
+
assert(priceId);
|
|
892
892
|
|
|
893
893
|
const response = await supertest(ctMock.app)
|
|
894
894
|
.post(`/dummy/products/${productPublished.id}`)
|
|
@@ -896,161 +896,163 @@ describe('Product update actions', () => {
|
|
|
896
896
|
version: 1,
|
|
897
897
|
actions: [
|
|
898
898
|
{
|
|
899
|
-
action:
|
|
899
|
+
action: "removePrice",
|
|
900
900
|
priceId,
|
|
901
901
|
},
|
|
902
902
|
],
|
|
903
|
-
})
|
|
904
|
-
expect(response.status).toBe(200)
|
|
905
|
-
expect(response.body.version).toBe(2)
|
|
906
|
-
expect(response.body.masterData.staged.masterVariant.prices).toHaveLength(
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
903
|
+
});
|
|
904
|
+
expect(response.status).toBe(200);
|
|
905
|
+
expect(response.body.version).toBe(2);
|
|
906
|
+
expect(response.body.masterData.staged.masterVariant.prices).toHaveLength(
|
|
907
|
+
0,
|
|
908
|
+
);
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
test("changeName product", async () => {
|
|
912
|
+
assert(productPublished, "product not created");
|
|
911
913
|
const response = await supertest(ctMock.app)
|
|
912
914
|
.post(`/dummy/products/${productPublished.id}`)
|
|
913
915
|
.send({
|
|
914
916
|
version: 1,
|
|
915
917
|
actions: [
|
|
916
918
|
{
|
|
917
|
-
action:
|
|
918
|
-
name:
|
|
919
|
+
action: "changeName",
|
|
920
|
+
name: "new test published product",
|
|
919
921
|
staged: false,
|
|
920
922
|
},
|
|
921
923
|
],
|
|
922
|
-
})
|
|
923
|
-
expect(response.status).toBe(200)
|
|
924
|
-
expect(response.body.version).toBe(2)
|
|
924
|
+
});
|
|
925
|
+
expect(response.status).toBe(200);
|
|
926
|
+
expect(response.body.version).toBe(2);
|
|
925
927
|
expect(response.body.masterData.staged.name).toBe(
|
|
926
|
-
|
|
927
|
-
)
|
|
928
|
+
"new test published product",
|
|
929
|
+
);
|
|
928
930
|
expect(response.body.masterData.current.name).toBe(
|
|
929
|
-
|
|
930
|
-
)
|
|
931
|
-
})
|
|
931
|
+
"new test published product",
|
|
932
|
+
);
|
|
933
|
+
});
|
|
932
934
|
|
|
933
|
-
test(
|
|
934
|
-
assert(productPublished,
|
|
935
|
+
test("changeSlug product", async () => {
|
|
936
|
+
assert(productPublished, "product not created");
|
|
935
937
|
const response = await supertest(ctMock.app)
|
|
936
938
|
.post(`/dummy/products/${productPublished.id}`)
|
|
937
939
|
.send({
|
|
938
940
|
version: 1,
|
|
939
941
|
actions: [
|
|
940
942
|
{
|
|
941
|
-
action:
|
|
943
|
+
action: "changeSlug",
|
|
942
944
|
slug: {
|
|
943
|
-
|
|
945
|
+
"nl-NL": "test-published-product-new",
|
|
944
946
|
},
|
|
945
947
|
staged: false,
|
|
946
948
|
},
|
|
947
949
|
],
|
|
948
|
-
})
|
|
949
|
-
expect(response.status).toBe(200)
|
|
950
|
-
expect(response.body.version).toBe(2)
|
|
950
|
+
});
|
|
951
|
+
expect(response.status).toBe(200);
|
|
952
|
+
expect(response.body.version).toBe(2);
|
|
951
953
|
expect(response.body.masterData.staged.slug).toMatchObject({
|
|
952
|
-
|
|
953
|
-
})
|
|
954
|
+
"nl-NL": "test-published-product-new",
|
|
955
|
+
});
|
|
954
956
|
expect(response.body.masterData.current.slug).toMatchObject({
|
|
955
|
-
|
|
956
|
-
})
|
|
957
|
-
})
|
|
957
|
+
"nl-NL": "test-published-product-new",
|
|
958
|
+
});
|
|
959
|
+
});
|
|
958
960
|
|
|
959
|
-
test(
|
|
960
|
-
assert(productPublished,
|
|
961
|
+
test("setMetaTitle product", async () => {
|
|
962
|
+
assert(productPublished, "product not created");
|
|
961
963
|
const response = await supertest(ctMock.app)
|
|
962
964
|
.post(`/dummy/products/${productPublished.id}`)
|
|
963
965
|
.send({
|
|
964
966
|
version: 1,
|
|
965
967
|
actions: [
|
|
966
968
|
{
|
|
967
|
-
action:
|
|
969
|
+
action: "setMetaTitle",
|
|
968
970
|
metaTitle: {
|
|
969
|
-
|
|
971
|
+
"nl-NL": "Unpublished product (new meta title)",
|
|
970
972
|
},
|
|
971
973
|
staged: false,
|
|
972
974
|
},
|
|
973
975
|
],
|
|
974
|
-
})
|
|
975
|
-
expect(response.status).toBe(200)
|
|
976
|
-
expect(response.body.version).toBe(2)
|
|
976
|
+
});
|
|
977
|
+
expect(response.status).toBe(200);
|
|
978
|
+
expect(response.body.version).toBe(2);
|
|
977
979
|
expect(response.body.masterData.staged.metaTitle).toMatchObject({
|
|
978
|
-
|
|
979
|
-
})
|
|
980
|
+
"nl-NL": "Unpublished product (new meta title)",
|
|
981
|
+
});
|
|
980
982
|
expect(response.body.masterData.current.metaTitle).toMatchObject({
|
|
981
|
-
|
|
982
|
-
})
|
|
983
|
-
})
|
|
983
|
+
"nl-NL": "Unpublished product (new meta title)",
|
|
984
|
+
});
|
|
985
|
+
});
|
|
984
986
|
|
|
985
|
-
test(
|
|
986
|
-
assert(productPublished,
|
|
987
|
+
test("setMetaDescription product", async () => {
|
|
988
|
+
assert(productPublished, "product not created");
|
|
987
989
|
const response = await supertest(ctMock.app)
|
|
988
990
|
.post(`/dummy/products/${productPublished.id}`)
|
|
989
991
|
.send({
|
|
990
992
|
version: 1,
|
|
991
993
|
actions: [
|
|
992
994
|
{
|
|
993
|
-
action:
|
|
995
|
+
action: "setMetaDescription",
|
|
994
996
|
metaDescription: {
|
|
995
|
-
|
|
997
|
+
"nl-NL": "Unpublished product description (new meta description)",
|
|
996
998
|
},
|
|
997
999
|
staged: false,
|
|
998
1000
|
},
|
|
999
1001
|
],
|
|
1000
|
-
})
|
|
1001
|
-
expect(response.status).toBe(200)
|
|
1002
|
-
expect(response.body.version).toBe(2)
|
|
1002
|
+
});
|
|
1003
|
+
expect(response.status).toBe(200);
|
|
1004
|
+
expect(response.body.version).toBe(2);
|
|
1003
1005
|
expect(response.body.masterData.staged.metaDescription).toMatchObject({
|
|
1004
|
-
|
|
1005
|
-
})
|
|
1006
|
+
"nl-NL": "Unpublished product description (new meta description)",
|
|
1007
|
+
});
|
|
1006
1008
|
expect(response.body.masterData.current.metaDescription).toMatchObject({
|
|
1007
|
-
|
|
1008
|
-
})
|
|
1009
|
-
})
|
|
1009
|
+
"nl-NL": "Unpublished product description (new meta description)",
|
|
1010
|
+
});
|
|
1011
|
+
});
|
|
1010
1012
|
|
|
1011
|
-
test(
|
|
1012
|
-
assert(productPublished,
|
|
1013
|
+
test("setMetaKeywords product", async () => {
|
|
1014
|
+
assert(productPublished, "product not created");
|
|
1013
1015
|
const response = await supertest(ctMock.app)
|
|
1014
1016
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1015
1017
|
.send({
|
|
1016
1018
|
version: 1,
|
|
1017
1019
|
actions: [
|
|
1018
1020
|
{
|
|
1019
|
-
action:
|
|
1021
|
+
action: "setMetaKeywords",
|
|
1020
1022
|
metaKeywords: {
|
|
1021
|
-
|
|
1023
|
+
"nl-NL": "Test product (newmeta Keywords)",
|
|
1022
1024
|
},
|
|
1023
1025
|
staged: false,
|
|
1024
1026
|
},
|
|
1025
1027
|
],
|
|
1026
|
-
})
|
|
1027
|
-
expect(response.status).toBe(200)
|
|
1028
|
-
expect(response.body.version).toBe(2)
|
|
1028
|
+
});
|
|
1029
|
+
expect(response.status).toBe(200);
|
|
1030
|
+
expect(response.body.version).toBe(2);
|
|
1029
1031
|
expect(response.body.masterData.staged.metaKeywords).toMatchObject({
|
|
1030
|
-
|
|
1031
|
-
})
|
|
1032
|
+
"nl-NL": "Test product (newmeta Keywords)",
|
|
1033
|
+
});
|
|
1032
1034
|
expect(response.body.masterData.current.metaKeywords).toMatchObject({
|
|
1033
|
-
|
|
1034
|
-
})
|
|
1035
|
-
})
|
|
1035
|
+
"nl-NL": "Test product (newmeta Keywords)",
|
|
1036
|
+
});
|
|
1037
|
+
});
|
|
1036
1038
|
|
|
1037
|
-
test(
|
|
1038
|
-
assert(productPublished,
|
|
1039
|
+
test("addVariant product", async () => {
|
|
1040
|
+
assert(productPublished, "product not created");
|
|
1039
1041
|
const response = await supertest(ctMock.app)
|
|
1040
1042
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1041
1043
|
.send({
|
|
1042
1044
|
version: 1,
|
|
1043
1045
|
actions: [
|
|
1044
1046
|
{
|
|
1045
|
-
action:
|
|
1046
|
-
sku:
|
|
1047
|
-
key:
|
|
1047
|
+
action: "addVariant",
|
|
1048
|
+
sku: "4567",
|
|
1049
|
+
key: "variant-2-key",
|
|
1048
1050
|
price: [
|
|
1049
1051
|
{
|
|
1050
|
-
key:
|
|
1051
|
-
country:
|
|
1052
|
+
key: "base_price_eur",
|
|
1053
|
+
country: "NL",
|
|
1052
1054
|
value: {
|
|
1053
|
-
currencyCode:
|
|
1055
|
+
currencyCode: "EUR",
|
|
1054
1056
|
centAmount: 3000,
|
|
1055
1057
|
},
|
|
1056
1058
|
},
|
|
@@ -1058,362 +1060,362 @@ describe('Product update actions', () => {
|
|
|
1058
1060
|
images: [],
|
|
1059
1061
|
attributes: [
|
|
1060
1062
|
{
|
|
1061
|
-
name:
|
|
1062
|
-
value:
|
|
1063
|
+
name: "test3",
|
|
1064
|
+
value: "test3",
|
|
1063
1065
|
},
|
|
1064
1066
|
],
|
|
1065
1067
|
assets: [],
|
|
1066
1068
|
staged: false,
|
|
1067
1069
|
},
|
|
1068
1070
|
],
|
|
1069
|
-
})
|
|
1070
|
-
expect(response.status).toBe(200)
|
|
1071
|
-
expect(response.body.version).toBe(2)
|
|
1072
|
-
expect(response.body.masterData.staged.variants).toHaveLength(2)
|
|
1073
|
-
expect(response.body.masterData.current.variants).toHaveLength(2)
|
|
1074
|
-
expect(response.body.masterData.staged.variants[1].id).toBe(3)
|
|
1075
|
-
expect(response.body.masterData.current.variants[1].id).toBe(3)
|
|
1076
|
-
})
|
|
1077
|
-
|
|
1078
|
-
test(
|
|
1079
|
-
assert(productPublished,
|
|
1071
|
+
});
|
|
1072
|
+
expect(response.status).toBe(200);
|
|
1073
|
+
expect(response.body.version).toBe(2);
|
|
1074
|
+
expect(response.body.masterData.staged.variants).toHaveLength(2);
|
|
1075
|
+
expect(response.body.masterData.current.variants).toHaveLength(2);
|
|
1076
|
+
expect(response.body.masterData.staged.variants[1].id).toBe(3);
|
|
1077
|
+
expect(response.body.masterData.current.variants[1].id).toBe(3);
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
test("removeVariant by id", async () => {
|
|
1081
|
+
assert(productPublished, "product not created");
|
|
1080
1082
|
const response = await supertest(ctMock.app)
|
|
1081
1083
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1082
1084
|
.send({
|
|
1083
1085
|
version: 1,
|
|
1084
1086
|
actions: [
|
|
1085
1087
|
{
|
|
1086
|
-
action:
|
|
1088
|
+
action: "removeVariant",
|
|
1087
1089
|
id: 2,
|
|
1088
1090
|
staged: false,
|
|
1089
1091
|
},
|
|
1090
1092
|
],
|
|
1091
|
-
})
|
|
1092
|
-
expect(response.status).toBe(200)
|
|
1093
|
-
expect(response.body.version).toBe(2)
|
|
1094
|
-
expect(response.body.masterData.staged.variants).toHaveLength(0)
|
|
1095
|
-
expect(response.body.masterData.current.variants).toHaveLength(0)
|
|
1096
|
-
})
|
|
1097
|
-
|
|
1098
|
-
test(
|
|
1099
|
-
assert(productPublished,
|
|
1093
|
+
});
|
|
1094
|
+
expect(response.status).toBe(200);
|
|
1095
|
+
expect(response.body.version).toBe(2);
|
|
1096
|
+
expect(response.body.masterData.staged.variants).toHaveLength(0);
|
|
1097
|
+
expect(response.body.masterData.current.variants).toHaveLength(0);
|
|
1098
|
+
});
|
|
1099
|
+
|
|
1100
|
+
test("removeVariant by sku", async () => {
|
|
1101
|
+
assert(productPublished, "product not created");
|
|
1100
1102
|
const response = await supertest(ctMock.app)
|
|
1101
1103
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1102
1104
|
.send({
|
|
1103
1105
|
version: 1,
|
|
1104
1106
|
actions: [
|
|
1105
1107
|
{
|
|
1106
|
-
action:
|
|
1107
|
-
sku:
|
|
1108
|
+
action: "removeVariant",
|
|
1109
|
+
sku: "1338",
|
|
1108
1110
|
staged: false,
|
|
1109
1111
|
},
|
|
1110
1112
|
],
|
|
1111
|
-
})
|
|
1112
|
-
expect(response.status).toBe(200)
|
|
1113
|
-
expect(response.body.version).toBe(2)
|
|
1114
|
-
expect(response.body.masterData.staged.variants).toHaveLength(0)
|
|
1115
|
-
expect(response.body.masterData.current.variants).toHaveLength(0)
|
|
1116
|
-
})
|
|
1117
|
-
|
|
1118
|
-
test(
|
|
1119
|
-
assert(productPublished,
|
|
1113
|
+
});
|
|
1114
|
+
expect(response.status).toBe(200);
|
|
1115
|
+
expect(response.body.version).toBe(2);
|
|
1116
|
+
expect(response.body.masterData.staged.variants).toHaveLength(0);
|
|
1117
|
+
expect(response.body.masterData.current.variants).toHaveLength(0);
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
test("removeVariant master", async () => {
|
|
1121
|
+
assert(productPublished, "product not created");
|
|
1120
1122
|
const response = await supertest(ctMock.app)
|
|
1121
1123
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1122
1124
|
.send({
|
|
1123
1125
|
version: 1,
|
|
1124
1126
|
actions: [
|
|
1125
1127
|
{
|
|
1126
|
-
action:
|
|
1128
|
+
action: "removeVariant",
|
|
1127
1129
|
id: 1,
|
|
1128
1130
|
staged: false,
|
|
1129
1131
|
},
|
|
1130
1132
|
],
|
|
1131
|
-
})
|
|
1132
|
-
expect(response.status).toBe(500)
|
|
1133
|
+
});
|
|
1134
|
+
expect(response.status).toBe(500);
|
|
1133
1135
|
expect(response.body.error).toBe(
|
|
1134
|
-
`Can not remove the variant [ID:1] for [Product:${productPublished.id}] since it's the master variant
|
|
1135
|
-
)
|
|
1136
|
-
})
|
|
1136
|
+
`Can not remove the variant [ID:1] for [Product:${productPublished.id}] since it's the master variant`,
|
|
1137
|
+
);
|
|
1138
|
+
});
|
|
1137
1139
|
|
|
1138
|
-
test(
|
|
1139
|
-
assert(productPublished,
|
|
1140
|
+
test("changeMasterVariant", async () => {
|
|
1141
|
+
assert(productPublished, "product not created");
|
|
1140
1142
|
const response = await supertest(ctMock.app)
|
|
1141
1143
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1142
1144
|
.send({
|
|
1143
1145
|
version: 1,
|
|
1144
1146
|
actions: [
|
|
1145
1147
|
{
|
|
1146
|
-
action:
|
|
1147
|
-
sku:
|
|
1148
|
+
action: "changeMasterVariant",
|
|
1149
|
+
sku: "1338",
|
|
1148
1150
|
staged: false,
|
|
1149
1151
|
},
|
|
1150
1152
|
],
|
|
1151
|
-
})
|
|
1152
|
-
expect(response.status).toBe(200)
|
|
1153
|
-
expect(response.body.version).toBe(2)
|
|
1154
|
-
expect(response.body.masterData.staged.variants).toHaveLength(1)
|
|
1155
|
-
expect(response.body.masterData.staged.masterVariant.id).toBe(2)
|
|
1156
|
-
expect(response.body.masterData.staged.variants[0].id).toBe(1)
|
|
1157
|
-
|
|
1158
|
-
expect(response.body.masterData.current.variants).toHaveLength(1)
|
|
1159
|
-
expect(response.body.masterData.current.masterVariant.id).toBe(2)
|
|
1160
|
-
expect(response.body.masterData.current.variants[0].id).toBe(1)
|
|
1161
|
-
})
|
|
1162
|
-
|
|
1163
|
-
test(
|
|
1164
|
-
assert(productPublished,
|
|
1153
|
+
});
|
|
1154
|
+
expect(response.status).toBe(200);
|
|
1155
|
+
expect(response.body.version).toBe(2);
|
|
1156
|
+
expect(response.body.masterData.staged.variants).toHaveLength(1);
|
|
1157
|
+
expect(response.body.masterData.staged.masterVariant.id).toBe(2);
|
|
1158
|
+
expect(response.body.masterData.staged.variants[0].id).toBe(1);
|
|
1159
|
+
|
|
1160
|
+
expect(response.body.masterData.current.variants).toHaveLength(1);
|
|
1161
|
+
expect(response.body.masterData.current.masterVariant.id).toBe(2);
|
|
1162
|
+
expect(response.body.masterData.current.variants[0].id).toBe(1);
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
test("changeMasterVariant same master", async () => {
|
|
1166
|
+
assert(productPublished, "product not created");
|
|
1165
1167
|
const response = await supertest(ctMock.app)
|
|
1166
1168
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1167
1169
|
.send({
|
|
1168
1170
|
version: 1,
|
|
1169
1171
|
actions: [
|
|
1170
1172
|
{
|
|
1171
|
-
action:
|
|
1173
|
+
action: "changeMasterVariant",
|
|
1172
1174
|
variantId: 1,
|
|
1173
1175
|
staged: false,
|
|
1174
1176
|
},
|
|
1175
1177
|
],
|
|
1176
|
-
})
|
|
1177
|
-
expect(response.status).toBe(200)
|
|
1178
|
-
expect(response.body.version).toBe(1)
|
|
1179
|
-
expect(response.body.masterData.staged.variants).toHaveLength(1)
|
|
1180
|
-
expect(response.body.masterData.staged.masterVariant.id).toBe(1)
|
|
1181
|
-
expect(response.body.masterData.staged.variants[0].id).toBe(2)
|
|
1182
|
-
|
|
1183
|
-
expect(response.body.masterData.current.variants).toHaveLength(1)
|
|
1184
|
-
expect(response.body.masterData.current.masterVariant.id).toBe(1)
|
|
1185
|
-
expect(response.body.masterData.current.variants[0].id).toBe(2)
|
|
1186
|
-
})
|
|
1187
|
-
|
|
1188
|
-
test(
|
|
1189
|
-
assert(productPublished,
|
|
1178
|
+
});
|
|
1179
|
+
expect(response.status).toBe(200);
|
|
1180
|
+
expect(response.body.version).toBe(1);
|
|
1181
|
+
expect(response.body.masterData.staged.variants).toHaveLength(1);
|
|
1182
|
+
expect(response.body.masterData.staged.masterVariant.id).toBe(1);
|
|
1183
|
+
expect(response.body.masterData.staged.variants[0].id).toBe(2);
|
|
1184
|
+
|
|
1185
|
+
expect(response.body.masterData.current.variants).toHaveLength(1);
|
|
1186
|
+
expect(response.body.masterData.current.masterVariant.id).toBe(1);
|
|
1187
|
+
expect(response.body.masterData.current.variants[0].id).toBe(2);
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
test("setTaxCategory", async () => {
|
|
1191
|
+
assert(productPublished, "product not created");
|
|
1190
1192
|
const response = await supertest(ctMock.app)
|
|
1191
1193
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1192
1194
|
.send({
|
|
1193
1195
|
version: 1,
|
|
1194
1196
|
actions: [
|
|
1195
1197
|
{
|
|
1196
|
-
action:
|
|
1198
|
+
action: "setTaxCategory",
|
|
1197
1199
|
taxCategory: {
|
|
1198
|
-
typeId:
|
|
1200
|
+
typeId: "tax-category",
|
|
1199
1201
|
id: taxCategory2.id,
|
|
1200
1202
|
},
|
|
1201
1203
|
},
|
|
1202
1204
|
],
|
|
1203
|
-
})
|
|
1204
|
-
expect(response.status).toBe(200)
|
|
1205
|
-
expect(response.body.taxCategory.id).toBe(taxCategory2.id)
|
|
1206
|
-
})
|
|
1207
|
-
|
|
1208
|
-
test(
|
|
1209
|
-
assert(productPublished,
|
|
1210
|
-
const fakeTaxCategoryId =
|
|
1205
|
+
});
|
|
1206
|
+
expect(response.status).toBe(200);
|
|
1207
|
+
expect(response.body.taxCategory.id).toBe(taxCategory2.id);
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
test("setTaxCategory fail 1", async () => {
|
|
1211
|
+
assert(productPublished, "product not created");
|
|
1212
|
+
const fakeTaxCategoryId = "00000000-0000-0000-0000-000000000000";
|
|
1211
1213
|
const response = await supertest(ctMock.app)
|
|
1212
1214
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1213
1215
|
.send({
|
|
1214
1216
|
version: 1,
|
|
1215
1217
|
actions: [
|
|
1216
1218
|
{
|
|
1217
|
-
action:
|
|
1219
|
+
action: "setTaxCategory",
|
|
1218
1220
|
taxCategory: {
|
|
1219
|
-
typeId:
|
|
1221
|
+
typeId: "tax-category",
|
|
1220
1222
|
id: fakeTaxCategoryId,
|
|
1221
1223
|
},
|
|
1222
1224
|
},
|
|
1223
1225
|
],
|
|
1224
|
-
})
|
|
1225
|
-
expect(response.status).toBe(400)
|
|
1226
|
-
expect(response.body.errors[0].code).toBe(
|
|
1227
|
-
})
|
|
1226
|
+
});
|
|
1227
|
+
expect(response.status).toBe(400);
|
|
1228
|
+
expect(response.body.errors[0].code).toBe("ReferencedResourceNotFound");
|
|
1229
|
+
});
|
|
1228
1230
|
|
|
1229
|
-
test(
|
|
1230
|
-
assert(productPublished,
|
|
1231
|
+
test("setTaxCategory fail 2", async () => {
|
|
1232
|
+
assert(productPublished, "product not created");
|
|
1231
1233
|
const response = await supertest(ctMock.app)
|
|
1232
1234
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1233
1235
|
.send({
|
|
1234
1236
|
version: 1,
|
|
1235
1237
|
actions: [
|
|
1236
1238
|
{
|
|
1237
|
-
action:
|
|
1239
|
+
action: "setTaxCategory",
|
|
1238
1240
|
taxCategory: {
|
|
1239
|
-
typeId:
|
|
1241
|
+
typeId: "tax-category",
|
|
1240
1242
|
},
|
|
1241
1243
|
},
|
|
1242
1244
|
],
|
|
1243
|
-
})
|
|
1244
|
-
expect(response.status).toBe(400)
|
|
1245
|
-
expect(response.body.errors[0].code).toBe(
|
|
1246
|
-
})
|
|
1245
|
+
});
|
|
1246
|
+
expect(response.status).toBe(400);
|
|
1247
|
+
expect(response.body.errors[0].code).toBe("InvalidJsonInput");
|
|
1248
|
+
});
|
|
1247
1249
|
|
|
1248
|
-
test(
|
|
1249
|
-
assert(productPublished,
|
|
1250
|
+
test("addToCategory by id", async () => {
|
|
1251
|
+
assert(productPublished, "product not created");
|
|
1250
1252
|
const response = await supertest(ctMock.app)
|
|
1251
1253
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1252
1254
|
.send({
|
|
1253
1255
|
version: 1,
|
|
1254
1256
|
actions: [
|
|
1255
1257
|
{
|
|
1256
|
-
action:
|
|
1258
|
+
action: "addToCategory",
|
|
1257
1259
|
category: {
|
|
1258
|
-
typeId:
|
|
1260
|
+
typeId: "category",
|
|
1259
1261
|
id: category2.id,
|
|
1260
1262
|
},
|
|
1261
1263
|
staged: false,
|
|
1262
1264
|
},
|
|
1263
1265
|
],
|
|
1264
|
-
})
|
|
1265
|
-
expect(response.status).toBe(200)
|
|
1266
|
-
expect(response.body.masterData.staged.categories).toHaveLength(2)
|
|
1267
|
-
expect(response.body.masterData.current.categories).toHaveLength(2)
|
|
1268
|
-
})
|
|
1269
|
-
|
|
1270
|
-
test(
|
|
1271
|
-
assert(productPublished,
|
|
1266
|
+
});
|
|
1267
|
+
expect(response.status).toBe(200);
|
|
1268
|
+
expect(response.body.masterData.staged.categories).toHaveLength(2);
|
|
1269
|
+
expect(response.body.masterData.current.categories).toHaveLength(2);
|
|
1270
|
+
});
|
|
1271
|
+
|
|
1272
|
+
test("addToCategory by key", async () => {
|
|
1273
|
+
assert(productPublished, "product not created");
|
|
1272
1274
|
const response = await supertest(ctMock.app)
|
|
1273
1275
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1274
1276
|
.send({
|
|
1275
1277
|
version: 1,
|
|
1276
1278
|
actions: [
|
|
1277
1279
|
{
|
|
1278
|
-
action:
|
|
1280
|
+
action: "addToCategory",
|
|
1279
1281
|
category: {
|
|
1280
|
-
typeId:
|
|
1282
|
+
typeId: "category",
|
|
1281
1283
|
key: category2.key,
|
|
1282
1284
|
},
|
|
1283
1285
|
staged: true,
|
|
1284
1286
|
},
|
|
1285
1287
|
],
|
|
1286
|
-
})
|
|
1287
|
-
expect(response.status).toBe(200)
|
|
1288
|
-
expect(response.body.masterData.staged.categories).toHaveLength(2)
|
|
1289
|
-
expect(response.body.masterData.current.categories).toHaveLength(1)
|
|
1290
|
-
})
|
|
1291
|
-
|
|
1292
|
-
test(
|
|
1293
|
-
assert(productPublished,
|
|
1294
|
-
const fakeCategoryId =
|
|
1288
|
+
});
|
|
1289
|
+
expect(response.status).toBe(200);
|
|
1290
|
+
expect(response.body.masterData.staged.categories).toHaveLength(2);
|
|
1291
|
+
expect(response.body.masterData.current.categories).toHaveLength(1);
|
|
1292
|
+
});
|
|
1293
|
+
|
|
1294
|
+
test("addToCategory fail 1", async () => {
|
|
1295
|
+
assert(productPublished, "product not created");
|
|
1296
|
+
const fakeCategoryId = "00000000-0000-0000-0000-000000000000";
|
|
1295
1297
|
const response = await supertest(ctMock.app)
|
|
1296
1298
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1297
1299
|
.send({
|
|
1298
1300
|
version: 1,
|
|
1299
1301
|
actions: [
|
|
1300
1302
|
{
|
|
1301
|
-
action:
|
|
1303
|
+
action: "addToCategory",
|
|
1302
1304
|
category: {
|
|
1303
|
-
typeId:
|
|
1305
|
+
typeId: "category",
|
|
1304
1306
|
id: fakeCategoryId,
|
|
1305
1307
|
},
|
|
1306
1308
|
staged: true,
|
|
1307
1309
|
},
|
|
1308
1310
|
],
|
|
1309
|
-
})
|
|
1310
|
-
expect(response.status).toBe(400)
|
|
1311
|
-
expect(response.body.errors[0].code).toBe(
|
|
1312
|
-
})
|
|
1311
|
+
});
|
|
1312
|
+
expect(response.status).toBe(400);
|
|
1313
|
+
expect(response.body.errors[0].code).toBe("ReferencedResourceNotFound");
|
|
1314
|
+
});
|
|
1313
1315
|
|
|
1314
|
-
test(
|
|
1315
|
-
assert(productPublished,
|
|
1316
|
+
test("addToCategory fail 2", async () => {
|
|
1317
|
+
assert(productPublished, "product not created");
|
|
1316
1318
|
const response = await supertest(ctMock.app)
|
|
1317
1319
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1318
1320
|
.send({
|
|
1319
1321
|
version: 1,
|
|
1320
1322
|
actions: [
|
|
1321
1323
|
{
|
|
1322
|
-
action:
|
|
1324
|
+
action: "addToCategory",
|
|
1323
1325
|
category: null,
|
|
1324
1326
|
staged: true,
|
|
1325
1327
|
},
|
|
1326
1328
|
],
|
|
1327
|
-
})
|
|
1328
|
-
expect(response.status).toBe(400)
|
|
1329
|
-
expect(response.body.errors[0].code).toBe(
|
|
1330
|
-
})
|
|
1329
|
+
});
|
|
1330
|
+
expect(response.status).toBe(400);
|
|
1331
|
+
expect(response.body.errors[0].code).toBe("InvalidJsonInput");
|
|
1332
|
+
});
|
|
1331
1333
|
|
|
1332
|
-
test(
|
|
1333
|
-
assert(productPublished,
|
|
1334
|
+
test("removeFromCategory", async () => {
|
|
1335
|
+
assert(productPublished, "product not created");
|
|
1334
1336
|
const response = await supertest(ctMock.app)
|
|
1335
1337
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1336
1338
|
.send({
|
|
1337
1339
|
version: 1,
|
|
1338
1340
|
actions: [
|
|
1339
1341
|
{
|
|
1340
|
-
action:
|
|
1342
|
+
action: "removeFromCategory",
|
|
1341
1343
|
category: {
|
|
1342
|
-
typeId:
|
|
1344
|
+
typeId: "category",
|
|
1343
1345
|
key: category1.key,
|
|
1344
1346
|
},
|
|
1345
1347
|
staged: false,
|
|
1346
1348
|
},
|
|
1347
1349
|
],
|
|
1348
|
-
})
|
|
1349
|
-
expect(response.status).toBe(200)
|
|
1350
|
-
expect(response.body.masterData.staged.categories).toHaveLength(0)
|
|
1351
|
-
expect(response.body.masterData.current.categories).toHaveLength(0)
|
|
1352
|
-
})
|
|
1353
|
-
|
|
1354
|
-
test(
|
|
1355
|
-
assert(productPublished,
|
|
1350
|
+
});
|
|
1351
|
+
expect(response.status).toBe(200);
|
|
1352
|
+
expect(response.body.masterData.staged.categories).toHaveLength(0);
|
|
1353
|
+
expect(response.body.masterData.current.categories).toHaveLength(0);
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
test("removeFromCategory fail 1", async () => {
|
|
1357
|
+
assert(productPublished, "product not created");
|
|
1356
1358
|
const response = await supertest(ctMock.app)
|
|
1357
1359
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1358
1360
|
.send({
|
|
1359
1361
|
version: 1,
|
|
1360
1362
|
actions: [
|
|
1361
1363
|
{
|
|
1362
|
-
action:
|
|
1364
|
+
action: "removeFromCategory",
|
|
1363
1365
|
category: {
|
|
1364
|
-
typeId:
|
|
1365
|
-
id:
|
|
1366
|
+
typeId: "category",
|
|
1367
|
+
id: "fake-category-id",
|
|
1366
1368
|
},
|
|
1367
1369
|
staged: false,
|
|
1368
1370
|
},
|
|
1369
1371
|
],
|
|
1370
|
-
})
|
|
1371
|
-
expect(response.status).toBe(400)
|
|
1372
|
-
expect(response.body.errors[0].code).toBe(
|
|
1373
|
-
})
|
|
1372
|
+
});
|
|
1373
|
+
expect(response.status).toBe(400);
|
|
1374
|
+
expect(response.body.errors[0].code).toBe("ReferencedResourceNotFound");
|
|
1375
|
+
});
|
|
1374
1376
|
|
|
1375
|
-
test(
|
|
1376
|
-
assert(productPublished,
|
|
1377
|
+
test("removeFromCategory fail 2", async () => {
|
|
1378
|
+
assert(productPublished, "product not created");
|
|
1377
1379
|
const response = await supertest(ctMock.app)
|
|
1378
1380
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1379
1381
|
.send({
|
|
1380
1382
|
version: 1,
|
|
1381
1383
|
actions: [
|
|
1382
1384
|
{
|
|
1383
|
-
action:
|
|
1385
|
+
action: "removeFromCategory",
|
|
1384
1386
|
category: {
|
|
1385
|
-
typeId:
|
|
1387
|
+
typeId: "category",
|
|
1386
1388
|
id: category2.id,
|
|
1387
1389
|
},
|
|
1388
1390
|
staged: false,
|
|
1389
1391
|
},
|
|
1390
1392
|
],
|
|
1391
|
-
})
|
|
1392
|
-
expect(response.status).toBe(400)
|
|
1393
|
-
expect(response.body.errors[0].code).toBe(
|
|
1394
|
-
})
|
|
1393
|
+
});
|
|
1394
|
+
expect(response.status).toBe(400);
|
|
1395
|
+
expect(response.body.errors[0].code).toBe("InvalidOperation");
|
|
1396
|
+
});
|
|
1395
1397
|
|
|
1396
|
-
test(
|
|
1397
|
-
assert(productPublished,
|
|
1398
|
+
test("transitionState", async () => {
|
|
1399
|
+
assert(productPublished, "product not created");
|
|
1398
1400
|
const response = await supertest(ctMock.app)
|
|
1399
1401
|
.post(`/dummy/products/${productPublished.id}`)
|
|
1400
1402
|
.send({
|
|
1401
1403
|
version: 1,
|
|
1402
1404
|
actions: [
|
|
1403
1405
|
{
|
|
1404
|
-
action:
|
|
1406
|
+
action: "transitionState",
|
|
1405
1407
|
state: {
|
|
1406
|
-
typeId:
|
|
1408
|
+
typeId: "state",
|
|
1407
1409
|
id: productState2.id,
|
|
1408
1410
|
},
|
|
1409
1411
|
force: false,
|
|
1410
1412
|
},
|
|
1411
1413
|
],
|
|
1412
|
-
})
|
|
1413
|
-
expect(response.status).toBe(200)
|
|
1414
|
+
});
|
|
1415
|
+
expect(response.status).toBe(200);
|
|
1414
1416
|
expect(response.body.state).toMatchObject({
|
|
1415
|
-
typeId:
|
|
1417
|
+
typeId: "state",
|
|
1416
1418
|
id: productState2.id,
|
|
1417
|
-
})
|
|
1418
|
-
})
|
|
1419
|
-
})
|
|
1419
|
+
});
|
|
1420
|
+
});
|
|
1421
|
+
});
|