@labdigital/commercetools-mock 2.27.0 → 2.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +72 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +72 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/oauth/server.test.ts +1 -0
- package/src/repositories/business-unit.ts +40 -8
- package/src/repositories/cart/actions.ts +8 -4
- package/src/repositories/customer/index.ts +1 -0
- package/src/repositories/helpers.ts +1 -2
- package/src/repositories/index.ts +2 -0
- package/src/repositories/order/actions.ts +22 -0
- package/src/repositories/product-tailoring.ts +34 -0
- package/src/repositories/shipping-method/actions.ts +10 -1
- package/src/repositories/shipping-method/index.ts +1 -0
- package/src/services/customer.test.ts +2 -0
- package/src/services/my-customer.test.ts +11 -3
- package/src/services/order.test.ts +161 -0
- package/src/services/shipping-method.test.ts +1 -0
- package/src/storage/in-memory.ts +2 -0
- package/src/types.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labdigital/commercetools-mock",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Michael van Tellingen",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@changesets/changelog-github": "^0.5.0",
|
|
36
36
|
"@changesets/cli": "^2.27.1",
|
|
37
|
-
"@commercetools/platform-sdk": "7.
|
|
37
|
+
"@commercetools/platform-sdk": "7.11.0",
|
|
38
38
|
"@stylistic/eslint-plugin": "^1.6.2",
|
|
39
39
|
"@types/basic-auth": "^1.1.8",
|
|
40
40
|
"@types/body-parser": "^1.19.5",
|
package/src/oauth/server.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BusinessUnitChangeApprovalRuleModeAction,
|
|
2
3
|
BusinessUnitChangeAssociateModeAction,
|
|
3
4
|
BusinessUnitChangeStatusAction,
|
|
4
5
|
BusinessUnitUpdateAction,
|
|
@@ -19,8 +20,8 @@ import {
|
|
|
19
20
|
type Company,
|
|
20
21
|
type Division,
|
|
21
22
|
} from "@commercetools/platform-sdk";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
23
|
+
import { AbstractStorage } from "~src/storage";
|
|
24
|
+
import { generateRandomString, getBaseResourceProperties } from "../helpers";
|
|
24
25
|
import { Writable } from "../types";
|
|
25
26
|
import {
|
|
26
27
|
AbstractResourceRepository,
|
|
@@ -43,6 +44,28 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
create(context: RepositoryContext, draft: BusinessUnitDraft): BusinessUnit {
|
|
47
|
+
const addresses =
|
|
48
|
+
draft.addresses?.map((address) => ({
|
|
49
|
+
...address,
|
|
50
|
+
id: generateRandomString(5),
|
|
51
|
+
})) ?? [];
|
|
52
|
+
|
|
53
|
+
const defaultBillingAddressId =
|
|
54
|
+
addresses.length > 0 && draft.defaultBillingAddress !== undefined
|
|
55
|
+
? addresses[draft.defaultBillingAddress].id
|
|
56
|
+
: undefined;
|
|
57
|
+
const defaultShippingAddressId =
|
|
58
|
+
addresses.length > 0 && draft.defaultShippingAddress !== undefined
|
|
59
|
+
? addresses[draft.defaultShippingAddress].id
|
|
60
|
+
: undefined;
|
|
61
|
+
|
|
62
|
+
const shippingAddressIds = draft.shippingAddresses?.map(
|
|
63
|
+
(i) => addresses[i].id,
|
|
64
|
+
);
|
|
65
|
+
const billingAddressIds = draft.billingAddresses?.map(
|
|
66
|
+
(i) => addresses[i].id,
|
|
67
|
+
);
|
|
68
|
+
|
|
46
69
|
const resource = {
|
|
47
70
|
...getBaseResourceProperties(),
|
|
48
71
|
key: draft.key,
|
|
@@ -53,18 +76,19 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business
|
|
|
53
76
|
storeMode: draft.storeMode,
|
|
54
77
|
name: draft.name,
|
|
55
78
|
contactEmail: draft.contactEmail,
|
|
56
|
-
addresses:
|
|
57
|
-
createAddress(a, context.projectKey, this._storage),
|
|
58
|
-
),
|
|
79
|
+
addresses: addresses,
|
|
59
80
|
custom: createCustomFields(
|
|
60
81
|
draft.custom,
|
|
61
82
|
context.projectKey,
|
|
62
83
|
this._storage,
|
|
63
84
|
),
|
|
64
|
-
shippingAddressIds:
|
|
65
|
-
|
|
66
|
-
|
|
85
|
+
shippingAddressIds: shippingAddressIds,
|
|
86
|
+
billingAddressIds: billingAddressIds,
|
|
87
|
+
defaultShippingAddressId: defaultShippingAddressId,
|
|
88
|
+
defaultBillingAddressId: defaultBillingAddressId,
|
|
67
89
|
associateMode: draft.associateMode,
|
|
90
|
+
approvalRuleMode: draft.approvalRuleMode,
|
|
91
|
+
|
|
68
92
|
associates: draft.associates?.map((a) =>
|
|
69
93
|
createAssociate(a, context.projectKey, this._storage),
|
|
70
94
|
),
|
|
@@ -170,6 +194,14 @@ class BusinessUnitUpdateHandler
|
|
|
170
194
|
}
|
|
171
195
|
}
|
|
172
196
|
|
|
197
|
+
changeApprovalRuleMode(
|
|
198
|
+
context: RepositoryContext,
|
|
199
|
+
resource: Writable<BusinessUnit>,
|
|
200
|
+
{ approvalRuleMode }: BusinessUnitChangeApprovalRuleModeAction,
|
|
201
|
+
) {
|
|
202
|
+
resource.approvalRuleMode = approvalRuleMode;
|
|
203
|
+
}
|
|
204
|
+
|
|
173
205
|
changeAssociateMode(
|
|
174
206
|
context: RepositoryContext,
|
|
175
207
|
resource: Writable<BusinessUnit>,
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
type ProductPagedQueryResponse,
|
|
31
31
|
type ProductVariant,
|
|
32
32
|
} from "@commercetools/platform-sdk";
|
|
33
|
+
import { DirectDiscount } from "@commercetools/platform-sdk/dist/declarations/src/generated/models/cart";
|
|
33
34
|
import { v4 as uuidv4 } from "uuid";
|
|
34
35
|
import { CommercetoolsError } from "~src/exceptions";
|
|
35
36
|
import type { Writable } from "~src/types";
|
|
@@ -419,10 +420,13 @@ export class CartUpdateHandler
|
|
|
419
420
|
{ discounts }: CartSetDirectDiscountsAction,
|
|
420
421
|
) {
|
|
421
422
|
// Doesn't apply any discounts logic, just sets the directDiscounts field
|
|
422
|
-
resource.directDiscounts = discounts.map(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
423
|
+
resource.directDiscounts = discounts.map(
|
|
424
|
+
(discount) =>
|
|
425
|
+
({
|
|
426
|
+
...discount,
|
|
427
|
+
id: uuidv4(),
|
|
428
|
+
}) as DirectDiscount,
|
|
429
|
+
);
|
|
426
430
|
}
|
|
427
431
|
|
|
428
432
|
setLineItemShippingDetails(
|
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
type StoreReference,
|
|
28
28
|
type StoreResourceIdentifier,
|
|
29
29
|
type Type,
|
|
30
|
-
type TypedMoney,
|
|
31
30
|
type _Money,
|
|
32
31
|
} from "@commercetools/platform-sdk";
|
|
33
32
|
import type { Request } from "express";
|
|
@@ -133,7 +132,7 @@ export const createCentPrecisionMoney = (value: _Money): CentPrecisionMoney => {
|
|
|
133
132
|
};
|
|
134
133
|
};
|
|
135
134
|
|
|
136
|
-
export const createTypedMoney = (value: _Money):
|
|
135
|
+
export const createTypedMoney = (value: _Money): CentPrecisionMoney => {
|
|
137
136
|
const result = createCentPrecisionMoney(value);
|
|
138
137
|
return result;
|
|
139
138
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProductTailoringRepository } from "~src/repositories/product-tailoring";
|
|
1
2
|
import { AbstractStorage } from "../storage";
|
|
2
3
|
import { AssociateRoleRepository } from "./associate-role";
|
|
3
4
|
import { AttributeGroupRepository } from "./attribute-group";
|
|
@@ -66,6 +67,7 @@ export const createRepositories = (storage: AbstractStorage) => ({
|
|
|
66
67
|
"product-discount": new ProductDiscountRepository(storage),
|
|
67
68
|
"product-projection": new ProductProjectionRepository(storage),
|
|
68
69
|
"product-selection": new ProductSelectionRepository(storage),
|
|
70
|
+
"product-tailoring": new ProductTailoringRepository(storage),
|
|
69
71
|
"project": new ProjectRepository(storage),
|
|
70
72
|
"review": new ReviewRepository(storage),
|
|
71
73
|
"quote": new QuoteRepository(storage),
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
OrderSetCustomTypeAction,
|
|
12
12
|
OrderSetCustomerEmailAction,
|
|
13
13
|
OrderSetCustomerIdAction,
|
|
14
|
+
OrderSetDeliveryCustomFieldAction,
|
|
14
15
|
OrderSetLocaleAction,
|
|
15
16
|
OrderSetOrderNumberAction,
|
|
16
17
|
OrderSetShippingAddressAction,
|
|
@@ -23,6 +24,7 @@ import type {
|
|
|
23
24
|
Store,
|
|
24
25
|
SyncInfo,
|
|
25
26
|
} from "@commercetools/platform-sdk";
|
|
27
|
+
import assert from "assert";
|
|
26
28
|
import { getBaseResourceProperties } from "~src/helpers";
|
|
27
29
|
import type { Writable } from "~src/types";
|
|
28
30
|
import {
|
|
@@ -180,6 +182,26 @@ export class OrderUpdateHandler
|
|
|
180
182
|
}
|
|
181
183
|
}
|
|
182
184
|
|
|
185
|
+
setDeliveryCustomField(
|
|
186
|
+
context: RepositoryContext,
|
|
187
|
+
resource: Writable<Order>,
|
|
188
|
+
{ deliveryId, name, value }: OrderSetDeliveryCustomFieldAction,
|
|
189
|
+
) {
|
|
190
|
+
assert(resource.shippingInfo, "shippingInfo is not defined");
|
|
191
|
+
|
|
192
|
+
if (Array.isArray(resource.shippingInfo.deliveries)) {
|
|
193
|
+
resource.shippingInfo.deliveries.map((delivery) => {
|
|
194
|
+
if (delivery.id !== deliveryId) throw "No matching delivery id found";
|
|
195
|
+
if (delivery.custom) {
|
|
196
|
+
const update = delivery.custom.fields;
|
|
197
|
+
update[name] = value;
|
|
198
|
+
Object.assign(delivery.custom.fields, update);
|
|
199
|
+
}
|
|
200
|
+
return delivery;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
183
205
|
setLocale(
|
|
184
206
|
context: RepositoryContext,
|
|
185
207
|
resource: Writable<Order>,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProductTailoring,
|
|
3
|
+
ProductTailoringUpdateAction,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { AbstractStorage } from "~src/storage";
|
|
6
|
+
import {
|
|
7
|
+
AbstractResourceRepository,
|
|
8
|
+
AbstractUpdateHandler,
|
|
9
|
+
RepositoryContext,
|
|
10
|
+
UpdateHandlerInterface,
|
|
11
|
+
} from "./abstract";
|
|
12
|
+
|
|
13
|
+
export class ProductTailoringRepository extends AbstractResourceRepository<"product-tailoring"> {
|
|
14
|
+
constructor(storage: AbstractStorage) {
|
|
15
|
+
super("product-tailoring", storage);
|
|
16
|
+
this.actions = new ProductTailoringUpdateHandler(this._storage);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
create(context: RepositoryContext, draft: any): ProductTailoring {
|
|
20
|
+
throw new Error("Create method for product-tailoring not implemented.");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class ProductTailoringUpdateHandler
|
|
25
|
+
extends AbstractUpdateHandler
|
|
26
|
+
implements
|
|
27
|
+
Partial<
|
|
28
|
+
UpdateHandlerInterface<ProductTailoring, ProductTailoringUpdateAction>
|
|
29
|
+
>
|
|
30
|
+
{
|
|
31
|
+
setSlug() {
|
|
32
|
+
throw new Error("SetSlug method for product-tailoring not implemented.");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type ShippingMethod,
|
|
5
5
|
type ShippingMethodAddShippingRateAction,
|
|
6
6
|
type ShippingMethodAddZoneAction,
|
|
7
|
+
type ShippingMethodChangeActiveAction,
|
|
7
8
|
type ShippingMethodChangeIsDefaultAction,
|
|
8
9
|
type ShippingMethodChangeNameAction,
|
|
9
10
|
type ShippingMethodRemoveZoneAction,
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
type ZoneReference,
|
|
19
20
|
} from "@commercetools/platform-sdk";
|
|
20
21
|
import deepEqual from "deep-equal";
|
|
21
|
-
import type { Writable } from "
|
|
22
|
+
import type { Writable } from "~src/types";
|
|
22
23
|
import {
|
|
23
24
|
AbstractUpdateHandler,
|
|
24
25
|
RepositoryContext,
|
|
@@ -83,6 +84,14 @@ export class ShippingMethodUpdateHandler
|
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
changeActive(
|
|
88
|
+
_context: RepositoryContext,
|
|
89
|
+
resource: Writable<ShippingMethod>,
|
|
90
|
+
{ active }: ShippingMethodChangeActiveAction,
|
|
91
|
+
) {
|
|
92
|
+
resource.active = active;
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
changeIsDefault(
|
|
87
96
|
_context: RepositoryContext,
|
|
88
97
|
resource: Writable<ShippingMethod>,
|
|
@@ -35,6 +35,7 @@ export class ShippingMethodRepository extends AbstractResourceRepository<"shippi
|
|
|
35
35
|
const resource: ShippingMethod = {
|
|
36
36
|
...getBaseResourceProperties(),
|
|
37
37
|
...draft,
|
|
38
|
+
active: draft.active ?? true,
|
|
38
39
|
taxCategory: getReferenceFromResourceIdentifier(
|
|
39
40
|
draft.taxCategory,
|
|
40
41
|
context.projectKey,
|
|
@@ -20,6 +20,7 @@ describe("Customer Update Actions", () => {
|
|
|
20
20
|
isEmailVerified: true,
|
|
21
21
|
authenticationMode: "Password", //default in Commercetools
|
|
22
22
|
version: 1,
|
|
23
|
+
stores: [],
|
|
23
24
|
};
|
|
24
25
|
ctMock.project("dummy").add("customer", customer);
|
|
25
26
|
});
|
|
@@ -467,6 +468,7 @@ describe("Customer Password Reset", () => {
|
|
|
467
468
|
isEmailVerified: true,
|
|
468
469
|
authenticationMode: "password",
|
|
469
470
|
custom: { type: { typeId: "type", id: "" }, fields: {} },
|
|
471
|
+
stores: [],
|
|
470
472
|
});
|
|
471
473
|
});
|
|
472
474
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Customer,
|
|
2
3
|
CustomerChangePassword,
|
|
3
4
|
CustomerToken,
|
|
4
5
|
MyCustomerDraft,
|
|
@@ -37,6 +38,7 @@ describe("Me", () => {
|
|
|
37
38
|
id: expect.anything(),
|
|
38
39
|
createdAt: expect.anything(),
|
|
39
40
|
lastModifiedAt: expect.anything(),
|
|
41
|
+
stores: [],
|
|
40
42
|
},
|
|
41
43
|
});
|
|
42
44
|
});
|
|
@@ -73,6 +75,7 @@ describe("/me", () => {
|
|
|
73
75
|
isEmailVerified: true,
|
|
74
76
|
authenticationMode: "password",
|
|
75
77
|
custom: { type: { typeId: "type", id: "" }, fields: {} },
|
|
78
|
+
stores: [],
|
|
76
79
|
});
|
|
77
80
|
});
|
|
78
81
|
|
|
@@ -96,6 +99,7 @@ describe("/me", () => {
|
|
|
96
99
|
typeId: "type",
|
|
97
100
|
},
|
|
98
101
|
},
|
|
102
|
+
stores: [],
|
|
99
103
|
});
|
|
100
104
|
});
|
|
101
105
|
|
|
@@ -119,6 +123,7 @@ describe("/me", () => {
|
|
|
119
123
|
typeId: "type",
|
|
120
124
|
},
|
|
121
125
|
},
|
|
126
|
+
stores: [],
|
|
122
127
|
});
|
|
123
128
|
|
|
124
129
|
const newResponse = await supertest(ctMock.app).get("/dummy/me");
|
|
@@ -126,7 +131,7 @@ describe("/me", () => {
|
|
|
126
131
|
});
|
|
127
132
|
|
|
128
133
|
test("Change my password", async () => {
|
|
129
|
-
const customer = {
|
|
134
|
+
const customer: Customer = {
|
|
130
135
|
...getBaseResourceProperties(),
|
|
131
136
|
id: "customer-uuid",
|
|
132
137
|
email: "user@example.com",
|
|
@@ -135,6 +140,7 @@ describe("/me", () => {
|
|
|
135
140
|
isEmailVerified: true,
|
|
136
141
|
authenticationMode: "Password", //default in Commercetools
|
|
137
142
|
version: 1,
|
|
143
|
+
stores: [],
|
|
138
144
|
};
|
|
139
145
|
ctMock.project("dummy").add("customer", customer);
|
|
140
146
|
|
|
@@ -176,7 +182,7 @@ describe("/me", () => {
|
|
|
176
182
|
});
|
|
177
183
|
|
|
178
184
|
test("reset password flow", async () => {
|
|
179
|
-
const customer = {
|
|
185
|
+
const customer: Customer = {
|
|
180
186
|
...getBaseResourceProperties(),
|
|
181
187
|
id: "customer-uuid",
|
|
182
188
|
email: "user@example.com",
|
|
@@ -185,6 +191,7 @@ describe("/me", () => {
|
|
|
185
191
|
isEmailVerified: true,
|
|
186
192
|
authenticationMode: "Password", //default in Commercetools
|
|
187
193
|
version: 1,
|
|
194
|
+
stores: [],
|
|
188
195
|
};
|
|
189
196
|
ctMock.project("dummy").add("customer", customer);
|
|
190
197
|
|
|
@@ -225,7 +232,7 @@ describe("/me", () => {
|
|
|
225
232
|
});
|
|
226
233
|
|
|
227
234
|
test("verify email flow", async () => {
|
|
228
|
-
const customer = {
|
|
235
|
+
const customer: Customer = {
|
|
229
236
|
...getBaseResourceProperties(),
|
|
230
237
|
id: "customer-uuid",
|
|
231
238
|
email: "user@example.com",
|
|
@@ -234,6 +241,7 @@ describe("/me", () => {
|
|
|
234
241
|
isEmailVerified: false,
|
|
235
242
|
authenticationMode: "Password", //default in Commercetools
|
|
236
243
|
version: 1,
|
|
244
|
+
stores: [],
|
|
237
245
|
};
|
|
238
246
|
ctMock.project("dummy").add("customer", customer);
|
|
239
247
|
|
|
@@ -2,6 +2,7 @@ import type { Order, Payment, State } from "@commercetools/platform-sdk";
|
|
|
2
2
|
import assert from "assert";
|
|
3
3
|
import supertest from "supertest";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
5
|
+
import { generateRandomString } from "~src/helpers";
|
|
5
6
|
import { CommercetoolsMock, getBaseResourceProperties } from "../index";
|
|
6
7
|
|
|
7
8
|
describe("Order Query", () => {
|
|
@@ -402,6 +403,166 @@ describe("Order Update Actions", () => {
|
|
|
402
403
|
expect(response.body.paymentState).toBe("Failed");
|
|
403
404
|
});
|
|
404
405
|
|
|
406
|
+
test("setDeliveryCustomField", async () => {
|
|
407
|
+
const order: Order = {
|
|
408
|
+
...getBaseResourceProperties(),
|
|
409
|
+
customLineItems: [],
|
|
410
|
+
lastMessageSequenceNumber: 0,
|
|
411
|
+
lineItems: [],
|
|
412
|
+
orderNumber: "1389",
|
|
413
|
+
orderState: "Open",
|
|
414
|
+
origin: "Customer",
|
|
415
|
+
paymentInfo: {
|
|
416
|
+
payments: [
|
|
417
|
+
{
|
|
418
|
+
typeId: "payment",
|
|
419
|
+
id: generateRandomString(10),
|
|
420
|
+
},
|
|
421
|
+
],
|
|
422
|
+
},
|
|
423
|
+
refusedGifts: [],
|
|
424
|
+
shippingInfo: {
|
|
425
|
+
shippingMethodName: "Home delivery (package)",
|
|
426
|
+
price: {
|
|
427
|
+
type: "centPrecision",
|
|
428
|
+
currencyCode: "EUR",
|
|
429
|
+
centAmount: 999,
|
|
430
|
+
fractionDigits: 2,
|
|
431
|
+
},
|
|
432
|
+
shippingRate: {
|
|
433
|
+
price: {
|
|
434
|
+
type: "centPrecision",
|
|
435
|
+
currencyCode: "EUR",
|
|
436
|
+
centAmount: 999,
|
|
437
|
+
fractionDigits: 2,
|
|
438
|
+
},
|
|
439
|
+
tiers: [
|
|
440
|
+
{
|
|
441
|
+
type: "CartScore",
|
|
442
|
+
score: 24,
|
|
443
|
+
price: {
|
|
444
|
+
type: "centPrecision",
|
|
445
|
+
currencyCode: "EUR",
|
|
446
|
+
centAmount: 1998,
|
|
447
|
+
fractionDigits: 2,
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
type: "CartScore",
|
|
452
|
+
score: 47,
|
|
453
|
+
price: {
|
|
454
|
+
type: "centPrecision",
|
|
455
|
+
currencyCode: "EUR",
|
|
456
|
+
centAmount: 2997,
|
|
457
|
+
fractionDigits: 2,
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
type: "CartScore",
|
|
462
|
+
score: 70,
|
|
463
|
+
price: {
|
|
464
|
+
type: "centPrecision",
|
|
465
|
+
currencyCode: "EUR",
|
|
466
|
+
centAmount: 3996,
|
|
467
|
+
fractionDigits: 2,
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
type: "CartScore",
|
|
472
|
+
score: 93,
|
|
473
|
+
price: {
|
|
474
|
+
type: "centPrecision",
|
|
475
|
+
currencyCode: "EUR",
|
|
476
|
+
centAmount: 4995,
|
|
477
|
+
fractionDigits: 2,
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
],
|
|
481
|
+
},
|
|
482
|
+
deliveries: [
|
|
483
|
+
{
|
|
484
|
+
id: "6a458cad-dd46-4f5f-8b73-debOede6a17d",
|
|
485
|
+
key: "CT-Z243002",
|
|
486
|
+
createdAt: "2024-07-29T13:37:48.047Z",
|
|
487
|
+
items: [
|
|
488
|
+
{
|
|
489
|
+
id: "5d209544-2892-45c9-bef0-dde4e250188e",
|
|
490
|
+
quantity: 1,
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
parcels: [],
|
|
494
|
+
custom: {
|
|
495
|
+
type: {
|
|
496
|
+
typeId: "type",
|
|
497
|
+
id: "c493b7bb-d415-450c-b421-e128a8b26569",
|
|
498
|
+
},
|
|
499
|
+
fields: {
|
|
500
|
+
location: "test",
|
|
501
|
+
status: "created",
|
|
502
|
+
carrier: "test_carrier",
|
|
503
|
+
},
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
],
|
|
507
|
+
shippingMethodState: "MatchesCart",
|
|
508
|
+
},
|
|
509
|
+
shipping: [],
|
|
510
|
+
shippingMode: "Single",
|
|
511
|
+
syncInfo: [],
|
|
512
|
+
totalPrice: {
|
|
513
|
+
type: "centPrecision",
|
|
514
|
+
fractionDigits: 2,
|
|
515
|
+
centAmount: 2000,
|
|
516
|
+
currencyCode: "EUR",
|
|
517
|
+
},
|
|
518
|
+
};
|
|
519
|
+
ctMock.project("dummy").add("order", order);
|
|
520
|
+
|
|
521
|
+
const response = await supertest(ctMock.app).get(
|
|
522
|
+
`/dummy/orders/order-number=${order.orderNumber}`,
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
// check if status is set
|
|
526
|
+
const _updateResponse = await supertest(ctMock.app)
|
|
527
|
+
.post(`/dummy/orders/${response.body.id}`)
|
|
528
|
+
.send({
|
|
529
|
+
version: 0,
|
|
530
|
+
actions: [
|
|
531
|
+
{
|
|
532
|
+
action: "setDeliveryCustomField",
|
|
533
|
+
deliveryId: "6a458cad-dd46-4f5f-8b73-debOede6a17d",
|
|
534
|
+
name: "status",
|
|
535
|
+
value: "delayed",
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
});
|
|
539
|
+
expect(_updateResponse.status).toBe(200);
|
|
540
|
+
expect(_updateResponse.body.version).toBe(1);
|
|
541
|
+
expect(
|
|
542
|
+
_updateResponse.body.shippingInfo.deliveries[0].custom.fields.status,
|
|
543
|
+
).toBe("delayed");
|
|
544
|
+
|
|
545
|
+
// check if other field can be set
|
|
546
|
+
const _updateResponse2 = await supertest(ctMock.app)
|
|
547
|
+
.post(`/dummy/orders/${response.body.id}`)
|
|
548
|
+
.send({
|
|
549
|
+
version: 1,
|
|
550
|
+
actions: [
|
|
551
|
+
{
|
|
552
|
+
action: "setDeliveryCustomField",
|
|
553
|
+
deliveryId: "6a458cad-dd46-4f5f-8b73-debOede6a17d",
|
|
554
|
+
name: "carrier",
|
|
555
|
+
value: "dhl",
|
|
556
|
+
},
|
|
557
|
+
],
|
|
558
|
+
});
|
|
559
|
+
expect(_updateResponse2.status).toBe(200);
|
|
560
|
+
expect(_updateResponse2.body.version).toBe(2);
|
|
561
|
+
expect(
|
|
562
|
+
_updateResponse2.body.shippingInfo.deliveries[0].custom.fields.carrier,
|
|
563
|
+
).toBe("dhl");
|
|
564
|
+
});
|
|
565
|
+
|
|
405
566
|
test("updateSyncInfo", async () => {
|
|
406
567
|
assert(order, "order not created");
|
|
407
568
|
|
package/src/storage/in-memory.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type Product,
|
|
23
23
|
type ProductDiscount,
|
|
24
24
|
type ProductProjection,
|
|
25
|
+
type ProductTailoring,
|
|
25
26
|
type ProductType,
|
|
26
27
|
type Project,
|
|
27
28
|
type Quote,
|
|
@@ -189,6 +190,7 @@ export class InMemoryStorage extends AbstractStorage {
|
|
|
189
190
|
"product-selection": new Map<string, any>(),
|
|
190
191
|
"product-type": new Map<string, ProductType>(),
|
|
191
192
|
"product-projection": new Map<string, ProductProjection>(),
|
|
193
|
+
"product-tailoring": new Map<string, ProductTailoring>(),
|
|
192
194
|
"review": new Map<string, any>(),
|
|
193
195
|
"shipping-method": new Map<string, ShippingMethod>(),
|
|
194
196
|
"staged-quote": new Map<string, StagedQuote>(),
|
package/src/types.ts
CHANGED
|
@@ -45,6 +45,7 @@ export type ResourceMap = {
|
|
|
45
45
|
"product-price": ctp.StandalonePrice;
|
|
46
46
|
"product-projection": ctp.ProductProjection;
|
|
47
47
|
"product-selection": ctp.ProductSelection;
|
|
48
|
+
"product-tailoring": ctp.ProductTailoring;
|
|
48
49
|
"product-type": ctp.ProductType;
|
|
49
50
|
"product": ctp.Product;
|
|
50
51
|
"quote-request": ctp.QuoteRequest;
|
|
@@ -85,6 +86,7 @@ export type PagedQueryResponseMap = {
|
|
|
85
86
|
"product-price": ctp.StandalonePricePagedQueryResponse;
|
|
86
87
|
"product-projection": ctp.ProductProjectionPagedQueryResponse;
|
|
87
88
|
"product-selection": ctp.ProductSelectionPagedQueryResponse;
|
|
89
|
+
"product-tailoring": ctp.ProductTailoringPagedQueryResponse;
|
|
88
90
|
"product-type": ctp.ProductTypePagedQueryResponse;
|
|
89
91
|
"product": ctp.ProductPagedQueryResponse;
|
|
90
92
|
"quote-request": ctp.QuoteRequestPagedQueryResponse;
|