@labdigital/commercetools-mock 2.37.0 → 2.38.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.
Files changed (130) hide show
  1. package/dist/index.cjs +211 -80
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +211 -80
  4. package/dist/index.js.map +1 -1
  5. package/package.json +10 -9
  6. package/src/ctMock.ts +10 -6
  7. package/src/helpers.ts +4 -4
  8. package/src/index.ts +2 -1
  9. package/src/lib/expandParser.ts +1 -1
  10. package/src/lib/haversine.test.ts +2 -1
  11. package/src/lib/password.ts +2 -2
  12. package/src/lib/predicateParser.ts +1 -1
  13. package/src/lib/productSearchFilter.test.ts +4 -1
  14. package/src/lib/projectionSearchFilter.ts +3 -3
  15. package/src/oauth/helpers.ts +1 -1
  16. package/src/oauth/server.test.ts +2 -1
  17. package/src/oauth/server.ts +5 -8
  18. package/src/oauth/store.ts +1 -1
  19. package/src/priceSelector.ts +1 -1
  20. package/src/product-projection-search.ts +4 -2
  21. package/src/product-search.ts +2 -2
  22. package/src/projectAPI.ts +4 -4
  23. package/src/repositories/abstract.ts +20 -3
  24. package/src/repositories/associate-role.ts +3 -3
  25. package/src/repositories/attribute-group.ts +3 -3
  26. package/src/repositories/business-unit.ts +6 -4
  27. package/src/repositories/cart/actions.ts +6 -7
  28. package/src/repositories/cart/helpers.ts +1 -1
  29. package/src/repositories/cart/index.ts +1 -1
  30. package/src/repositories/cart-discount/actions.ts +2 -5
  31. package/src/repositories/cart-discount/index.ts +1 -1
  32. package/src/repositories/category/actions.ts +4 -7
  33. package/src/repositories/category/index.ts +3 -3
  34. package/src/repositories/channel.ts +2 -2
  35. package/src/repositories/custom-object.ts +3 -6
  36. package/src/repositories/customer/actions.ts +272 -68
  37. package/src/repositories/customer/index.ts +10 -8
  38. package/src/repositories/customer-group.ts +2 -2
  39. package/src/repositories/discount-code/actions.ts +2 -5
  40. package/src/repositories/discount-code/index.ts +1 -1
  41. package/src/repositories/extension.ts +3 -3
  42. package/src/repositories/helpers.ts +4 -2
  43. package/src/repositories/index.ts +1 -1
  44. package/src/repositories/inventory-entry/actions.ts +2 -5
  45. package/src/repositories/inventory-entry/index.ts +1 -1
  46. package/src/repositories/my-customer.ts +2 -2
  47. package/src/repositories/order/actions.ts +2 -5
  48. package/src/repositories/order/index.ts +3 -6
  49. package/src/repositories/order-edit.ts +3 -2
  50. package/src/repositories/payment/actions.ts +2 -5
  51. package/src/repositories/payment/helpers.ts +6 -3
  52. package/src/repositories/payment/index.ts +3 -2
  53. package/src/repositories/product/actions.ts +2 -2
  54. package/src/repositories/product/helpers.ts +4 -4
  55. package/src/repositories/product/index.ts +3 -2
  56. package/src/repositories/product-discount.ts +3 -7
  57. package/src/repositories/product-projection.ts +2 -5
  58. package/src/repositories/product-selection.ts +3 -7
  59. package/src/repositories/product-tailoring.ts +3 -7
  60. package/src/repositories/product-type.ts +7 -11
  61. package/src/repositories/project.ts +4 -8
  62. package/src/repositories/quote-request.ts +3 -2
  63. package/src/repositories/quote.ts +3 -2
  64. package/src/repositories/review.ts +6 -3
  65. package/src/repositories/shipping-method/actions.ts +5 -6
  66. package/src/repositories/shipping-method/helpers.ts +4 -1
  67. package/src/repositories/shipping-method/index.ts +3 -6
  68. package/src/repositories/shopping-list/actions.ts +3 -6
  69. package/src/repositories/shopping-list/index.ts +4 -3
  70. package/src/repositories/staged-quote.ts +3 -2
  71. package/src/repositories/standalone-price.ts +3 -7
  72. package/src/repositories/state.ts +3 -7
  73. package/src/repositories/store.ts +3 -7
  74. package/src/repositories/subscription.ts +4 -8
  75. package/src/repositories/tax-category/actions.ts +2 -1
  76. package/src/repositories/tax-category/helpers.ts +1 -1
  77. package/src/repositories/tax-category/index.ts +3 -2
  78. package/src/repositories/type/actions.ts +2 -1
  79. package/src/repositories/type/index.ts +3 -2
  80. package/src/repositories/zone.ts +3 -7
  81. package/src/services/abstract.ts +2 -2
  82. package/src/services/associate-roles.test.ts +1 -1
  83. package/src/services/associate-roles.ts +2 -2
  84. package/src/services/attribute-group.ts +2 -2
  85. package/src/services/business-units.test.ts +1 -1
  86. package/src/services/business-units.ts +2 -2
  87. package/src/services/cart-discount.test.ts +1 -1
  88. package/src/services/cart-discount.ts +2 -2
  89. package/src/services/category.ts +2 -2
  90. package/src/services/channel.ts +2 -2
  91. package/src/services/customer-group.ts +2 -2
  92. package/src/services/customer.test.ts +422 -132
  93. package/src/services/customer.ts +4 -3
  94. package/src/services/discount-code.ts +2 -2
  95. package/src/services/extension.ts +2 -2
  96. package/src/services/index.ts +1 -1
  97. package/src/services/inventory-entry.ts +2 -2
  98. package/src/services/my-business-unit.ts +1 -1
  99. package/src/services/my-cart.ts +3 -2
  100. package/src/services/my-customer.ts +4 -3
  101. package/src/services/my-order.ts +1 -1
  102. package/src/services/my-payment.ts +2 -2
  103. package/src/services/my-shopping-list.ts +2 -2
  104. package/src/services/order.ts +2 -2
  105. package/src/services/payment.ts +2 -2
  106. package/src/services/product-discount.ts +2 -2
  107. package/src/services/product-projection.test.ts +1 -1
  108. package/src/services/product-projection.ts +2 -2
  109. package/src/services/product-selection.ts +2 -2
  110. package/src/services/product-type.ts +2 -2
  111. package/src/services/product.test.ts +1 -1
  112. package/src/services/product.ts +2 -2
  113. package/src/services/project.ts +3 -3
  114. package/src/services/reviews.ts +2 -2
  115. package/src/services/shipping-method.ts +2 -2
  116. package/src/services/shopping-list.test.ts +1 -1
  117. package/src/services/shopping-list.ts +2 -2
  118. package/src/services/standalone-price.ts +2 -2
  119. package/src/services/state.ts +2 -2
  120. package/src/services/store.ts +2 -2
  121. package/src/services/subscription.ts +2 -2
  122. package/src/services/tax-category.ts +2 -2
  123. package/src/services/type.ts +2 -2
  124. package/src/services/zone.ts +2 -2
  125. package/src/shipping.test.ts +1 -1
  126. package/src/shipping.ts +3 -3
  127. package/src/storage/abstract.ts +5 -1
  128. package/src/storage/in-memory.ts +6 -8
  129. package/src/types.ts +2 -2
  130. package/src/validate.ts +2 -2
