@labdigital/commercetools-mock 2.26.1 → 2.28.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labdigital/commercetools-mock",
3
- "version": "2.26.1",
3
+ "version": "2.28.0",
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.3.0",
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",
@@ -12,10 +12,10 @@ export const validatePassword = (
12
12
  export const hashPassword = (clearPassword: string) =>
13
13
  Buffer.from(clearPassword).toString("base64");
14
14
 
15
- export const createPasswordResetToken = (customer: Customer) =>
16
- Buffer.from(`${customer.id}:${PWRESET_SECRET}:${uuidv4()}`).toString(
17
- "base64",
18
- );
15
+ export const createPasswordResetToken = (customer: Customer, expiresAt: Date) =>
16
+ Buffer.from(
17
+ `${customer.id}:${PWRESET_SECRET}:${expiresAt.getTime()}`,
18
+ ).toString("base64");
19
19
 
20
20
  export const createEmailVerifyToken = (customer: Customer) =>
21
21
  Buffer.from(`${customer.id}:${EMAIL_VERIFY_SECRET}:${uuidv4()}`).toString(
@@ -24,13 +24,20 @@ export const createEmailVerifyToken = (customer: Customer) =>
24
24
 
25
25
  export const validatePasswordResetToken = (token: string) => {
26
26
  const items = Buffer.from(token, "base64").toString("utf-8").split(":");
27
- const [customerId, secret] = items;
27
+ const [customerId, secret, time] = items;
28
+
28
29
  if (secret !== PWRESET_SECRET) {
29
30
  return undefined;
30
31
  }
31
32
 
33
+ // Check if the token is expired
34
+ if (parseInt(time) < new Date().getTime()) {
35
+ return undefined;
36
+ }
37
+
32
38
  return customerId;
33
39
  };
40
+
34
41
  export const validateEmailVerifyToken = (token: string) => {
35
42
  const items = Buffer.from(token, "base64").toString("utf-8").split(":");
36
43
  const [customerId, secret] = items;
@@ -106,6 +106,7 @@ describe("OAuth2Server", () => {
106
106
  addresses: [],
107
107
  authenticationMode: "password",
108
108
  isEmailVerified: true,
109
+ stores: [],
109
110
  });
110
111
 
111
112
  const response = await supertest(app)
@@ -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 { getBaseResourceProperties } from "../helpers";
23
- import { AbstractStorage } from "../storage/abstract";
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: draft.addresses?.map((a) =>
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: draft.shippingAddresses,
65
- defaultShippingAddressId: draft.defaultShippingAddress,
66
- billingAddressIds: draft.billingAddresses,
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((discount) => ({
423
- ...discount,
424
- id: uuidv4(),
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(
@@ -1,8 +1,11 @@
1
1
  import type {
2
2
  Customer,
3
+ CustomerCreatePasswordResetToken,
3
4
  CustomerDraft,
5
+ CustomerResetPassword,
4
6
  CustomerToken,
5
7
  DuplicateFieldError,
8
+ MyCustomerResetPassword,
6
9
  ResourceNotFoundError,
7
10
  } from "@commercetools/platform-sdk";
8
11
  import { CommercetoolsError } from "~src/exceptions";
@@ -11,8 +14,10 @@ import {
11
14
  createEmailVerifyToken,
12
15
  createPasswordResetToken,
13
16
  hashPassword,
17
+ validatePasswordResetToken,
14
18
  } from "~src/lib/password";
15
19
  import { AbstractStorage } from "~src/storage/abstract";
20
+ import { Writable } from "~src/types";
16
21
  import {
17
22
  AbstractResourceRepository,
18
23
  type RepositoryContext,
@@ -86,25 +91,33 @@ export class CustomerRepository extends AbstractResourceRepository<"customer"> {
86
91
  context.projectKey,
87
92
  this._storage,
88
93
  ),
94
+ stores: [],
89
95
  };
90
96
  return this.saveNew(context, resource);
91
97
  }
92
98
 
93
- passwordResetToken(context: RepositoryContext, email: string): CustomerToken {
99
+ passwordResetToken(
100
+ context: RepositoryContext,
101
+ request: CustomerCreatePasswordResetToken,
102
+ ): CustomerToken {
94
103
  const results = this._storage.query(context.projectKey, this.getTypeId(), {
95
- where: [`email="${email.toLocaleLowerCase()}"`],
104
+ where: [`email="${request.email.toLocaleLowerCase()}"`],
96
105
  });
97
106
  if (results.count === 0) {
98
107
  throw new CommercetoolsError<ResourceNotFoundError>({
99
108
  code: "ResourceNotFound",
100
- message: `The Customer with ID '${email}' was not found.`,
109
+ message: `The Customer with ID '${request.email}' was not found.`,
101
110
  });
102
111
  }
103
- const expiresAt = new Date(Date.now() + 30 * 60);
112
+
113
+ const ttlMinutes = request.ttlMinutes ?? 34560; // 34560 is CT default
114
+
115
+ const expiresAt = new Date(new Date().getTime() + ttlMinutes * 60 * 1000);
104
116
  const customer = results.results[0] as Customer;
105
117
  const rest = getBaseResourceProperties();
106
118
 
107
- const token = createPasswordResetToken(customer);
119
+ const token = createPasswordResetToken(customer, expiresAt);
120
+
108
121
  return {
109
122
  id: rest.id,
110
123
  createdAt: rest.createdAt,
@@ -115,6 +128,41 @@ export class CustomerRepository extends AbstractResourceRepository<"customer"> {
115
128
  };
116
129
  }
117
130
 
131
+ passwordReset(
132
+ context: RepositoryContext,
133
+ resetPassword: CustomerResetPassword | MyCustomerResetPassword,
134
+ ) {
135
+ const { newPassword, tokenValue } = resetPassword;
136
+
137
+ const customerId = validatePasswordResetToken(tokenValue);
138
+ if (!customerId) {
139
+ throw new CommercetoolsError<ResourceNotFoundError>({
140
+ code: "ResourceNotFound",
141
+ message: `The Customer with ID 'Token(${tokenValue})' was not found.`,
142
+ });
143
+ }
144
+
145
+ const customer = this._storage.get(
146
+ context.projectKey,
147
+ "customer",
148
+ customerId,
149
+ ) as Writable<Customer> | undefined;
150
+
151
+ if (!customer) {
152
+ throw new CommercetoolsError<ResourceNotFoundError>({
153
+ code: "ResourceNotFound",
154
+ message: `The Customer with ID 'Token(${tokenValue})' was not found.`,
155
+ });
156
+ }
157
+
158
+ customer.password = hashPassword(newPassword);
159
+ customer.version += 1;
160
+
161
+ // Update storage
162
+ this._storage.add(context.projectKey, "customer", customer);
163
+ return customer;
164
+ }
165
+
118
166
  verifyEmailToken(context: RepositoryContext, id: string): CustomerToken {
119
167
  const results = this._storage.query(context.projectKey, this.getTypeId(), {
120
168
  where: [`id="${id.toLocaleLowerCase()}"`],
@@ -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): TypedMoney => {
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),
@@ -4,14 +4,9 @@ import {
4
4
  MyCustomerChangePassword,
5
5
  MyCustomerEmailVerify,
6
6
  ResourceNotFoundError,
7
- type MyCustomerResetPassword,
8
7
  } from "@commercetools/platform-sdk";
9
8
  import { CommercetoolsError } from "~src/exceptions";
10
- import {
11
- hashPassword,
12
- validateEmailVerifyToken,
13
- validatePasswordResetToken,
14
- } from "../lib/password";
9
+ import { hashPassword, validateEmailVerifyToken } from "../lib/password";
15
10
  import { Writable } from "../types";
16
11
  import { type RepositoryContext } from "./abstract";
17
12
  import { CustomerRepository } from "./customer";
@@ -116,39 +111,4 @@ export class MyCustomerRepository extends CustomerRepository {
116
111
 
117
112
  return;
118
113
  }
119
-
120
- resetPassword(
121
- context: RepositoryContext,
122
- resetPassword: MyCustomerResetPassword,
123
- ) {
124
- const { newPassword, tokenValue } = resetPassword;
125
-
126
- const customerId = validatePasswordResetToken(tokenValue);
127
- if (!customerId) {
128
- throw new CommercetoolsError<ResourceNotFoundError>({
129
- code: "ResourceNotFound",
130
- message: `The Customer with ID 'Token(${tokenValue})' was not found.`,
131
- });
132
- }
133
-
134
- const customer = this._storage.get(
135
- context.projectKey,
136
- "customer",
137
- customerId,
138
- ) as Writable<Customer> | undefined;
139
-
140
- if (!customer) {
141
- throw new CommercetoolsError<ResourceNotFoundError>({
142
- code: "ResourceNotFound",
143
- message: `The Customer with ID 'Token(${tokenValue})' was not found.`,
144
- });
145
- }
146
-
147
- customer.password = hashPassword(newPassword);
148
- customer.version += 1;
149
-
150
- // Update storage
151
- this._storage.add(context.projectKey, "customer", customer);
152
- return customer;
153
- }
154
114
  }
@@ -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 "../../types";
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,
@@ -1,11 +1,13 @@
1
- import { Customer } from "@commercetools/platform-sdk";
1
+ import { Customer, CustomerToken } 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 { hashPassword } from "~src/lib/password";
5
6
  import { CommercetoolsMock, getBaseResourceProperties } from "../index";
6
7
 
8
+ const ctMock = new CommercetoolsMock();
9
+
7
10
  describe("Customer Update Actions", () => {
8
- const ctMock = new CommercetoolsMock();
9
11
  let customer: Customer | undefined;
10
12
 
11
13
  beforeEach(async () => {
@@ -18,6 +20,7 @@ describe("Customer Update Actions", () => {
18
20
  isEmailVerified: true,
19
21
  authenticationMode: "Password", //default in Commercetools
20
22
  version: 1,
23
+ stores: [],
21
24
  };
22
25
  ctMock.project("dummy").add("customer", customer);
23
26
  });
@@ -447,3 +450,62 @@ describe("Customer Update Actions", () => {
447
450
  expect(response.body.key).toBe("C001");
448
451
  });
449
452
  });
453
+
454
+ describe("Customer Password Reset", () => {
455
+ afterEach(() => {
456
+ ctMock.clear();
457
+ });
458
+
459
+ beforeEach(() => {
460
+ ctMock.project("dummy").add("customer", {
461
+ id: "123",
462
+ createdAt: "2021-03-18T14:00:00.000Z",
463
+ version: 2,
464
+ lastModifiedAt: "2021-03-18T14:00:00.000Z",
465
+ email: "foo@example.org",
466
+ password: hashPassword("p4ssw0rd"),
467
+ addresses: [],
468
+ isEmailVerified: true,
469
+ authenticationMode: "password",
470
+ custom: { type: { typeId: "type", id: "" }, fields: {} },
471
+ stores: [],
472
+ });
473
+ });
474
+
475
+ test("reset password flow", async () => {
476
+ const token = await supertest(ctMock.app)
477
+ .post("/dummy/customers/password-token")
478
+ .send({
479
+ email: "foo@example.org",
480
+ })
481
+ .then((response) => response.body as CustomerToken);
482
+
483
+ const response = await supertest(ctMock.app)
484
+ .post("/dummy/customers/password/reset")
485
+ .send({
486
+ tokenValue: token.value,
487
+ newPassword: "somethingNew",
488
+ });
489
+ expect(response.status).toBe(200);
490
+ });
491
+
492
+ test("fail reset password flow", async () => {
493
+ const response = await supertest(ctMock.app)
494
+ .post("/dummy/customers/password/reset")
495
+ .send({
496
+ tokenValue: "invalid-token",
497
+ newPassword: "somethingNew",
498
+ });
499
+ expect(response.status).toBe(400);
500
+ expect(response.body).toEqual({
501
+ message: `The Customer with ID 'Token(invalid-token)' was not found.`,
502
+ statusCode: 400,
503
+ errors: [
504
+ {
505
+ code: "ResourceNotFound",
506
+ message: `The Customer with ID 'Token(invalid-token)' was not found.`,
507
+ },
508
+ ],
509
+ });
510
+ });
511
+ });
@@ -16,6 +16,12 @@ export class CustomerService extends AbstractService {
16
16
  return "customers";
17
17
  }
18
18
 
19
+ extraRoutes(parent: Router) {
20
+ parent.post("/password-token", this.passwordResetToken.bind(this));
21
+ parent.post("/password/reset", this.passwordReset.bind(this));
22
+ parent.post("/email-token", this.confirmEmailToken.bind(this));
23
+ }
24
+
19
25
  post(request: Request, response: Response) {
20
26
  const draft = request.body;
21
27
  const resource = this.repository.create(
@@ -30,23 +36,30 @@ export class CustomerService extends AbstractService {
30
36
  return response.status(this.createStatusCode).send(result);
31
37
  }
32
38
 
33
- extraRoutes(parent: Router) {
34
- parent.post("/password-token", (request, response) => {
35
- const email = request.body.email;
36
- const token = this.repository.passwordResetToken(
37
- getRepositoryContext(request),
38
- email,
39
- );
40
- return response.status(200).send(token);
41
- });
42
-
43
- parent.post("/email-token", (request, response) => {
44
- const id = request.body.id;
45
- const token = this.repository.verifyEmailToken(
46
- getRepositoryContext(request),
47
- id,
48
- );
49
- return response.status(200).send(token);
50
- });
39
+ passwordResetToken(request: Request, response: Response) {
40
+ const customer = this.repository.passwordResetToken(
41
+ getRepositoryContext(request),
42
+ request.body,
43
+ );
44
+
45
+ return response.status(200).send(customer);
46
+ }
47
+
48
+ passwordReset(request: Request, response: Response) {
49
+ const customer = this.repository.passwordReset(
50
+ getRepositoryContext(request),
51
+ request.body,
52
+ );
53
+
54
+ return response.status(200).send(customer);
55
+ }
56
+
57
+ confirmEmailToken(request: Request, response: Response) {
58
+ const id = request.body.id;
59
+ const token = this.repository.verifyEmailToken(
60
+ getRepositoryContext(request),
61
+ id,
62
+ );
63
+ return response.status(200).send(token);
51
64
  }
52
65
  }
@@ -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
 
@@ -98,7 +98,7 @@ export class MyCustomerService extends AbstractService {
98
98
  }
99
99
 
100
100
  resetPassword(request: Request, response: Response) {
101
- const customer = this.repository.resetPassword(
101
+ const customer = this.repository.passwordReset(
102
102
  getRepositoryContext(request),
103
103
  request.body,
104
104
  );