From f4553a48d9c5993b8cdddf67acfebe8ab84d1792 Mon Sep 17 00:00:00 2001 From: Thomas De Meyer Date: Fri, 16 Aug 2024 13:29:16 +0200 Subject: [PATCH 1/4] feat(business-unit): updated sdk, added better business-unit handling, added approval rule mode updating --- package.json | 2 +- pnpm-lock.yaml | 60 ++++++++++++++++++++++++++----- src/repositories/business-unit.ts | 48 ++++++++++++++++++++----- 3 files changed, 92 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index ef5d168..2405e13 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.1", - "@commercetools/platform-sdk": "7.3.0", + "@commercetools/platform-sdk": "7.11.0", "@stylistic/eslint-plugin": "^1.6.2", "@types/basic-auth": "^1.1.8", "@types/body-parser": "^1.19.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e9560ad..8b6bc02 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,8 +49,8 @@ importers: specifier: ^2.27.1 version: 2.27.1 '@commercetools/platform-sdk': - specifier: 7.3.0 - version: 7.3.0 + specifier: 7.11.0 + version: 7.11.0 '@stylistic/eslint-plugin': specifier: ^1.6.2 version: 1.6.2(eslint@8.57.0)(typescript@5.3.3) @@ -251,12 +251,12 @@ packages: '@changesets/write@0.3.0': resolution: {integrity: sha512-slGLb21fxZVUYbyea+94uFiD6ntQW0M2hIKNznFizDhZPDgn2c/fv1UzzlW43RVzh1BEDuIqW6hzlJ1OflNmcw==} - '@commercetools/platform-sdk@7.3.0': - resolution: {integrity: sha512-MovSWsEk8f/ZwtxHPuYf8dMIf3R3bOU44UdKtha4JXWw/xrP03B0/MlEPnmHskGHedb2QMt2asvEfw2yLF34oA==} + '@commercetools/platform-sdk@7.11.0': + resolution: {integrity: sha512-8vlgiK6w8NewUZ60HUDJzdNUzDp2ByO+8fAH7aUTkt+suXYbG3Jl/k8brgX8JOn2AR4k7kC8g7sEHV6JUN8KzA==} engines: {node: '>=14'} - '@commercetools/sdk-client-v2@2.3.0': - resolution: {integrity: sha512-+vS6qRoKBbkunZCpdozung+7te97nFxaidLPqOTlz/9TmJaRfMMcYC/KUZCTS8S5a/4BFfY6DYujddolaU7e6Q==} + '@commercetools/sdk-client-v2@2.5.0': + resolution: {integrity: sha512-v1y++O6yllG+IRTYm9jPE8s667+GapnysyGIf8NJDZbVwhvcanixZL4d20imXjCpOr4u1iZrgRftc90mgYqblw==} engines: {node: '>=14'} '@commercetools/sdk-middleware-auth@7.0.1': @@ -271,6 +271,10 @@ packages: resolution: {integrity: sha512-DhMXAA2yIch/AaGxy7st85Z1HFmeLtHWGkr9z5rX4xKjan4PHGB/IE5saAR+SNGHhs6+1Lp8vZEHDo3tFqVLmg==} engines: {node: '>=14'} + '@commercetools/ts-client@2.0.2': + resolution: {integrity: sha512-4R+tOcshiDd3ikhwART2P58VFoZkMNIBCZYTidXIzpPrDvZta32B71xbp9mHVMROLBmEcCBU2jhzbKMOlMr/uw==} + engines: {node: '>=14'} + '@cspotcode/source-map-support@0.8.1': resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} engines: {node: '>=12'} @@ -995,6 +999,10 @@ packages: '@vitest/utils@1.5.0': resolution: {integrity: sha512-BDU0GNL8MWkRkSRdNFvCUCAVOeHaUlVJ9Tx0TYBZyXaaOTmGtUFObzchCivIBrIwKzvZA7A9sCejVhXM2aY98A==} + abort-controller@3.0.0: + resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} + engines: {node: '>=6.5'} + accepts@1.3.8: resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} engines: {node: '>= 0.6'} @@ -1093,6 +1101,9 @@ packages: assertion-error@1.1.0: resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + async-mutex@0.5.0: + resolution: {integrity: sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==} + asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} @@ -1537,6 +1548,10 @@ packages: resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} engines: {node: '>= 0.6'} + event-target-shim@5.0.1: + resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} + engines: {node: '>=6'} + execa@5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -3059,6 +3074,10 @@ packages: resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} engines: {node: '>= 0.4.0'} + uuid@10.0.0: + resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==} + hasBin: true + uuid@9.0.1: resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} hasBin: true @@ -3457,16 +3476,17 @@ snapshots: human-id: 1.0.2 prettier: 2.8.8 - '@commercetools/platform-sdk@7.3.0': + '@commercetools/platform-sdk@7.11.0': dependencies: - '@commercetools/sdk-client-v2': 2.3.0 + '@commercetools/sdk-client-v2': 2.5.0 '@commercetools/sdk-middleware-auth': 7.0.1 '@commercetools/sdk-middleware-http': 7.0.4 '@commercetools/sdk-middleware-logger': 3.0.0 + '@commercetools/ts-client': 2.0.2 transitivePeerDependencies: - encoding - '@commercetools/sdk-client-v2@2.3.0': + '@commercetools/sdk-client-v2@2.5.0': dependencies: buffer: 6.0.3 node-fetch: 2.7.0 @@ -3483,6 +3503,16 @@ snapshots: '@commercetools/sdk-middleware-logger@3.0.0': {} + '@commercetools/ts-client@2.0.2': + dependencies: + abort-controller: 3.0.0 + async-mutex: 0.5.0 + buffer: 6.0.3 + node-fetch: 2.7.0 + uuid: 10.0.0 + transitivePeerDependencies: + - encoding + '@cspotcode/source-map-support@0.8.1': dependencies: '@jridgewell/trace-mapping': 0.3.9 @@ -4164,6 +4194,10 @@ snapshots: loupe: 2.3.7 pretty-format: 29.7.0 + abort-controller@3.0.0: + dependencies: + event-target-shim: 5.0.1 + accepts@1.3.8: dependencies: mime-types: 2.1.35 @@ -4254,6 +4288,10 @@ snapshots: assertion-error@1.1.0: {} + async-mutex@0.5.0: + dependencies: + tslib: 2.6.2 + asynckit@0.4.0: {} available-typed-arrays@1.0.7: @@ -4817,6 +4855,8 @@ snapshots: etag@1.8.1: {} + event-target-shim@5.0.1: {} + execa@5.1.1: dependencies: cross-spawn: 7.0.3 @@ -6369,6 +6409,8 @@ snapshots: utils-merge@1.0.1: {} + uuid@10.0.0: {} + uuid@9.0.1: {} v8-compile-cache-lib@3.0.1: {} diff --git a/src/repositories/business-unit.ts b/src/repositories/business-unit.ts index 0f69463..f188268 100644 --- a/src/repositories/business-unit.ts +++ b/src/repositories/business-unit.ts @@ -1,4 +1,5 @@ import { + BusinessUnitChangeApprovalRuleModeAction, BusinessUnitChangeAssociateModeAction, BusinessUnitChangeStatusAction, BusinessUnitUpdateAction, @@ -19,8 +20,8 @@ import { type Company, type Division, } from "@commercetools/platform-sdk"; -import { getBaseResourceProperties } from "../helpers"; -import { AbstractStorage } from "../storage/abstract"; +import { generateRandomString, getBaseResourceProperties } from "../helpers"; +import { AbstractStorage } from "~src/storage"; import { Writable } from "../types"; import { AbstractResourceRepository, @@ -43,6 +44,28 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business } create(context: RepositoryContext, draft: BusinessUnitDraft): BusinessUnit { + const addresses = + draft.addresses?.map((address) => ({ + ...address, + id: generateRandomString(5), + })) ?? []; + + const defaultBillingAddressId = + addresses.length > 0 && draft.defaultBillingAddress !== undefined + ? addresses[draft.defaultBillingAddress].id + : undefined; + const defaultShippingAddressId = + addresses.length > 0 && draft.defaultShippingAddress !== undefined + ? addresses[draft.defaultShippingAddress].id + : undefined; + + const shippingAddressIds = draft.shippingAddresses?.map( + (i) => addresses[i].id, + ); + const billingAddressIds = draft.billingAddresses?.map( + (i) => addresses[i].id, + ); + const resource = { ...getBaseResourceProperties(), key: draft.key, @@ -53,18 +76,19 @@ export class BusinessUnitRepository extends AbstractResourceRepository<"business storeMode: draft.storeMode, name: draft.name, contactEmail: draft.contactEmail, - addresses: draft.addresses?.map((a) => - createAddress(a, context.projectKey, this._storage), - ), + addresses: addresses, custom: createCustomFields( draft.custom, context.projectKey, this._storage, ), - shippingAddressIds: draft.shippingAddresses, - defaultShippingAddressId: draft.defaultShippingAddress, - billingAddressIds: draft.billingAddresses, + shippingAddressIds: shippingAddressIds, + billingAddressIds: billingAddressIds, + defaultShippingAddressId: defaultShippingAddressId, + defaultBillingAddressId: defaultBillingAddressId, associateMode: draft.associateMode, + approvalRuleMode: draft.approvalRuleMode, + associates: draft.associates?.map((a) => createAssociate(a, context.projectKey, this._storage), ), @@ -170,6 +194,14 @@ class BusinessUnitUpdateHandler } } + changeApprovalRuleMode( + context: RepositoryContext, + resource: Writable, + { approvalRuleMode }: BusinessUnitChangeApprovalRuleModeAction, + ) { + resource.approvalRuleMode = approvalRuleMode; + } + changeAssociateMode( context: RepositoryContext, resource: Writable, From 97cce0e504bf1d9404d05f0f3a980f203281fd11 Mon Sep 17 00:00:00 2001 From: Thomas De Meyer Date: Fri, 16 Aug 2024 13:32:23 +0200 Subject: [PATCH 2/4] feat(business-unit): fixed linting --- src/repositories/business-unit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/repositories/business-unit.ts b/src/repositories/business-unit.ts index f188268..c608a3b 100644 --- a/src/repositories/business-unit.ts +++ b/src/repositories/business-unit.ts @@ -20,8 +20,8 @@ import { type Company, type Division, } from "@commercetools/platform-sdk"; -import { generateRandomString, getBaseResourceProperties } from "../helpers"; import { AbstractStorage } from "~src/storage"; +import { generateRandomString, getBaseResourceProperties } from "../helpers"; import { Writable } from "../types"; import { AbstractResourceRepository, From e50af4fbc1175c750bfa26048d280a81636467a9 Mon Sep 17 00:00:00 2001 From: Thomas De Meyer Date: Fri, 16 Aug 2024 14:37:57 +0200 Subject: [PATCH 3/4] feat(business-unit): fixed issues with new sdk --- src/oauth/server.test.ts | 1 + src/repositories/cart/actions.ts | 12 +++++--- src/repositories/customer/index.ts | 1 + src/repositories/helpers.ts | 3 +- src/repositories/index.ts | 2 ++ src/repositories/product-tailoring.ts | 34 +++++++++++++++++++++ src/repositories/shipping-method/actions.ts | 11 ++++++- src/repositories/shipping-method/index.ts | 1 + src/services/customer.test.ts | 2 ++ src/services/my-customer.test.ts | 11 +++++-- src/storage/in-memory.ts | 2 ++ src/types.ts | 2 ++ 12 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 src/repositories/product-tailoring.ts diff --git a/src/oauth/server.test.ts b/src/oauth/server.test.ts index 86fe981..65810fd 100644 --- a/src/oauth/server.test.ts +++ b/src/oauth/server.test.ts @@ -106,6 +106,7 @@ describe("OAuth2Server", () => { addresses: [], authenticationMode: "password", isEmailVerified: true, + stores: [], }); const response = await supertest(app) diff --git a/src/repositories/cart/actions.ts b/src/repositories/cart/actions.ts index dd6a4c1..cd33896 100644 --- a/src/repositories/cart/actions.ts +++ b/src/repositories/cart/actions.ts @@ -30,6 +30,7 @@ import { type ProductPagedQueryResponse, type ProductVariant, } from "@commercetools/platform-sdk"; +import { DirectDiscount } from "@commercetools/platform-sdk/dist/declarations/src/generated/models/cart"; import { v4 as uuidv4 } from "uuid"; import { CommercetoolsError } from "~src/exceptions"; import type { Writable } from "~src/types"; @@ -419,10 +420,13 @@ export class CartUpdateHandler { discounts }: CartSetDirectDiscountsAction, ) { // Doesn't apply any discounts logic, just sets the directDiscounts field - resource.directDiscounts = discounts.map((discount) => ({ - ...discount, - id: uuidv4(), - })); + resource.directDiscounts = discounts.map( + (discount) => + ({ + ...discount, + id: uuidv4(), + }) as DirectDiscount, + ); } setLineItemShippingDetails( diff --git a/src/repositories/customer/index.ts b/src/repositories/customer/index.ts index 2fded0c..3203b37 100644 --- a/src/repositories/customer/index.ts +++ b/src/repositories/customer/index.ts @@ -91,6 +91,7 @@ export class CustomerRepository extends AbstractResourceRepository<"customer"> { context.projectKey, this._storage, ), + stores: [], }; return this.saveNew(context, resource); } diff --git a/src/repositories/helpers.ts b/src/repositories/helpers.ts index ee184c2..5c4fb1b 100644 --- a/src/repositories/helpers.ts +++ b/src/repositories/helpers.ts @@ -27,7 +27,6 @@ import { type StoreReference, type StoreResourceIdentifier, type Type, - type TypedMoney, type _Money, } from "@commercetools/platform-sdk"; import type { Request } from "express"; @@ -133,7 +132,7 @@ export const createCentPrecisionMoney = (value: _Money): CentPrecisionMoney => { }; }; -export const createTypedMoney = (value: _Money): TypedMoney => { +export const createTypedMoney = (value: _Money): CentPrecisionMoney => { const result = createCentPrecisionMoney(value); return result; }; diff --git a/src/repositories/index.ts b/src/repositories/index.ts index 2ae4b0e..a4fe674 100644 --- a/src/repositories/index.ts +++ b/src/repositories/index.ts @@ -1,3 +1,4 @@ +import { ProductTailoringRepository } from "~src/repositories/product-tailoring"; import { AbstractStorage } from "../storage"; import { AssociateRoleRepository } from "./associate-role"; import { AttributeGroupRepository } from "./attribute-group"; @@ -66,6 +67,7 @@ export const createRepositories = (storage: AbstractStorage) => ({ "product-discount": new ProductDiscountRepository(storage), "product-projection": new ProductProjectionRepository(storage), "product-selection": new ProductSelectionRepository(storage), + "product-tailoring": new ProductTailoringRepository(storage), "project": new ProjectRepository(storage), "review": new ReviewRepository(storage), "quote": new QuoteRepository(storage), diff --git a/src/repositories/product-tailoring.ts b/src/repositories/product-tailoring.ts new file mode 100644 index 0000000..ec29b2c --- /dev/null +++ b/src/repositories/product-tailoring.ts @@ -0,0 +1,34 @@ +import type { + ProductTailoring, + ProductTailoringUpdateAction, +} from "@commercetools/platform-sdk"; +import { AbstractStorage } from "~src/storage"; +import { + AbstractResourceRepository, + AbstractUpdateHandler, + RepositoryContext, + UpdateHandlerInterface, +} from "./abstract"; + +export class ProductTailoringRepository extends AbstractResourceRepository<"product-tailoring"> { + constructor(storage: AbstractStorage) { + super("product-tailoring", storage); + this.actions = new ProductTailoringUpdateHandler(this._storage); + } + + create(context: RepositoryContext, draft: any): ProductTailoring { + throw new Error("Create method for product-tailoring not implemented."); + } +} + +class ProductTailoringUpdateHandler + extends AbstractUpdateHandler + implements + Partial< + UpdateHandlerInterface + > +{ + setSlug() { + throw new Error("SetSlug method for product-tailoring not implemented."); + } +} diff --git a/src/repositories/shipping-method/actions.ts b/src/repositories/shipping-method/actions.ts index 2d84461..0fd3393 100644 --- a/src/repositories/shipping-method/actions.ts +++ b/src/repositories/shipping-method/actions.ts @@ -4,6 +4,7 @@ import { type ShippingMethod, type ShippingMethodAddShippingRateAction, type ShippingMethodAddZoneAction, + type ShippingMethodChangeActiveAction, type ShippingMethodChangeIsDefaultAction, type ShippingMethodChangeNameAction, type ShippingMethodRemoveZoneAction, @@ -18,7 +19,7 @@ import { type ZoneReference, } from "@commercetools/platform-sdk"; import deepEqual from "deep-equal"; -import type { Writable } from "../../types"; +import type { Writable } from "~src/types"; import { AbstractUpdateHandler, RepositoryContext, @@ -83,6 +84,14 @@ export class ShippingMethodUpdateHandler }); } + changeActive( + _context: RepositoryContext, + resource: Writable, + { active }: ShippingMethodChangeActiveAction, + ) { + resource.active = active; + } + changeIsDefault( _context: RepositoryContext, resource: Writable, diff --git a/src/repositories/shipping-method/index.ts b/src/repositories/shipping-method/index.ts index a17e7cb..28fcab6 100644 --- a/src/repositories/shipping-method/index.ts +++ b/src/repositories/shipping-method/index.ts @@ -35,6 +35,7 @@ export class ShippingMethodRepository extends AbstractResourceRepository<"shippi const resource: ShippingMethod = { ...getBaseResourceProperties(), ...draft, + active: draft.active ?? true, taxCategory: getReferenceFromResourceIdentifier( draft.taxCategory, context.projectKey, diff --git a/src/services/customer.test.ts b/src/services/customer.test.ts index 0c63817..f15b4e5 100644 --- a/src/services/customer.test.ts +++ b/src/services/customer.test.ts @@ -20,6 +20,7 @@ describe("Customer Update Actions", () => { isEmailVerified: true, authenticationMode: "Password", //default in Commercetools version: 1, + stores: [], }; ctMock.project("dummy").add("customer", customer); }); @@ -467,6 +468,7 @@ describe("Customer Password Reset", () => { isEmailVerified: true, authenticationMode: "password", custom: { type: { typeId: "type", id: "" }, fields: {} }, + stores: [], }); }); diff --git a/src/services/my-customer.test.ts b/src/services/my-customer.test.ts index 8d1bc28..25c8b15 100644 --- a/src/services/my-customer.test.ts +++ b/src/services/my-customer.test.ts @@ -1,4 +1,5 @@ import type { + Customer, CustomerChangePassword, CustomerToken, MyCustomerDraft, @@ -73,6 +74,7 @@ describe("/me", () => { isEmailVerified: true, authenticationMode: "password", custom: { type: { typeId: "type", id: "" }, fields: {} }, + stores: [], }); }); @@ -126,7 +128,7 @@ describe("/me", () => { }); test("Change my password", async () => { - const customer = { + const customer: Customer = { ...getBaseResourceProperties(), id: "customer-uuid", email: "user@example.com", @@ -135,6 +137,7 @@ describe("/me", () => { isEmailVerified: true, authenticationMode: "Password", //default in Commercetools version: 1, + stores: [], }; ctMock.project("dummy").add("customer", customer); @@ -176,7 +179,7 @@ describe("/me", () => { }); test("reset password flow", async () => { - const customer = { + const customer: Customer = { ...getBaseResourceProperties(), id: "customer-uuid", email: "user@example.com", @@ -185,6 +188,7 @@ describe("/me", () => { isEmailVerified: true, authenticationMode: "Password", //default in Commercetools version: 1, + stores: [], }; ctMock.project("dummy").add("customer", customer); @@ -225,7 +229,7 @@ describe("/me", () => { }); test("verify email flow", async () => { - const customer = { + const customer: Customer = { ...getBaseResourceProperties(), id: "customer-uuid", email: "user@example.com", @@ -234,6 +238,7 @@ describe("/me", () => { isEmailVerified: false, authenticationMode: "Password", //default in Commercetools version: 1, + stores: [], }; ctMock.project("dummy").add("customer", customer); diff --git a/src/storage/in-memory.ts b/src/storage/in-memory.ts index 46618c3..944fb78 100644 --- a/src/storage/in-memory.ts +++ b/src/storage/in-memory.ts @@ -22,6 +22,7 @@ import { type Product, type ProductDiscount, type ProductProjection, + type ProductTailoring, type ProductType, type Project, type Quote, @@ -189,6 +190,7 @@ export class InMemoryStorage extends AbstractStorage { "product-selection": new Map(), "product-type": new Map(), "product-projection": new Map(), + "product-tailoring": new Map(), "review": new Map(), "shipping-method": new Map(), "staged-quote": new Map(), diff --git a/src/types.ts b/src/types.ts index 86541c2..de31c05 100644 --- a/src/types.ts +++ b/src/types.ts @@ -45,6 +45,7 @@ export type ResourceMap = { "product-price": ctp.StandalonePrice; "product-projection": ctp.ProductProjection; "product-selection": ctp.ProductSelection; + "product-tailoring": ctp.ProductTailoring; "product-type": ctp.ProductType; "product": ctp.Product; "quote-request": ctp.QuoteRequest; @@ -85,6 +86,7 @@ export type PagedQueryResponseMap = { "product-price": ctp.StandalonePricePagedQueryResponse; "product-projection": ctp.ProductProjectionPagedQueryResponse; "product-selection": ctp.ProductSelectionPagedQueryResponse; + "product-tailoring": ctp.ProductTailoringPagedQueryResponse; "product-type": ctp.ProductTypePagedQueryResponse; "product": ctp.ProductPagedQueryResponse; "quote-request": ctp.QuoteRequestPagedQueryResponse; From 8bb5cb3d2b5839501f9c393e1aff90ed9b4e113b Mon Sep 17 00:00:00 2001 From: Thomas De Meyer Date: Fri, 16 Aug 2024 14:42:41 +0200 Subject: [PATCH 4/4] feat(business-unit): fixed tests --- .changeset/dry-walls-dance.md | 5 +++++ src/services/my-customer.test.ts | 3 +++ src/services/shipping-method.test.ts | 1 + 3 files changed, 9 insertions(+) create mode 100644 .changeset/dry-walls-dance.md diff --git a/.changeset/dry-walls-dance.md b/.changeset/dry-walls-dance.md new file mode 100644 index 0000000..afe01c5 --- /dev/null +++ b/.changeset/dry-walls-dance.md @@ -0,0 +1,5 @@ +--- +"@labdigital/commercetools-mock": minor +--- + +Fixed issues with business units, updated sdk to latest diff --git a/src/services/my-customer.test.ts b/src/services/my-customer.test.ts index 25c8b15..08f1883 100644 --- a/src/services/my-customer.test.ts +++ b/src/services/my-customer.test.ts @@ -38,6 +38,7 @@ describe("Me", () => { id: expect.anything(), createdAt: expect.anything(), lastModifiedAt: expect.anything(), + stores: [], }, }); }); @@ -98,6 +99,7 @@ describe("/me", () => { typeId: "type", }, }, + stores: [], }); }); @@ -121,6 +123,7 @@ describe("/me", () => { typeId: "type", }, }, + stores: [], }); const newResponse = await supertest(ctMock.app).get("/dummy/me"); diff --git a/src/services/shipping-method.test.ts b/src/services/shipping-method.test.ts index c477b7c..70617ef 100644 --- a/src/services/shipping-method.test.ts +++ b/src/services/shipping-method.test.ts @@ -74,6 +74,7 @@ describe("Shipping method", () => { }, version: 1, zoneRates: [], + active: true, }); });