@@ -1,9 +1,10 @@
1
- import {
1
+ import type {
2
2
  Customer,
3
3
  CustomerDraft,
4
4
  CustomerToken,
5
5
  } from "@commercetools/platform-sdk";
6
6
  import assert from "assert";
7
+ import { Factory } from "fishery";
7
8
  import supertest from "supertest";
8
9
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
9
10
  import { hashPassword } from "~src/lib/password";
@@ -11,12 +12,67 @@ import { CommercetoolsMock, getBaseResourceProperties } from "../index";
11
12
 
12
13
  const ctMock = new CommercetoolsMock();
13
14
 
15
+ const customerDraftFactory = Factory.define<
16
+ CustomerDraft,
17
+ CustomerDraft,
18
+ Customer
19
+ >(({ onCreate }) => {
20
+ onCreate(async (draft) => {
21
+ const response = await supertest(ctMock.app)
22
+ .post(`/dummy/customers`)
23
+ .send(draft);
24
+
25
+ return response.body.customer;
26
+ });
27
+
28
+ return {
29
+ email: "customer@example.com",
30
+ firstName: "John",
31
+ lastName: "Doe",
32
+ locale: "nl-NL",
33
+ password: "my-secret-pw",
34
+ addresses: [
35
+ {
36
+ firstName: "John",
37
+ lastName: "Doe",
38
+ streetName: "Street name",
39
+ streetNumber: "42",
40
+ postalCode: "1234 AB",
41
+ city: "Utrecht",
42
+ country: "NL",
43
+ company: "Lab Digital",
44
+ phone: "+31612345678",
45
+ email: "customer@example.com",
46
+ },
47
+ ],
48
+ isEmailVerified: false,
49
+ stores: [],
50
+ authenticationMode: "Password",
51
+ };
52
+ });
53
+
14
54
  afterEach(() => {
15
55
  ctMock.clear();
16
56
  });
17
57
 
18
58
  describe("Customer create", () => {
19
59
  test("create new customer", async () => {
60
+ const draft = customerDraftFactory.build();
61
+
62
+ const response = await supertest(ctMock.app)
63
+ .post(`/dummy/customers`)
64
+ .send(draft);
65
+
66
+ const customer = response.body.customer as Customer;
67
+ expect(response.status, JSON.stringify(customer)).toBe(201);
68
+ expect(customer.version).toBe(1);
69
+ expect(customer.defaultBillingAddressId).toBeUndefined();
70
+ expect(customer.defaultShippingAddressId).toBeUndefined();
71
+ expect(customer.billingAddressIds).toHaveLength(0);
72
+ expect(customer.shippingAddressIds).toHaveLength(0);
73
+ });
74
+
75
+ test("create new customer with default billing & shipping address", async () => {
20
76
  const draft: CustomerDraft = {
21
77
  email: "new-user@example.com",
22
78
  password: "supersecret",
@@ -33,8 +89,8 @@ describe("Customer create", () => {
33
89
  country: "DE",
34
90
  },
35
91
  ],
36
- billingAddresses: [0],
37
- shippingAddresses: [0],
92
+ defaultBillingAddress: 0,
93
+ defaultShippingAddress: 0,
38
94
  };
39
95
 
40
96
  const response = await supertest(ctMock.app)
@@ -44,14 +100,373 @@ describe("Customer create", () => {
44
100
  const customer = response.body.customer as Customer;
45
101
  expect(response.status, JSON.stringify(customer)).toBe(201);
46
102
  expect(customer.version).toBe(1);
47
- expect(customer.defaultBillingAddressId).toBeUndefined();
48
- expect(customer.defaultShippingAddressId).toBeUndefined();
103
+ expect(customer.defaultBillingAddressId).toBeDefined();
104
+ expect(customer.defaultShippingAddressId).toBeDefined();
105
+ expect(customer.billingAddressIds).toHaveLength(0);
106
+ expect(customer.shippingAddressIds).toHaveLength(0);
107
+ });
108
+ });
109
+
110
+ describe("Customer Update Actions", () => {
111
+ test("addAddress", async () => {
112
+ const customer = await customerDraftFactory.create();
113
+ const response = await supertest(ctMock.app)
114
+ .post(`/dummy/customers/${customer.id}`)
115
+ .send({
116
+ version: 1,
117
+ actions: [
118
+ {
119
+ action: "addAddress",
120
+ address: {
121
+ firstName: "Foo",
122
+ lastName: "Bar",
123
+ streetName: "Baz Street",
124
+ streetNumber: "99",
125
+ postalCode: "12ab",
126
+ country: "NL",
127
+ },
128
+ },
129
+ ],
130
+ });
131
+ expect(response.status).toBe(200);
132
+ expect(response.body.version).toBe(2);
133
+ expect(response.body.addresses).toHaveLength(2);
134
+ });
135
+
136
+ test("removeAddress by ID", async () => {
137
+ const customer = await customerDraftFactory.create({
138
+ addresses: [
139
+ {
140
+ key: "address-key",
141
+ firstName: "John",
142
+ lastName: "Doe",
143
+ streetName: "Main Street",
144
+ streetNumber: "1",
145
+ postalCode: "12345",
146
+ country: "DE",
147
+ },
148
+ ],
149
+ });
150
+
151
+ const response = await supertest(ctMock.app)
152
+ .post(`/dummy/customers/${customer.id}`)
153
+ .send({
154
+ version: 1,
155
+ actions: [
156
+ {
157
+ action: "removeAddress",
158
+ addressId: customer.addresses[0].id,
159
+ },
160
+ ],
161
+ });
162
+ expect(response.status, JSON.stringify(response.body)).toBe(200);
163
+ expect(response.body.version).toBe(2);
164
+ expect(response.body.addresses).toHaveLength(0);
165
+ });
166
+
167
+ test("removeAddress by Key", async () => {
168
+ const customer = await customerDraftFactory.create({
169
+ addresses: [
170
+ {
171
+ key: "address-key",
172
+ firstName: "John",
173
+ lastName: "Doe",
174
+ streetName: "Main Street",
175
+ streetNumber: "1",
176
+ postalCode: "12345",
177
+ country: "DE",
178
+ },
179
+ ],
180
+ });
181
+
182
+ const response = await supertest(ctMock.app)
183
+ .post(`/dummy/customers/${customer.id}`)
184
+ .send({
185
+ version: 1,
186
+ actions: [
187
+ {
188
+ action: "removeAddress",
189
+ addressKey: customer.addresses[0].key,
190
+ },
191
+ ],
192
+ });
193
+ expect(response.status, JSON.stringify(response.body)).toBe(200);
194
+ expect(response.body.version).toBe(2);
195
+ expect(response.body.addresses).toHaveLength(0);
196
+ });
197
+
198
+ test("changeAddress by ID", async () => {
199
+ const customer = await customerDraftFactory.create({
200
+ addresses: [
201
+ {
202
+ key: "address-key",
203
+ firstName: "John",
204
+ lastName: "Doe",
205
+ streetName: "Main Street",
206
+ streetNumber: "1",
207
+ postalCode: "12345",
208
+ country: "DE",
209
+ },
210
+ ],
211
+ });
212
+ const addressId = customer.addresses[0].id;
213
+
214
+ const response = await supertest(ctMock.app)
215
+ .post(`/dummy/customers/${customer.id}`)
216
+ .send({
217
+ version: 1,
218
+ actions: [
219
+ {
220
+ action: "changeAddress",
221
+ addressId: addressId,
222
+ address: {
223
+ firstName: "Foo",
224
+ lastName: "Bar",
225
+ streetName: "Baz Street",
226
+ streetNumber: "99",
227
+ postalCode: "12ab",
228
+ country: "NL",
229
+ },
230
+ },
231
+ ],
232
+ });
233
+ expect(response.status, JSON.stringify(response.body)).toBe(200);
234
+ const result = response.body as Customer;
235
+ expect(result.version).toBe(2);
236
+ expect(result.addresses).toHaveLength(1);
237
+ expect(result.addresses).toStrictEqual([
238
+ {
239
+ id: addressId,
240
+ firstName: "Foo",
241
+ lastName: "Bar",
242
+ streetName: "Baz Street",
243
+ streetNumber: "99",
244
+ postalCode: "12ab",
245
+ country: "NL",
246
+ },
247
+ ]);
248
+ });
249
+
250
+ test("addBillingAddressId", async () => {
251
+ const customer = await customerDraftFactory.create({
252
+ addresses: [
253
+ {
254
+ key: "address-key",
255
+ firstName: "John",
256
+ lastName: "Doe",
257
+ streetName: "Main Street",
258
+ streetNumber: "1",
259
+ postalCode: "12345",
260
+ country: "DE",
261
+ },
262
+ ],
263
+ });
264
+
265
+ const response = await supertest(ctMock.app)
266
+ .post(`/dummy/customers/${customer.id}`)
267
+ .send({
268
+ version: 1,
269
+ actions: [
270
+ {
271
+ action: "addBillingAddressId",
272
+ addressId: customer.addresses[0].id,
273
+ },
274
+ ],
275
+ });
276
+ expect(response.status).toBe(200);
277
+ expect(response.body.version).toBe(2);
278
+ expect(response.body.shippingAddressIds).toHaveLength(0);
279
+ expect(response.body.billingAddressIds).toHaveLength(1);
280
+ });
281
+
282
+ test("removeBillingAddressId", async () => {
283
+ const customer = await customerDraftFactory.create({
284
+ addresses: [
285
+ {
286
+ key: "address-key",
287
+ firstName: "John",
288
+ lastName: "Doe",
289
+ streetName: "Main Street",
290
+ streetNumber: "1",
291
+ postalCode: "12345",
292
+ country: "DE",
293
+ },
294
+ ],
295
+ billingAddresses: [0],
296
+ defaultBillingAddress: 0,
297
+ });
49
298
  expect(customer.billingAddressIds).toHaveLength(1);
299
+ expect(customer.defaultBillingAddressId).toBeDefined();
300
+
301
+ const addressId = customer.addresses[0].id;
302
+ const response = await supertest(ctMock.app)
303
+ .post(`/dummy/customers/${customer.id}`)
304
+ .send({
305
+ version: 1,
306
+ actions: [
307
+ {
308
+ action: "removeBillingAddressId",
309
+ addressId: addressId,
310
+ },
311
+ ],
312
+ });
313
+ expect(response.status).toBe(200);
314
+ const result = response.body as Customer;
315
+ expect(result.version).toBe(2);
316
+ expect(result.billingAddressIds).toHaveLength(0);
317
+ expect(result.defaultBillingAddressId).toBeUndefined();
318
+ });
319
+
320
+ test("setDefaultBillingAddress by ID", async () => {
321
+ const customer = await customerDraftFactory.create({
322
+ defaultBillingAddress: undefined,
323
+ defaultShippingAddress: undefined,
324
+ addresses: [
325
+ {
326
+ key: "address-key",
327
+ firstName: "John",
328
+ lastName: "Doe",
329
+ streetName: "Main Street",
330
+ streetNumber: "1",
331
+ postalCode: "12345",
332
+ country: "DE",
333
+ },
334
+ ],
335
+ shippingAddresses: [],
336
+ billingAddresses: [],
337
+ });
338
+ const addressId = customer.addresses[0].id;
339
+
340
+ const response = await supertest(ctMock.app)
341
+ .post(`/dummy/customers/${customer.id}`)
342
+ .send({
343
+ version: customer.version,
344
+ actions: [
345
+ {
346
+ action: "setDefaultBillingAddress",
347
+ addressId: addressId,
348
+ },
349
+ ],
350
+ });
351
+ expect(response.status, JSON.stringify(response.body)).toBe(200);
352
+ expect(response.body.version).toBe(2);
353
+ expect(response.body.defaultBillingAddressId).toBe(addressId);
354
+ expect(response.body.addresses).toHaveLength(1);
355
+ expect(response.body.billingAddressIds).toContain(addressId);
356
+ });
357
+
358
+ test("addShippingAddressId", async () => {
359
+ const customer = await customerDraftFactory.create({
360
+ addresses: [
361
+ {
362
+ key: "address-key",
363
+ firstName: "John",
364
+ lastName: "Doe",
365
+ streetName: "Main Street",
366
+ streetNumber: "1",
367
+ postalCode: "12345",
368
+ country: "DE",
369
+ },
370
+ ],
371
+ });
372
+
373
+ const response = await supertest(ctMock.app)
374
+ .post(`/dummy/customers/${customer.id}`)
375
+ .send({
376
+ version: 1,
377
+ actions: [
378
+ {
379
+ action: "addShippingAddressId",
380
+ addressId: customer.addresses[0].id,
381
+ },
382
+ ],
383
+ });
384
+ expect(response.status).toBe(200);
385
+ expect(response.body.version).toBe(2);
386
+ expect(response.body.shippingAddressIds).toHaveLength(1);
387
+ });
388
+
389
+ test("removeShippingAddressId", async () => {
390
+ const customer = await customerDraftFactory.create({
391
+ addresses: [
392
+ {
393
+ key: "address-key",
394
+ firstName: "John",
395
+ lastName: "Doe",
396
+ streetName: "Main Street",
397
+ streetNumber: "1",
398
+ postalCode: "12345",
399
+ country: "DE",
400
+ },
401
+ ],
402
+ shippingAddresses: [0],
403
+ defaultShippingAddress: 0,
404
+ });
50
405
  expect(customer.shippingAddressIds).toHaveLength(1);
406
+ expect(customer.defaultShippingAddressId).toBeDefined();
407
+
408
+ const addressId = customer.addresses[0].id;
409
+ const response = await supertest(ctMock.app)
410
+ .post(`/dummy/customers/${customer.id}`)
411
+ .send({
412
+ version: 1,
413
+ actions: [
414
+ {
415
+ action: "removeShippingAddressId",
416
+ addressId: addressId,
417
+ },
418
+ ],
419
+ });
420
+ expect(response.status).toBe(200);
421
+ const result = response.body as Customer;
422
+ expect(result.version).toBe(2);
423
+ expect(result.shippingAddressIds).toHaveLength(0);
424
+ expect(result.defaultShippingAddressId).toBeUndefined();
425
+ });
426
+
427
+ test("setDefaultShippingAddress by ID", async () => {
428
+ const customer = await customerDraftFactory.create({
429
+ defaultBillingAddress: undefined,
430
+ defaultShippingAddress: undefined,
431
+ addresses: [
432
+ {
433
+ key: "address-key",
434
+ firstName: "John",
435
+ lastName: "Doe",
436
+ streetName: "Main Street",
437
+ streetNumber: "1",
438
+ postalCode: "12345",
439
+ country: "DE",
440
+ },
441
+ ],
442
+ shippingAddresses: [],
443
+ billingAddresses: [],
444
+ });
445
+ const addressId = customer.addresses[0].id;
446
+
447
+ const response = await supertest(ctMock.app)
448
+ .post(`/dummy/customers/${customer.id}`)
449
+ .send({
450
+ version: customer.version,
451
+ actions: [
452
+ {
453
+ action: "setDefaultShippingAddress",
454
+ addressId: addressId,
455
+ },
456
+ ],
457
+ });
458
+ expect(response.status, JSON.stringify(response.body)).toBe(200);
459
+ const result = response.body as Customer;
460
+ expect(result.version).toBe(2);
461
+ expect(result.defaultShippingAddressId).toBe(addressId);
462
+ expect(result.addresses).toHaveLength(1);
463
+ expect(result.shippingAddressIds).toContain(addressId);
51
464
  });
52
465
  });
53
466
 
54
- describe("Customer Update Actions", () => {
467
+ // These tests use ctMock.project().add(), which we want to move away from.
468
+ // Please add new test to the previous section.
469
+ describe("Customer Update Actions (old-style)", () => {
55
470
  let customer: Customer | undefined;
56
471
 
57
472
  beforeEach(async () => {
@@ -142,7 +557,7 @@ describe("Customer Update Actions", () => {
142
557
  test("setAuthenticationMode error when setting current authMode", async () => {
143
558
  assert(customer, "customer not created");
144
559
  assert(
145
- customer.authenticationMode == "Password",
560
+ customer.authenticationMode === "Password",
146
561
  "customer not in default state",
147
562
  );
148
563
 
@@ -360,131 +775,6 @@ describe("Customer Update Actions", () => {
360
775
  expect(response.body.vatId).toBe("ABCD");
361
776
  });
362
777
 
363
- test("addAddress", async () => {
364
- assert(customer, "customer not created");
365
-
366
- customer = {
367
- ...customer,
368
- addresses: [
369
- {
370
- ...getBaseResourceProperties(),
371
- id: "address-uuid",
372
- firstName: "John",
373
- lastName: "Doe",
374
- streetName: "Main Street",
375
- streetNumber: "1",
376
- postalCode: "12345",
377
- country: "DE",
378
- },
379
- ],
380
- defaultBillingAddressId: "address-uuid",
381
- };
382
- ctMock.project("dummy").add("customer", customer);
383
-
384
- const response = await supertest(ctMock.app)
385
- .post(`/dummy/customers/${customer.id}`)
386
- .send({
387
- version: 1,
388
- actions: [
389
- {
390
- action: "addAddress",
391
- address: {
392
- firstName: "Foo",
393
- lastName: "Bar",
394
- streetName: "Baz Street",
395
- streetNumber: "99",
396
- postalCode: "12ab",
397
- country: "NL",
398
- },
399
- },
400
- ],
401
- });
402
- expect(response.status).toBe(200);
403
- expect(response.body.version).toBe(2);
404
- expect(response.body.addresses).toMatchObject([
405
- {
406
- id: "address-uuid",
407
- firstName: "John",
408
- lastName: "Doe",
409
- streetName: "Main Street",
410
- streetNumber: "1",
411
- postalCode: "12345",
412
- country: "DE",
413
- },
414
- {
415
- id: expect.any(String),
416
- firstName: "Foo",
417
- lastName: "Bar",
418
- streetName: "Baz Street",
419
- streetNumber: "99",
420
- postalCode: "12ab",
421
- country: "NL",
422
- },
423
- ]);
424
- });
425
-
426
- test("addBillingAddressId", async () => {
427
- assert(customer, "customer not created");
428
-
429
- customer = {
430
- ...customer,
431
- addresses: [
432
- {
433
- key: "address-key",
434
- firstName: "John",
435
- lastName: "Doe",
436
- streetName: "Main Street",
437
- streetNumber: "1",
438
- postalCode: "12345",
439
- country: "DE",
440
- },
441
- ],
442
- };
443
- ctMock.project("dummy").add("customer", customer);
444
-
445
- const response = await supertest(ctMock.app)
446
- .post(`/dummy/customers/${customer.id}`)
447
- .send({
448
- version: 1,
449
- actions: [{ action: "addBillingAddressId", addressKey: "address-key" }],
450
- });
451
- expect(response.status).toBe(200);
452
- expect(response.body.version).toBe(2);
453
- expect(response.body.billingAddressIds).toHaveLength(1);
454
- });
455
-
456
- test("addShippingAddressId", async () => {
457
- assert(customer, "customer not created");
458
-
459
- customer = {
460
- ...customer,
461
- addresses: [
462
- {
463
- key: "address-key",
464
- firstName: "John",
465
- lastName: "Doe",
466
- streetName: "Main Street",
467
- streetNumber: "1",
468
- postalCode: "12345",
469
- country: "DE",
470
- },
471
- ],
472
- };
473
- ctMock.project("dummy").add("customer", customer);
474
-
475
- const response = await supertest(ctMock.app)
476
- .post(`/dummy/customers/${customer.id}`)
477
- .send({
478
- version: 1,
479
- actions: [
480
- { action: "addShippingAddressId", addressKey: "address-key" },
481
- ],
482
- });
483
- expect(response.status).toBe(200);
484
- expect(response.body.version).toBe(2);
485
- expect(response.body.shippingAddressIds).toHaveLength(1);
486
- });
487
-
488
778
  test("changeAddress", async () => {
489
779
  assert(customer, "customer not created");
490
780
 
@@ -1,6 +1,7 @@
1
- import { CustomerSignInResult } from "@commercetools/platform-sdk";
2
- import { Router, type Request, type Response } from "express";
3
- import { CustomerRepository } from "../repositories/customer";
1
+ import type { CustomerSignInResult } from "@commercetools/platform-sdk";
2
+ import type { Router } from "express";
3
+ import { type Request, type Response } from "express";
4
+ import type { CustomerRepository } from "../repositories/customer";
4
5
  import { getRepositoryContext } from "../repositories/helpers";
5
6
  import AbstractService from "./abstract";
6
7
 
@@ -1,5 +1,5 @@
1
- import { Router } from "express";
2
- import { DiscountCodeRepository } from "../repositories/discount-code/index";
1
+ import type { Router } from "express";
2
+ import type { DiscountCodeRepository } from "../repositories/discount-code/index";
3
3
  import AbstractService from "./abstract";
4
4
 
5
5
  export class DiscountCodeService extends AbstractService {
@@ -1,5 +1,5 @@
1
- import { Router } from "express";
2
- import { ExtensionRepository } from "../repositories/extension";
1
+ import type { Router } from "express";
2
+ import type { ExtensionRepository } from "../repositories/extension";
3
3
  import AbstractService from "./abstract";
4
4
 
5
5
  export class ExtensionServices extends AbstractService {
@@ -1,4 +1,4 @@
1
- import { createRepositories } from "../repositories";
1
+ import type { createRepositories } from "../repositories";
2
2
  import { AssociateRoleServices } from "./associate-roles";
3
3
  import { AttributeGroupService } from "./attribute-group";
4
4
  import { BusinessUnitServices } from "./business-units";
@@ -1,5 +1,5 @@
1
- import { Router } from "express";
2
- import { InventoryEntryRepository } from "../repositories/inventory-entry";
1
+ import type { Router } from "express";
2
+ import type { InventoryEntryRepository } from "../repositories/inventory-entry";
3
3
  import AbstractService from "./abstract";
4
4
 
5
5
  export class InventoryEntryService extends AbstractService {
@@ -1,5 +1,5 @@
1
1
  import { Router } from "express";
2
- import { BusinessUnitRepository } from "~src/repositories/business-unit";
2
+ import type { BusinessUnitRepository } from "~src/repositories/business-unit";
3
3
  import AbstractService from "./abstract";
4
4
 
5
5
  export class MyBusinessUnitService extends AbstractService {
@@ -1,5 +1,6 @@
1
- import { Request, Response, Router } from "express";
2
- import { CartRepository } from "../repositories/cart";
1
+ import type { Request, Response } from "express";
2
+ import { Router } from "express";
3
+ import type { CartRepository } from "../repositories/cart";
3
4
  import AbstractService from "./abstract";
4
5
 
5
6
  export class MyCartService extends AbstractService {
@@ -1,10 +1,11 @@
1
- import { Update } from "@commercetools/platform-sdk";
2
- import { Request, Response, Router } from "express";
1
+ import type { Update } from "@commercetools/platform-sdk";
2
+ import type { Request, Response } from "express";
3
+ import { Router } from "express";
3
4
  import { updateRequestSchema } from "~src/schemas/update-request";
4
5
  import { validateData } from "~src/validate";
5
6
  import { hashPassword } from "../lib/password";
6
7
  import { getRepositoryContext } from "../repositories/helpers";
7
- import { MyCustomerRepository } from "../repositories/my-customer";
8
+ import type { MyCustomerRepository } from "../repositories/my-customer";
8
9
  import AbstractService from "./abstract";
9
10
 
10
11
  export class MyCustomerService extends AbstractService {
@@ -1,5 +1,5 @@
1
1
  import { Router } from "express";
2
- import { MyOrderRepository } from "../repositories/my-order";
2
+ import type { MyOrderRepository } from "../repositories/my-order";
3
3
  import AbstractService from "./abstract";
4
4
 
5
5
  export class MyOrderService extends AbstractService {
@@ -1,5 +1,5 @@
1
- import { Router } from "express";
2
- import { PaymentRepository } from "../repositories/payment";
1
+ import type { Router } from "express";
2
+ import type { PaymentRepository } from "../repositories/payment";
3
3
  import AbstractService from "./abstract";
4
4
 
5
5
  export class MyPaymentService extends AbstractService {