@labdigital/commercetools-mock 2.65.1 → 3.0.0-beta.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/README.md +31 -8
- package/dist/abstract-BKFcva6S.mjs +1044 -0
- package/dist/abstract-BKFcva6S.mjs.map +1 -0
- package/dist/config-BcNSzPZz.d.mts +1718 -0
- package/dist/index.d.mts +50 -1633
- package/dist/index.mjs +3771 -2654
- package/dist/index.mjs.map +1 -1
- package/dist/storage/sqlite.d.mts +59 -0
- package/dist/storage/sqlite.mjs +234 -0
- package/dist/storage/sqlite.mjs.map +1 -0
- package/package.json +26 -29
- package/src/ctMock.ts +125 -136
- package/src/helpers.ts +14 -6
- package/src/index.ts +5 -0
- package/src/lib/masking.ts +4 -5
- package/src/lib/product-review-statistics.test.ts +257 -294
- package/src/lib/review-statistics.ts +17 -4
- package/src/oauth/helpers.ts +7 -4
- package/src/oauth/server.test.ts +102 -62
- package/src/oauth/server.ts +215 -213
- package/src/oauth/store.ts +20 -6
- package/src/orderSearch.ts +3 -3
- package/src/product-projection-search.ts +38 -20
- package/src/product-search-availability.test.ts +31 -52
- package/src/product-search.ts +19 -10
- package/src/projectAPI.ts +6 -22
- package/src/repositories/abstract.ts +182 -48
- package/src/repositories/as-associate.test.ts +19 -19
- package/src/repositories/associate-role.ts +12 -23
- package/src/repositories/attribute-group.test.ts +23 -23
- package/src/repositories/attribute-group.ts +6 -4
- package/src/repositories/business-unit.test.ts +63 -57
- package/src/repositories/business-unit.ts +107 -55
- package/src/repositories/cart/actions.ts +96 -65
- package/src/repositories/cart/helpers.ts +15 -11
- package/src/repositories/cart/index.test.ts +136 -30
- package/src/repositories/cart/index.ts +76 -59
- package/src/repositories/cart-discount/actions.ts +12 -44
- package/src/repositories/cart-discount/index.ts +20 -8
- package/src/repositories/category/actions.ts +27 -27
- package/src/repositories/category/index.test.ts +13 -9
- package/src/repositories/category/index.ts +40 -23
- package/src/repositories/channel.test.ts +53 -51
- package/src/repositories/channel.ts +12 -22
- package/src/repositories/custom-object.ts +34 -25
- package/src/repositories/customer/actions.ts +47 -25
- package/src/repositories/customer/index.test.ts +11 -11
- package/src/repositories/customer/index.ts +65 -35
- package/src/repositories/customer-group.test.ts +44 -42
- package/src/repositories/customer-group.ts +12 -22
- package/src/repositories/discount-code/actions.ts +3 -19
- package/src/repositories/discount-code/index.ts +9 -4
- package/src/repositories/discount-group/index.ts +8 -3
- package/src/repositories/extension.test.ts +27 -27
- package/src/repositories/extension.ts +10 -5
- package/src/repositories/helpers.ts +126 -47
- package/src/repositories/inventory-entry/actions.ts +3 -24
- package/src/repositories/inventory-entry/index.ts +19 -11
- package/src/repositories/my-customer.ts +13 -12
- package/src/repositories/my-order.ts +5 -2
- package/src/repositories/order/actions.ts +89 -56
- package/src/repositories/order/index.test.ts +36 -31
- package/src/repositories/order/index.ts +83 -49
- package/src/repositories/order-edit.ts +8 -3
- package/src/repositories/payment/actions.ts +64 -44
- package/src/repositories/payment/helpers.ts +3 -3
- package/src/repositories/payment/index.ts +28 -12
- package/src/repositories/product/actions.ts +133 -98
- package/src/repositories/product/helpers.ts +29 -16
- package/src/repositories/product/index.ts +42 -25
- package/src/repositories/product-discount.ts +6 -4
- package/src/repositories/product-projection.ts +41 -21
- package/src/repositories/product-selection.ts +8 -15
- package/src/repositories/product-tailoring.ts +22 -3
- package/src/repositories/product-type.ts +45 -4
- package/src/repositories/project.ts +57 -13
- package/src/repositories/quote/actions.ts +5 -28
- package/src/repositories/quote/index.ts +29 -6
- package/src/repositories/quote-request/actions.ts +5 -28
- package/src/repositories/quote-request/index.test.ts +3 -3
- package/src/repositories/quote-request/index.ts +31 -11
- package/src/repositories/quote-staged/actions.ts +5 -28
- package/src/repositories/quote-staged/index.ts +22 -8
- package/src/repositories/recurrence-policy/index.ts +6 -4
- package/src/repositories/recurring-order/actions.ts +7 -32
- package/src/repositories/recurring-order/index.ts +8 -6
- package/src/repositories/review.test.ts +147 -142
- package/src/repositories/review.ts +31 -37
- package/src/repositories/shipping-method/actions.ts +11 -28
- package/src/repositories/shipping-method/index.ts +26 -15
- package/src/repositories/shopping-list/actions.ts +21 -31
- package/src/repositories/shopping-list/index.ts +44 -22
- package/src/repositories/standalone-price.ts +6 -4
- package/src/repositories/state.ts +15 -9
- package/src/repositories/store.ts +21 -32
- package/src/repositories/subscription.test.ts +22 -22
- package/src/repositories/subscription.ts +8 -3
- package/src/repositories/tax-category/index.ts +8 -3
- package/src/repositories/type/actions.ts +21 -3
- package/src/repositories/type/index.ts +5 -3
- package/src/repositories/zone.test.ts +112 -77
- package/src/repositories/zone.ts +5 -3
- package/src/schemas/generated/associate-role.ts +13 -0
- package/src/schemas/generated/attribute-group.ts +12 -0
- package/src/schemas/generated/business-unit.ts +38 -0
- package/src/schemas/generated/cart-discount.ts +33 -0
- package/src/schemas/generated/cart.ts +61 -0
- package/src/schemas/generated/category.ts +25 -0
- package/src/schemas/generated/channel.ts +21 -0
- package/src/schemas/generated/common.ts +1372 -0
- package/src/schemas/generated/custom-object.ts +11 -0
- package/src/schemas/generated/customer-group.ts +11 -0
- package/src/schemas/generated/customer.ts +47 -0
- package/src/schemas/generated/discount-code.ts +25 -0
- package/src/schemas/generated/discount-group.ts +13 -0
- package/src/schemas/generated/extension.ts +15 -0
- package/src/schemas/generated/index.ts +42 -0
- package/src/schemas/generated/inventory-entry.ts +20 -0
- package/src/schemas/generated/my-quote-request.ts +10 -0
- package/src/schemas/generated/order-edit.ts +18 -0
- package/src/schemas/generated/order-from-cart.ts +25 -0
- package/src/schemas/generated/payment.ts +30 -0
- package/src/schemas/generated/product-discount.ts +20 -0
- package/src/schemas/generated/product-selection.ts +18 -0
- package/src/schemas/generated/product-tailoring.ts +26 -0
- package/src/schemas/generated/product-type.ts +12 -0
- package/src/schemas/generated/product.ts +37 -0
- package/src/schemas/generated/quote-request.ts +19 -0
- package/src/schemas/generated/quote.ts +18 -0
- package/src/schemas/generated/recurrence-policy.ts +15 -0
- package/src/schemas/generated/recurring-order.ts +19 -0
- package/src/schemas/generated/review.ts +24 -0
- package/src/schemas/generated/shipping-method.ts +24 -0
- package/src/schemas/generated/shopping-list.ts +28 -0
- package/src/schemas/generated/staged-quote.ts +18 -0
- package/src/schemas/generated/standalone-price.ts +32 -0
- package/src/schemas/generated/state.ts +20 -0
- package/src/schemas/generated/store.ts +23 -0
- package/src/schemas/generated/subscription.ts +20 -0
- package/src/schemas/generated/tax-category.ts +12 -0
- package/src/schemas/generated/type.ts +17 -0
- package/src/schemas/generated/zone.ts +12 -0
- package/src/schemas/update-request.ts +3 -5
- package/src/server.ts +32 -4
- package/src/services/abstract.ts +207 -101
- package/src/services/as-associate-cart.test.ts +28 -36
- package/src/services/as-associate-cart.ts +15 -12
- package/src/services/as-associate-order.test.ts +33 -40
- package/src/services/as-associate-order.ts +15 -12
- package/src/services/as-associate-quote-request.ts +15 -12
- package/src/services/as-associate-shopping-list.test.ts +25 -35
- package/src/services/as-associate-shopping-list.ts +15 -12
- package/src/services/as-associate.test.ts +21 -15
- package/src/services/as-associate.ts +23 -22
- package/src/services/associate-roles.test.ts +16 -22
- package/src/services/associate-roles.ts +2 -2
- package/src/services/attribute-group.test.ts +40 -44
- package/src/services/attribute-group.ts +2 -2
- package/src/services/business-units.test.ts +227 -163
- package/src/services/business-units.ts +2 -2
- package/src/services/cart-discount.test.ts +253 -187
- package/src/services/cart-discount.ts +2 -2
- package/src/services/cart.test.ts +833 -832
- package/src/services/cart.ts +31 -12
- package/src/services/category.test.ts +208 -130
- package/src/services/category.ts +2 -2
- package/src/services/channel.test.ts +39 -44
- package/src/services/channel.ts +2 -2
- package/src/services/custom-object.test.ts +103 -79
- package/src/services/custom-object.ts +106 -38
- package/src/services/customer-group.test.ts +39 -44
- package/src/services/customer-group.ts +2 -2
- package/src/services/customer.test.ts +357 -292
- package/src/services/customer.ts +70 -23
- package/src/services/discount-code.test.ts +57 -68
- package/src/services/discount-code.ts +2 -2
- package/src/services/discount-group.test.ts +111 -134
- package/src/services/discount-group.ts +2 -2
- package/src/services/draft-validation.test.ts +255 -0
- package/src/services/extension.test.ts +39 -44
- package/src/services/extension.ts +2 -2
- package/src/services/inventory-entry.test.ts +106 -87
- package/src/services/inventory-entry.ts +2 -2
- package/src/services/my-business-unit.test.ts +82 -112
- package/src/services/my-business-unit.ts +25 -19
- package/src/services/my-cart.test.ts +46 -41
- package/src/services/my-cart.ts +32 -28
- package/src/services/my-customer.test.ts +153 -88
- package/src/services/my-customer.ts +130 -61
- package/src/services/my-order.ts +15 -12
- package/src/services/my-payment.test.ts +30 -24
- package/src/services/my-payment.ts +2 -2
- package/src/services/my-shopping-list.ts +2 -2
- package/src/services/order.test.ts +332 -276
- package/src/services/order.ts +45 -27
- package/src/services/payment.test.ts +31 -29
- package/src/services/payment.ts +2 -2
- package/src/services/product-discount.test.ts +39 -46
- package/src/services/product-discount.ts +2 -2
- package/src/services/product-projection.test.ts +176 -166
- package/src/services/product-projection.ts +31 -15
- package/src/services/product-selection.test.ts +17 -9
- package/src/services/product-selection.ts +2 -2
- package/src/services/product-type.test.ts +80 -21
- package/src/services/product-type.ts +2 -2
- package/src/services/product.test.ts +569 -534
- package/src/services/product.ts +14 -7
- package/src/services/project.test.ts +22 -12
- package/src/services/project.ts +28 -13
- package/src/services/quote-request.test.ts +36 -39
- package/src/services/quote-request.ts +2 -2
- package/src/services/quote-staged.ts +2 -2
- package/src/services/quote.ts +2 -2
- package/src/services/recurrence-policy.test.ts +114 -139
- package/src/services/recurrence-policy.ts +2 -2
- package/src/services/recurring-order.test.ts +149 -194
- package/src/services/recurring-order.ts +2 -2
- package/src/services/reviews.test.ts +127 -106
- package/src/services/reviews.ts +2 -2
- package/src/services/shipping-method.test.ts +96 -125
- package/src/services/shipping-method.ts +24 -12
- package/src/services/shopping-list.test.ts +183 -141
- package/src/services/shopping-list.ts +2 -2
- package/src/services/standalone-price.test.ts +60 -46
- package/src/services/standalone-price.ts +2 -2
- package/src/services/state.test.ts +20 -25
- package/src/services/state.ts +2 -2
- package/src/services/store.test.ts +26 -45
- package/src/services/store.ts +2 -2
- package/src/services/subscription.test.ts +39 -44
- package/src/services/subscription.ts +2 -2
- package/src/services/tax-category.test.ts +33 -36
- package/src/services/tax-category.ts +2 -2
- package/src/services/type.test.ts +45 -44
- package/src/services/type.ts +2 -2
- package/src/services/zone.test.ts +40 -44
- package/src/services/zone.ts +2 -2
- package/src/shipping.ts +41 -11
- package/src/storage/abstract.ts +248 -17
- package/src/storage/in-memory.ts +147 -290
- package/src/storage/sqlite.ts +429 -0
- package/src/storage/storage-map.ts +75 -0
- package/src/storage/storage.test-helpers.ts +97 -0
- package/src/storage/storage.test.ts +802 -0
- package/src/testing/associate-role.ts +28 -0
- package/src/testing/attribute-group.ts +27 -0
- package/src/testing/business-unit.ts +9 -8
- package/src/testing/cart-discount.ts +34 -0
- package/src/testing/cart.ts +20 -0
- package/src/testing/category.ts +25 -0
- package/src/testing/channel.ts +23 -0
- package/src/testing/custom-object.ts +27 -0
- package/src/testing/customer-group.ts +26 -0
- package/src/testing/customer.ts +36 -33
- package/src/testing/discount-code.ts +29 -0
- package/src/testing/discount-group.ts +27 -0
- package/src/testing/extension.ts +32 -0
- package/src/testing/index.ts +33 -0
- package/src/testing/inventory-entry.ts +26 -0
- package/src/testing/order.ts +27 -0
- package/src/testing/payment.ts +23 -0
- package/src/testing/product-discount.ts +33 -0
- package/src/testing/product-selection.ts +28 -0
- package/src/testing/product-type.ts +27 -0
- package/src/testing/product.ts +38 -0
- package/src/testing/quote-request.ts +29 -0
- package/src/testing/recurrence-policy.ts +33 -0
- package/src/testing/recurring-order.ts +32 -0
- package/src/testing/review.ts +24 -0
- package/src/testing/shipping-method.ts +31 -0
- package/src/testing/shopping-list.ts +25 -0
- package/src/testing/standalone-price.ts +31 -0
- package/src/testing/state.ts +21 -0
- package/src/testing/store.ts +26 -0
- package/src/testing/subscription.ts +38 -0
- package/src/testing/tax-category.ts +27 -0
- package/src/testing/type.ts +9 -6
- package/src/testing/zone.ts +22 -0
- package/src/validate.test.ts +122 -0
- package/src/validate.ts +78 -7
- package/src/.env +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AssociateRole,
|
|
3
|
+
AssociateRoleDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const associateRoleDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<AssociateRoleDraft, AssociateRoleDraft, AssociateRole>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/associate-roles",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
key: `associate-role-${sequence}`,
|
|
23
|
+
name: `Associate Role ${sequence}`,
|
|
24
|
+
buyerAssignable: false,
|
|
25
|
+
permissions: ["ViewMyQuotes", "ViewMyOrders", "ViewMyCarts"],
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AttributeGroup,
|
|
3
|
+
AttributeGroupDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const attributeGroupDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<AttributeGroupDraft, AttributeGroupDraft, AttributeGroup>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/attribute-groups",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
key: `attribute-group-${sequence}`,
|
|
23
|
+
name: { en: `Attribute Group ${sequence}` },
|
|
24
|
+
attributes: [{ key: `attribute-${sequence}` }],
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -3,24 +3,25 @@ import type {
|
|
|
3
3
|
BusinessUnitDraft,
|
|
4
4
|
} from "@commercetools/platform-sdk";
|
|
5
5
|
import { Factory } from "fishery";
|
|
6
|
-
import supertest from "supertest";
|
|
7
6
|
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
8
7
|
|
|
9
8
|
export const businessUnitDraftFactory = (m: CommercetoolsMock) =>
|
|
10
9
|
Factory.define<BusinessUnitDraft, BusinessUnitDraft, BusinessUnit>(
|
|
11
|
-
({ onCreate }) => {
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
12
11
|
onCreate(async (draft) => {
|
|
13
|
-
const response = await
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/business-units",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
16
17
|
|
|
17
|
-
return response.
|
|
18
|
+
return response.json();
|
|
18
19
|
});
|
|
19
20
|
|
|
20
21
|
return {
|
|
21
|
-
key:
|
|
22
|
+
key: `business-unit-${sequence}`,
|
|
22
23
|
unitType: "Company",
|
|
23
|
-
name:
|
|
24
|
+
name: `Test Business Unit ${sequence}`,
|
|
24
25
|
status: "Active",
|
|
25
26
|
contactEmail: "contact@businessunit.com",
|
|
26
27
|
storeMode: "Explicit",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CartDiscount,
|
|
3
|
+
CartDiscountDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const cartDiscountDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<CartDiscountDraft, CartDiscountDraft, CartDiscount>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/cart-discounts",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
key: `cart-discount-${sequence}`,
|
|
23
|
+
name: { en: `Cart Discount ${sequence}` },
|
|
24
|
+
value: {
|
|
25
|
+
type: "relative",
|
|
26
|
+
permyriad: 1000,
|
|
27
|
+
},
|
|
28
|
+
sortOrder: `0.${sequence}`,
|
|
29
|
+
cartPredicate: "1=1",
|
|
30
|
+
isActive: false,
|
|
31
|
+
requiresDiscountCode: false,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Cart, CartDraft } from "@commercetools/platform-sdk";
|
|
2
|
+
import { Factory } from "fishery";
|
|
3
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
4
|
+
|
|
5
|
+
export const cartDraftFactory = (m: CommercetoolsMock) =>
|
|
6
|
+
Factory.define<CartDraft, CartDraft, Cart>(({ onCreate }) => {
|
|
7
|
+
onCreate(async (draft) => {
|
|
8
|
+
const response = await m.app.inject({
|
|
9
|
+
method: "POST",
|
|
10
|
+
url: "/dummy/carts",
|
|
11
|
+
payload: draft,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return response.json();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
currency: "EUR",
|
|
19
|
+
};
|
|
20
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Category, CategoryDraft } from "@commercetools/platform-sdk";
|
|
2
|
+
import { Factory } from "fishery";
|
|
3
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
4
|
+
|
|
5
|
+
export const categoryDraftFactory = (m: CommercetoolsMock) =>
|
|
6
|
+
Factory.define<CategoryDraft, CategoryDraft, Category>(
|
|
7
|
+
({ sequence, onCreate }) => {
|
|
8
|
+
onCreate(async (draft) => {
|
|
9
|
+
const response = await m.app.inject({
|
|
10
|
+
method: "POST",
|
|
11
|
+
url: "/dummy/categories",
|
|
12
|
+
payload: draft,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return response.json();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
key: `category-${sequence}`,
|
|
20
|
+
name: { en: `Category ${sequence}` },
|
|
21
|
+
slug: { en: `category-${sequence}` },
|
|
22
|
+
orderHint: "0.1",
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Channel, ChannelDraft } from "@commercetools/platform-sdk";
|
|
2
|
+
import { Factory } from "fishery";
|
|
3
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
4
|
+
|
|
5
|
+
export const channelDraftFactory = (m: CommercetoolsMock) =>
|
|
6
|
+
Factory.define<ChannelDraft, ChannelDraft, Channel>(
|
|
7
|
+
({ sequence, onCreate }) => {
|
|
8
|
+
onCreate(async (draft) => {
|
|
9
|
+
const response = await m.app.inject({
|
|
10
|
+
method: "POST",
|
|
11
|
+
url: "/dummy/channels",
|
|
12
|
+
payload: draft,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return response.json();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
key: `channel-${sequence}`,
|
|
20
|
+
roles: ["InventorySupply"],
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomObject,
|
|
3
|
+
CustomObjectDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const customObjectDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<CustomObjectDraft, CustomObjectDraft, CustomObject>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/custom-objects",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
container: `container-${sequence}`,
|
|
23
|
+
key: `key-${sequence}`,
|
|
24
|
+
value: `value-${sequence}`,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomerGroup,
|
|
3
|
+
CustomerGroupDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const customerGroupDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<CustomerGroupDraft, CustomerGroupDraft, CustomerGroup>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/customer-groups",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
key: `customer-group-${sequence}`,
|
|
23
|
+
groupName: `Customer Group ${sequence}`,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
);
|
package/src/testing/customer.ts
CHANGED
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
import type { Customer, CustomerDraft } from "@commercetools/platform-sdk";
|
|
2
2
|
import { Factory } from "fishery";
|
|
3
|
-
import supertest from "supertest";
|
|
4
3
|
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
5
4
|
|
|
6
5
|
export const customerDraftFactory = (m: CommercetoolsMock) =>
|
|
7
|
-
Factory.define<CustomerDraft, CustomerDraft, Customer>(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
|
|
6
|
+
Factory.define<CustomerDraft, CustomerDraft, Customer>(
|
|
7
|
+
({ sequence, onCreate }) => {
|
|
8
|
+
onCreate(async (draft) => {
|
|
9
|
+
const response = await m.app.inject({
|
|
10
|
+
method: "POST",
|
|
11
|
+
url: "/dummy/customers",
|
|
12
|
+
payload: draft,
|
|
13
|
+
});
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
return response.json().customer;
|
|
16
|
+
});
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
return {
|
|
19
|
+
email: `customer-${sequence}@example.com`,
|
|
20
|
+
firstName: "John",
|
|
21
|
+
lastName: "Doe",
|
|
22
|
+
locale: "nl-NL",
|
|
23
|
+
password: "my-secret-pw",
|
|
24
|
+
addresses: [
|
|
25
|
+
{
|
|
26
|
+
firstName: "John",
|
|
27
|
+
lastName: "Doe",
|
|
28
|
+
streetName: "Street name",
|
|
29
|
+
streetNumber: "42",
|
|
30
|
+
postalCode: "1234 AB",
|
|
31
|
+
city: "Utrecht",
|
|
32
|
+
country: "NL",
|
|
33
|
+
company: "Lab Digital",
|
|
34
|
+
phone: "+31612345678",
|
|
35
|
+
email: "customer@example.com",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
isEmailVerified: false,
|
|
39
|
+
stores: [],
|
|
40
|
+
authenticationMode: "Password",
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DiscountCode,
|
|
3
|
+
DiscountCodeDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const discountCodeDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<DiscountCodeDraft, DiscountCodeDraft, DiscountCode>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/discount-codes",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
key: `discount-code-${sequence}`,
|
|
23
|
+
code: `SAVE${sequence}`,
|
|
24
|
+
name: { en: `Discount Code ${sequence}` },
|
|
25
|
+
cartDiscounts: [],
|
|
26
|
+
isActive: true,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DiscountGroup,
|
|
3
|
+
DiscountGroupDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const discountGroupDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<DiscountGroupDraft, DiscountGroupDraft, DiscountGroup>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/discount-groups",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
key: `discount-group-${sequence}`,
|
|
23
|
+
name: { en: `Discount Group ${sequence}` },
|
|
24
|
+
sortOrder: `0.${sequence}`,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Extension, ExtensionDraft } from "@commercetools/platform-sdk";
|
|
2
|
+
import { Factory } from "fishery";
|
|
3
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
4
|
+
|
|
5
|
+
export const extensionDraftFactory = (m: CommercetoolsMock) =>
|
|
6
|
+
Factory.define<ExtensionDraft, ExtensionDraft, Extension>(
|
|
7
|
+
({ sequence, onCreate }) => {
|
|
8
|
+
onCreate(async (draft) => {
|
|
9
|
+
const response = await m.app.inject({
|
|
10
|
+
method: "POST",
|
|
11
|
+
url: "/dummy/extensions",
|
|
12
|
+
payload: draft,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return response.json();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
key: `extension-${sequence}`,
|
|
20
|
+
destination: {
|
|
21
|
+
type: "HTTP",
|
|
22
|
+
url: `https://example.com/webhook-${sequence}`,
|
|
23
|
+
},
|
|
24
|
+
triggers: [
|
|
25
|
+
{
|
|
26
|
+
resourceTypeId: "order",
|
|
27
|
+
actions: ["Create"],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { associateRoleDraftFactory } from "./associate-role.ts";
|
|
2
|
+
export { attributeGroupDraftFactory } from "./attribute-group.ts";
|
|
3
|
+
export { businessUnitDraftFactory } from "./business-unit.ts";
|
|
4
|
+
export { cartDraftFactory } from "./cart.ts";
|
|
5
|
+
export { cartDiscountDraftFactory } from "./cart-discount.ts";
|
|
6
|
+
export { categoryDraftFactory } from "./category.ts";
|
|
7
|
+
export { channelDraftFactory } from "./channel.ts";
|
|
8
|
+
export { customObjectDraftFactory } from "./custom-object.ts";
|
|
9
|
+
export { customerDraftFactory } from "./customer.ts";
|
|
10
|
+
export { customerGroupDraftFactory } from "./customer-group.ts";
|
|
11
|
+
export { discountCodeDraftFactory } from "./discount-code.ts";
|
|
12
|
+
export { discountGroupDraftFactory } from "./discount-group.ts";
|
|
13
|
+
export { extensionDraftFactory } from "./extension.ts";
|
|
14
|
+
export { inventoryEntryDraftFactory } from "./inventory-entry.ts";
|
|
15
|
+
export { orderDraftFactory } from "./order.ts";
|
|
16
|
+
export { paymentDraftFactory } from "./payment.ts";
|
|
17
|
+
export { productDraftFactory } from "./product.ts";
|
|
18
|
+
export { productDiscountDraftFactory } from "./product-discount.ts";
|
|
19
|
+
export { productSelectionDraftFactory } from "./product-selection.ts";
|
|
20
|
+
export { productTypeDraftFactory } from "./product-type.ts";
|
|
21
|
+
export { quoteRequestDraftFactory } from "./quote-request.ts";
|
|
22
|
+
export { recurrencePolicyDraftFactory } from "./recurrence-policy.ts";
|
|
23
|
+
export { recurringOrderDraftFactory } from "./recurring-order.ts";
|
|
24
|
+
export { reviewDraftFactory } from "./review.ts";
|
|
25
|
+
export { shippingMethodDraftFactory } from "./shipping-method.ts";
|
|
26
|
+
export { shoppingListDraftFactory } from "./shopping-list.ts";
|
|
27
|
+
export { standalonePriceDraftFactory } from "./standalone-price.ts";
|
|
28
|
+
export { stateDraftFactory } from "./state.ts";
|
|
29
|
+
export { storeDraftFactory } from "./store.ts";
|
|
30
|
+
export { subscriptionDraftFactory } from "./subscription.ts";
|
|
31
|
+
export { taxCategoryDraftFactory } from "./tax-category.ts";
|
|
32
|
+
export { typeDraftFactory } from "./type.ts";
|
|
33
|
+
export { zoneDraftFactory } from "./zone.ts";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InventoryEntry,
|
|
3
|
+
InventoryEntryDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const inventoryEntryDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<InventoryEntryDraft, InventoryEntryDraft, InventoryEntry>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/inventory",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
sku: `sku-${sequence}`,
|
|
23
|
+
quantityOnStock: 100,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Order, OrderFromCartDraft } from "@commercetools/platform-sdk";
|
|
2
|
+
import { Factory } from "fishery";
|
|
3
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
4
|
+
|
|
5
|
+
export const orderDraftFactory = (m: CommercetoolsMock) =>
|
|
6
|
+
Factory.define<OrderFromCartDraft, OrderFromCartDraft, Order>(
|
|
7
|
+
({ sequence, onCreate }) => {
|
|
8
|
+
onCreate(async (draft) => {
|
|
9
|
+
const response = await m.app.inject({
|
|
10
|
+
method: "POST",
|
|
11
|
+
url: "/dummy/orders",
|
|
12
|
+
payload: draft,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return response.json();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
cart: {
|
|
20
|
+
typeId: "cart" as const,
|
|
21
|
+
id: "cart-id-placeholder",
|
|
22
|
+
},
|
|
23
|
+
version: 1,
|
|
24
|
+
orderNumber: `order-${sequence}`,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Payment, PaymentDraft } from "@commercetools/platform-sdk";
|
|
2
|
+
import { Factory } from "fishery";
|
|
3
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
4
|
+
|
|
5
|
+
export const paymentDraftFactory = (m: CommercetoolsMock) =>
|
|
6
|
+
Factory.define<PaymentDraft, PaymentDraft, Payment>(({ onCreate }) => {
|
|
7
|
+
onCreate(async (draft) => {
|
|
8
|
+
const response = await m.app.inject({
|
|
9
|
+
method: "POST",
|
|
10
|
+
url: "/dummy/payments",
|
|
11
|
+
payload: draft,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return response.json();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
amountPlanned: {
|
|
19
|
+
currencyCode: "EUR",
|
|
20
|
+
centAmount: 1000,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProductDiscount,
|
|
3
|
+
ProductDiscountDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const productDiscountDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<ProductDiscountDraft, ProductDiscountDraft, ProductDiscount>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/product-discounts",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
key: `product-discount-${sequence}`,
|
|
23
|
+
name: { en: `Product Discount ${sequence}` },
|
|
24
|
+
value: {
|
|
25
|
+
type: "relative",
|
|
26
|
+
permyriad: 2000,
|
|
27
|
+
},
|
|
28
|
+
predicate: "1=1",
|
|
29
|
+
sortOrder: `0.${sequence}`,
|
|
30
|
+
isActive: true,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProductSelection,
|
|
3
|
+
ProductSelectionDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const productSelectionDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<
|
|
10
|
+
ProductSelectionDraft,
|
|
11
|
+
ProductSelectionDraft,
|
|
12
|
+
ProductSelection
|
|
13
|
+
>(({ sequence, onCreate }) => {
|
|
14
|
+
onCreate(async (draft) => {
|
|
15
|
+
const response = await m.app.inject({
|
|
16
|
+
method: "POST",
|
|
17
|
+
url: "/dummy/product-selections",
|
|
18
|
+
payload: draft,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return response.json();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
key: `product-selection-${sequence}`,
|
|
26
|
+
name: { en: `Product Selection ${sequence}` },
|
|
27
|
+
};
|
|
28
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ProductType,
|
|
3
|
+
ProductTypeDraft,
|
|
4
|
+
} from "@commercetools/platform-sdk";
|
|
5
|
+
import { Factory } from "fishery";
|
|
6
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
7
|
+
|
|
8
|
+
export const productTypeDraftFactory = (m: CommercetoolsMock) =>
|
|
9
|
+
Factory.define<ProductTypeDraft, ProductTypeDraft, ProductType>(
|
|
10
|
+
({ sequence, onCreate }) => {
|
|
11
|
+
onCreate(async (draft) => {
|
|
12
|
+
const response = await m.app.inject({
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/dummy/product-types",
|
|
15
|
+
payload: draft,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.json();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
key: `product-type-${sequence}`,
|
|
23
|
+
name: `Product Type ${sequence}`,
|
|
24
|
+
description: `Product Type ${sequence} description`,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Product, ProductDraft } from "@commercetools/platform-sdk";
|
|
2
|
+
import { Factory } from "fishery";
|
|
3
|
+
import type { CommercetoolsMock } from "#src/ctMock.ts";
|
|
4
|
+
|
|
5
|
+
export const productDraftFactory = (m: CommercetoolsMock) =>
|
|
6
|
+
Factory.define<ProductDraft, ProductDraft, Product>(
|
|
7
|
+
({ sequence, onCreate }) => {
|
|
8
|
+
onCreate(async (draft) => {
|
|
9
|
+
const response = await m.app.inject({
|
|
10
|
+
method: "POST",
|
|
11
|
+
url: "/dummy/products",
|
|
12
|
+
payload: draft,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return response.json();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
productType: {
|
|
20
|
+
typeId: "product-type",
|
|
21
|
+
key: `product-type-${sequence}`,
|
|
22
|
+
},
|
|
23
|
+
name: { en: `Product ${sequence}` },
|
|
24
|
+
slug: { en: `product-${sequence}` },
|
|
25
|
+
masterVariant: {
|
|
26
|
+
sku: `sku-${sequence}`,
|
|
27
|
+
prices: [
|
|
28
|
+
{
|
|
29
|
+
value: {
|
|
30
|
+
currencyCode: "EUR",
|
|
31
|
+
centAmount: 1000,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
);
|