@lookiero/checkout 8.14.0-beta.102 → 8.14.0-beta.3

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 (137) hide show
  1. package/dist/pact.config.d.ts +4 -12
  2. package/dist/pact.config.js +4 -11
  3. package/dist/src/infrastructure/projection/bookedProductsVariants/bookedProductsVariants.mock.d.ts +0 -1
  4. package/dist/src/infrastructure/projection/bookedProductsVariants/bookedProductsVariants.mock.js +24 -24
  5. package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.js +33 -40
  6. package/dist/src/infrastructure/projection/checkout/checkout.mock.d.ts +6 -6
  7. package/dist/src/infrastructure/projection/checkout/checkout.mock.js +12 -15
  8. package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.js +82 -89
  9. package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.js +33 -40
  10. package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js +31 -38
  11. package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js +31 -38
  12. package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js +31 -38
  13. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +2 -5
  14. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +8 -10
  15. package/dist/src/infrastructure/projection/checkoutBooking/checkoutBooking.mock.d.ts +0 -1
  16. package/dist/src/infrastructure/projection/checkoutBooking/checkoutBooking.mock.js +3 -3
  17. package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js +33 -40
  18. package/dist/src/infrastructure/projection/checkoutItem/checkoutItem.mock.d.ts +6 -10
  19. package/dist/src/infrastructure/projection/checkoutItem/checkoutItem.mock.js +38 -39
  20. package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.js +33 -40
  21. package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.d.ts +0 -1
  22. package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.js +96 -97
  23. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.js +33 -40
  24. package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js +83 -94
  25. package/dist/src/infrastructure/projection/payment/paymentFlowPayload.mock.d.ts +1 -7
  26. package/dist/src/infrastructure/projection/payment/paymentFlowPayload.mock.js +173 -178
  27. package/dist/src/infrastructure/projection/payment/react/useViewPaymentFlowPayloadByCheckoutId.js +1 -1
  28. package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.js +33 -40
  29. package/dist/src/infrastructure/projection/pricing/pricing.mock.d.ts +2 -3
  30. package/dist/src/infrastructure/projection/pricing/pricing.mock.js +34 -35
  31. package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.js +33 -40
  32. package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.d.ts +0 -1
  33. package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.js +377 -378
  34. package/dist/src/infrastructure/ui/Root.d.ts +2 -1
  35. package/dist/src/infrastructure/ui/Root.js +4 -2
  36. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +13 -14
  37. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +1 -2
  38. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +0 -1
  39. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +1 -2
  40. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +0 -1
  41. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +1 -1
  42. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +14 -15
  43. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +0 -1
  44. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +7 -32
  45. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +9 -9
  46. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +9 -10
  47. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +3 -2
  48. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.style.d.ts +1 -1
  49. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.style.js +1 -1
  50. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.js +3 -2
  51. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +1 -2
  52. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +2 -12
  53. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +5 -5
  54. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +5 -6
  55. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +3 -4
  56. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +32 -47
  57. package/dist/src/infrastructure/ui/i18n/fetchTranslations.d.ts +2 -3
  58. package/dist/src/infrastructure/ui/i18n/fetchTranslations.js +5 -13
  59. package/dist/src/infrastructure/ui/i18n/translationEndpoint.d.ts +6 -7
  60. package/dist/src/infrastructure/ui/i18n/translationEndpoint.js +14 -20
  61. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +4 -5
  62. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +15 -21
  63. package/dist/src/infrastructure/ui/test/render.js +3 -1
  64. package/dist/src/infrastructure/ui/views/App.js +12 -9
  65. package/dist/src/infrastructure/ui/views/App.style.d.ts +3 -3
  66. package/dist/src/infrastructure/ui/views/App.style.js +3 -4
  67. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +4 -4
  68. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +4 -5
  69. package/dist/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.js +3 -2
  70. package/dist/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.style.d.ts +1 -1
  71. package/dist/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.style.js +1 -1
  72. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +4 -5
  73. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +19 -43
  74. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +9 -9
  75. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +9 -10
  76. package/dist/src/infrastructure/ui/views/item/components/selectModal/SelectModal.d.ts +2 -9
  77. package/dist/src/infrastructure/ui/views/item/components/selectModal/SelectModal.js +6 -5
  78. package/dist/src/infrastructure/ui/views/item/components/selectModal/SelectModal.style.d.ts +1 -1
  79. package/dist/src/infrastructure/ui/views/item/components/selectModal/SelectModal.style.js +1 -1
  80. package/dist/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.js +3 -2
  81. package/dist/src/infrastructure/ui/views/return/Return.style.d.ts +37 -37
  82. package/dist/src/infrastructure/ui/views/return/Return.style.js +37 -38
  83. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +2 -3
  84. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +6 -7
  85. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +3 -22
  86. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +4 -4
  87. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +4 -5
  88. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +8 -17
  89. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +4 -12
  90. package/dist/src/projection/shared/country.d.ts +11 -11
  91. package/dist/src/projection/shared/country.js +11 -11
  92. package/dist/src/projection/shared/customer.d.ts +3 -4
  93. package/dist/src/projection/shared/locale.d.ts +9 -9
  94. package/dist/src/projection/shared/locale.js +9 -9
  95. package/dist/src/projection/shared/order.d.ts +3 -3
  96. package/dist/src/projection/shared/price.d.ts +5 -6
  97. package/dist/src/projection/shared/size.d.ts +10 -11
  98. package/dist/src/projection/shared/size.js +0 -1
  99. package/dist/src/shared/ui/components/atoms/error/Error.d.ts +2 -3
  100. package/dist/src/shared/ui/components/atoms/error/Error.js +1 -3
  101. package/dist/src/version.d.ts +1 -1
  102. package/dist/src/version.js +1 -1
  103. package/jest.setup.js +20 -0
  104. package/package.json +4 -3
  105. package/pact.config.ts +31 -0
  106. package/pact.publish.js +32 -0
  107. package/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.ts +62 -0
  108. package/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.ts +128 -0
  109. package/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.ts +63 -0
  110. package/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.ts +57 -0
  111. package/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.ts +57 -0
  112. package/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.ts +57 -0
  113. package/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.ts +63 -0
  114. package/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.ts +64 -0
  115. package/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.ts +62 -0
  116. package/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.ts +136 -0
  117. package/src/infrastructure/projection/payment/react/useViewPaymentFlowPayloadByCheckoutId.ts +1 -1
  118. package/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.ts +62 -0
  119. package/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.ts +62 -0
  120. package/src/infrastructure/ui/Root.tsx +21 -17
  121. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.style.ts +1 -1
  122. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.tsx +3 -2
  123. package/src/infrastructure/ui/components/organisms/returnQuestions/components/modalOptionReturnQuestionItems/ModalOptionReturnQuestionItems.tsx +3 -2
  124. package/src/infrastructure/ui/test/render.tsx +4 -1
  125. package/src/infrastructure/ui/views/App.style.ts +9 -0
  126. package/src/infrastructure/ui/views/App.tsx +23 -19
  127. package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.style.ts +1 -1
  128. package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.tsx +3 -2
  129. package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/__snapshots__/GetOutOfCheckoutModal.test.tsx.snap +6 -3
  130. package/src/infrastructure/ui/views/item/components/itemActions/ItemActions.tsx +1 -0
  131. package/src/infrastructure/ui/views/item/components/selectModal/SelectModal.style.ts +1 -1
  132. package/src/infrastructure/ui/views/item/components/selectModal/SelectModal.tsx +10 -21
  133. package/src/infrastructure/ui/views/item/components/selectModal/__snapshots__/SelecModal.test.tsx.snap +5 -8
  134. package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.tsx +4 -2
  135. package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/__snapshots__/SizeWithoutStockModal.test.tsx.snap +6 -3
  136. package/src/infrastructure/ui/views/item/views/itemWithoutCustomerDecission/ItemWithoutCustomerDecission.tsx +2 -2
  137. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +3 -9
@@ -1,21 +1,13 @@
1
1
  import { V3MockServer } from "@pact-foundation/pact";
2
-
3
2
  interface StringObject {
4
- readonly [k: string]: string;
3
+ readonly [k: string]: string;
5
4
  }
6
5
  declare const DEFAULT_PACT_OPTIONS: StringObject;
7
- declare const AUTH_TOKEN =
8
- "eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6InBpY2tlcixwYWNrZXIiLCJzdWIiOiIxIiwiaWF0IjoxNjAyODQ4MzEyfQ.gCs2_vBcJsXt4EdreNSjDI8NWkOTQ5Cy4SwtrGnuJ44";
6
+ declare const AUTH_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6InBpY2tlcixwYWNrZXIiLCJzdWIiOiIxIiwiaWF0IjoxNjAyODQ4MzEyfQ.gCs2_vBcJsXt4EdreNSjDI8NWkOTQ5Cy4SwtrGnuJ44";
9
7
  declare const DEFAULT_REQUEST_HEADERS: StringObject;
10
8
  declare const DEFAULT_RESPONSE_HEADERS: StringObject;
11
9
  interface FromMockServerUrlToApiUrlFunction {
12
- (mockServer: V3MockServer): string;
10
+ (mockServer: V3MockServer): string;
13
11
  }
14
12
  declare const fromMockServerUrlToApiUrl: FromMockServerUrlToApiUrlFunction;
15
- export {
16
- fromMockServerUrlToApiUrl,
17
- AUTH_TOKEN,
18
- DEFAULT_PACT_OPTIONS,
19
- DEFAULT_REQUEST_HEADERS,
20
- DEFAULT_RESPONSE_HEADERS,
21
- };
13
+ export { fromMockServerUrlToApiUrl, AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, };
@@ -1,16 +1,9 @@
1
1
  const DEFAULT_PACT_OPTIONS = { dir: ".contracts", logDir: ".pact/logs" };
2
- const AUTH_TOKEN =
3
- "eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6InBpY2tlcixwYWNrZXIiLCJzdWIiOiIxIiwiaWF0IjoxNjAyODQ4MzEyfQ.gCs2_vBcJsXt4EdreNSjDI8NWkOTQ5Cy4SwtrGnuJ44";
2
+ const AUTH_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6InBpY2tlcixwYWNrZXIiLCJzdWIiOiIxIiwiaWF0IjoxNjAyODQ4MzEyfQ.gCs2_vBcJsXt4EdreNSjDI8NWkOTQ5Cy4SwtrGnuJ44";
4
3
  const DEFAULT_REQUEST_HEADERS = {
5
- Authorization: `Bearer ${AUTH_TOKEN}`,
6
- ["Content-Type"]: "application/json",
4
+ Authorization: `Bearer ${AUTH_TOKEN}`,
5
+ ["Content-Type"]: "application/json",
7
6
  };
8
7
  const DEFAULT_RESPONSE_HEADERS = { ["Content-Type"]: "application/json" };
9
8
  const fromMockServerUrlToApiUrl = (mockServer) => mockServer.url.concat("/api");
10
- export {
11
- fromMockServerUrlToApiUrl,
12
- AUTH_TOKEN,
13
- DEFAULT_PACT_OPTIONS,
14
- DEFAULT_REQUEST_HEADERS,
15
- DEFAULT_RESPONSE_HEADERS,
16
- };
9
+ export { fromMockServerUrlToApiUrl, AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, };
@@ -1,4 +1,3 @@
1
1
  import { BookedProductsVariantsProjection } from "../../../projection/bookedProductsVariants/bookedProductsVariants";
2
-
3
2
  declare const bookedProductsVariants: BookedProductsVariantsProjection;
4
3
  export { bookedProductsVariants };
@@ -1,27 +1,27 @@
1
1
  const bookedProductsVariants = {
2
- productVariants: [
3
- {
4
- id: "383fab95-56eb-4639-bb18-530ab792b4d3",
5
- size: {
6
- id: "4f8a26b8-8d2d-4012-b49a-7d2820095598",
7
- europe: "S",
8
- lookiero: "S",
9
- uk: "S",
10
- it: "S",
11
- unique: false,
12
- },
13
- },
14
- {
15
- id: "a5422445-0e62-4b11-8a3f-1bb5469ee154",
16
- size: {
17
- id: "a5422445-0e62-4b11-8a3f-1bb5469ee154",
18
- europe: "M",
19
- lookiero: "M",
20
- uk: "M",
21
- it: "M",
22
- unique: false,
23
- },
24
- },
25
- ],
2
+ productVariants: [
3
+ {
4
+ id: "383fab95-56eb-4639-bb18-530ab792b4d3",
5
+ size: {
6
+ id: "4f8a26b8-8d2d-4012-b49a-7d2820095598",
7
+ europe: "S",
8
+ lookiero: "S",
9
+ uk: "S",
10
+ it: "S",
11
+ unique: false,
12
+ },
13
+ },
14
+ {
15
+ id: "a5422445-0e62-4b11-8a3f-1bb5469ee154",
16
+ size: {
17
+ id: "a5422445-0e62-4b11-8a3f-1bb5469ee154",
18
+ europe: "M",
19
+ lookiero: "M",
20
+ uk: "M",
21
+ it: "M",
22
+ unique: false,
23
+ },
24
+ },
25
+ ],
26
26
  };
27
27
  export { bookedProductsVariants };
@@ -1,55 +1,48 @@
1
1
  import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
2
  import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
- import {
4
- AUTH_TOKEN,
5
- DEFAULT_PACT_OPTIONS,
6
- DEFAULT_REQUEST_HEADERS,
7
- DEFAULT_RESPONSE_HEADERS,
8
- fromMockServerUrlToApiUrl,
9
- } from "../../../../pact.config";
3
+ import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
10
4
  import { bookedProductsVariants } from "./bookedProductsVariants.mock";
11
5
  import { httpBookedProductsVariantsForCheckoutItemView } from "./httpBookedProductsVariantsForCheckoutItemView";
12
-
13
6
  const provider = new PactV3({
14
- ...DEFAULT_PACT_OPTIONS,
15
- consumer: "STY-BOX_CHECKOUT-FRONT",
16
- provider: "STY-BOX_CHECKOUT-BACK_ViewBookedProductVariantsForCheckoutItem",
7
+ ...DEFAULT_PACT_OPTIONS,
8
+ consumer: "STY-BOX_CHECKOUT-FRONT",
9
+ provider: "STY-BOX_CHECKOUT-BACK_ViewBookedProductVariantsForCheckoutItem",
17
10
  });
18
11
  const checkoutItemId = "52440ae5-7a4c-498b-8b35-08ecfde15776";
19
12
  const bookedProductsVariantsResponse = {
20
- result: bookedProductsVariants,
13
+ result: bookedProductsVariants,
21
14
  };
22
15
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
16
  // @ts-ignore
24
17
  const EXPECTED_BODY = MatchersV3.like(bookedProductsVariantsResponse);
25
18
  describe("STY-BOX_CHECKOUT-BACK_ViewBookedProductVariantsForCheckoutItem API", () => {
26
- it("returns a valid booked size change product variants for the given checkout item", () => {
27
- provider
28
- .given("a valid booked size change product variants for the given checkout item")
29
- .uponReceiving("booked size change product variants projection")
30
- .withRequest({
31
- method: "POST",
32
- path: "/api/view-booked-product-variants-for-checkout-item",
33
- headers: DEFAULT_REQUEST_HEADERS,
34
- body: { checkoutItemId },
35
- })
36
- .willRespondWith({
37
- status: 200,
38
- headers: DEFAULT_RESPONSE_HEADERS,
39
- body: EXPECTED_BODY,
40
- });
41
- return provider.executeTest(async (mockserver) => {
42
- const httpPost = fetchHttpPost({
43
- apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
44
- getAuthToken: () => Promise.resolve(AUTH_TOKEN),
45
- device: "web",
46
- version: "1.0.0",
47
- });
48
- const response = await httpBookedProductsVariantsForCheckoutItemView({ httpPost })({
49
- checkoutItemId,
50
- signal: undefined,
51
- });
52
- expect(response).toStrictEqual(bookedProductsVariantsResponse.result);
19
+ it("returns a valid booked size change product variants for the given checkout item", () => {
20
+ provider
21
+ .given("a valid booked size change product variants for the given checkout item")
22
+ .uponReceiving("booked size change product variants projection")
23
+ .withRequest({
24
+ method: "POST",
25
+ path: "/api/view-booked-product-variants-for-checkout-item",
26
+ headers: DEFAULT_REQUEST_HEADERS,
27
+ body: { checkoutItemId },
28
+ })
29
+ .willRespondWith({
30
+ status: 200,
31
+ headers: DEFAULT_RESPONSE_HEADERS,
32
+ body: EXPECTED_BODY,
33
+ });
34
+ return provider.executeTest(async (mockserver) => {
35
+ const httpPost = fetchHttpPost({
36
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
37
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
38
+ device: "web",
39
+ version: "1.0.0",
40
+ });
41
+ const response = await httpBookedProductsVariantsForCheckoutItemView({ httpPost })({
42
+ checkoutItemId,
43
+ signal: undefined,
44
+ });
45
+ expect(response).toStrictEqual(bookedProductsVariantsResponse.result);
46
+ });
53
47
  });
54
- });
55
48
  });
@@ -2,18 +2,18 @@ import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
2
2
  import { CheckoutProjection } from "../../../projection/checkout/checkout";
3
3
  import { CheckoutItemFunctionArgs } from "../checkoutItem/checkoutItem.mock";
4
4
  import { CheckoutDto } from "./checkout";
5
-
6
5
  interface CheckoutDtoFunctionArgs {
7
- readonly status?: CheckoutStatus;
8
- readonly items: CheckoutItemFunctionArgs[];
6
+ readonly status?: CheckoutStatus;
7
+ readonly items: CheckoutItemFunctionArgs[];
9
8
  }
10
9
  interface CheckoutDtoFunction {
11
- (args: CheckoutDtoFunctionArgs): CheckoutDto;
10
+ (args: CheckoutDtoFunctionArgs): CheckoutDto;
12
11
  }
13
12
  declare const checkoutDto: CheckoutDtoFunction;
14
- interface CheckoutFunctionArgs extends CheckoutDtoFunctionArgs {}
13
+ interface CheckoutFunctionArgs extends CheckoutDtoFunctionArgs {
14
+ }
15
15
  interface CheckoutFunction {
16
- (args: CheckoutFunctionArgs): CheckoutProjection;
16
+ (args: CheckoutFunctionArgs): CheckoutProjection;
17
17
  }
18
18
  declare const checkout: CheckoutFunction;
19
19
  export { checkout, checkoutDto };
@@ -1,24 +1,21 @@
1
1
  import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
2
2
  import { checkoutItem } from "../checkoutItem/checkoutItem.mock";
3
3
  import { toCheckoutProjection } from "./checkout";
4
-
5
4
  const itemIds = [
6
- "a5422445-0e62-4b11-8a3f-1bb5469ee154",
7
- "cfc76463-621a-485a-b152-c5a9c4dc43d9",
8
- "a9a4fa26-fcc2-4efa-a6a8-fa29ea07b128",
9
- "8af02b73-0b0a-46a0-a3a8-d9710815c739",
10
- "8890e00b-d4ed-4220-ae13-52cd88ae8ed5",
5
+ "a5422445-0e62-4b11-8a3f-1bb5469ee154",
6
+ "cfc76463-621a-485a-b152-c5a9c4dc43d9",
7
+ "a9a4fa26-fcc2-4efa-a6a8-fa29ea07b128",
8
+ "8af02b73-0b0a-46a0-a3a8-d9710815c739",
9
+ "8890e00b-d4ed-4220-ae13-52cd88ae8ed5",
11
10
  ];
12
11
  const checkoutDto = ({ status = CheckoutStatus.STARTED, items }) => ({
13
- id: "9c450400-0cd7-44a4-b0e3-e0002a9bf8df",
14
- status,
15
- customerId: "0df61ca7-7e4d-462b-a422-a57de0d116b4",
16
- boxId: "9c406e57-100a-4aa6-83c5-016e7c2970e7",
17
- checkoutBookingId: "07c996bb-a0b4-45f9-ae21-6bb9c784d12b",
18
- expiresOn: "2022-09-20",
19
- items: items.map(({ id, status, feedbacks, replacedFor }, index) =>
20
- checkoutItem({ id: id || itemIds[index], status, feedbacks, replacedFor }),
21
- ),
12
+ id: "9c450400-0cd7-44a4-b0e3-e0002a9bf8df",
13
+ status,
14
+ customerId: "0df61ca7-7e4d-462b-a422-a57de0d116b4",
15
+ boxId: "9c406e57-100a-4aa6-83c5-016e7c2970e7",
16
+ checkoutBookingId: "07c996bb-a0b4-45f9-ae21-6bb9c784d12b",
17
+ expiresOn: "2022-09-20",
18
+ items: items.map(({ id, status, feedbacks, replacedFor }, index) => checkoutItem({ id: id || itemIds[index], status, feedbacks, replacedFor })),
22
19
  });
23
20
  const checkout = ({ status, items }) => toCheckoutProjection(checkoutDto({ status, items }));
24
21
  export { checkout, checkoutDto };
@@ -1,116 +1,109 @@
1
1
  import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
2
  import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
- import {
4
- AUTH_TOKEN,
5
- DEFAULT_PACT_OPTIONS,
6
- DEFAULT_REQUEST_HEADERS,
7
- DEFAULT_RESPONSE_HEADERS,
8
- fromMockServerUrlToApiUrl,
9
- } from "../../../../pact.config";
3
+ import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
10
4
  import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
11
5
  import { MediaPerspective } from "../../../projection/checkoutItem/checkoutItem";
12
6
  import { checkout } from "./checkout.mock";
13
7
  import { httpCheckoutByIdView } from "./httpCheckoutByIdView";
14
-
15
8
  const provider = new PactV3({
16
- ...DEFAULT_PACT_OPTIONS,
17
- consumer: "STY-BOX_CHECKOUT-FRONT",
18
- provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutById",
9
+ ...DEFAULT_PACT_OPTIONS,
10
+ consumer: "STY-BOX_CHECKOUT-FRONT",
11
+ provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutById",
19
12
  });
20
13
  const checkoutId = "e2490de5-5bd3-43d5-b7c4-526e33f71304";
21
14
  const replacedFor = {
22
- id: "2bf7fb8f-a283-4f53-bc27-0e7fc9466a33",
23
- media: [
24
- {
25
- id: "d7ec731b-4123-4394-829b-297b952e73e5",
26
- url: "https://cdn-catalog-back-prod.envs.lookiero.tech/1a/28/1a28f712-a76c-4172-8a11-f15002981dc0.jpg",
27
- perspective: MediaPerspective.MAIN,
15
+ id: "2bf7fb8f-a283-4f53-bc27-0e7fc9466a33",
16
+ media: [
17
+ {
18
+ id: "d7ec731b-4123-4394-829b-297b952e73e5",
19
+ url: "https://cdn-catalog-back-prod.envs.lookiero.tech/1a/28/1a28f712-a76c-4172-8a11-f15002981dc0.jpg",
20
+ perspective: MediaPerspective.MAIN,
21
+ },
22
+ {
23
+ id: "8055e209-2fe9-44c5-b715-b09ad3ef741c",
24
+ url: "https://cdn-catalog-back-prod.envs.lookiero.tech/15/ac/15aca112-4e71-4646-8db5-7f9723bc0130.jpg",
25
+ perspective: MediaPerspective.DETAIL,
26
+ },
27
+ ],
28
+ brand: "CKS",
29
+ name: "Sari Tshirt lines",
30
+ size: {
31
+ id: "b3a76aea-ce7a-4ecb-82a4-6637d0ac2afd",
32
+ lookiero: "S",
33
+ uk: "S",
34
+ it: "S",
35
+ europe: "S",
36
+ unique: false,
28
37
  },
29
- {
30
- id: "8055e209-2fe9-44c5-b715-b09ad3ef741c",
31
- url: "https://cdn-catalog-back-prod.envs.lookiero.tech/15/ac/15aca112-4e71-4646-8db5-7f9723bc0130.jpg",
32
- perspective: MediaPerspective.DETAIL,
38
+ color: {
39
+ id: "c228d1b0-d06d-4d5c-a7d5-953fd43af0d8",
40
+ label: "black_C2",
41
+ name: "black",
33
42
  },
34
- ],
35
- brand: "CKS",
36
- name: "Sari Tshirt lines",
37
- size: {
38
- id: "b3a76aea-ce7a-4ecb-82a4-6637d0ac2afd",
39
- lookiero: "S",
40
- uk: "S",
41
- it: "S",
42
- europe: "S",
43
- unique: false,
44
- },
45
- color: {
46
- id: "c228d1b0-d06d-4d5c-a7d5-953fd43af0d8",
47
- label: "black_C2",
48
- name: "black",
49
- },
50
43
  };
51
44
  const checkoutResponseWithReplacedFor = {
52
- result: checkout({ items: [{ status: CheckoutItemStatus.KEPT, replacedFor }] }),
45
+ result: checkout({ items: [{ status: CheckoutItemStatus.KEPT, replacedFor }] }),
53
46
  };
54
47
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
48
  // @ts-ignore
56
49
  const EXPECTED_BODY_WITH_REPLACED_FOR = MatchersV3.like(checkoutResponseWithReplacedFor);
57
50
  const checkoutResponseWithoutReplacedFor = {
58
- result: checkout({ items: [{ status: CheckoutItemStatus.KEPT }] }),
51
+ result: checkout({ items: [{ status: CheckoutItemStatus.KEPT }] }),
59
52
  };
60
53
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
61
54
  // @ts-ignore
62
55
  const EXPECTED_BODY_WITHOUT_REPLACED_FOR = MatchersV3.like(checkoutResponseWithoutReplacedFor);
63
56
  describe("STY-BOX_CHECKOUT-BACK_ViewCheckoutById API", () => {
64
- it("returns a valid checkout with replacedFor for the given id", () => {
65
- provider
66
- .given("a valid checkout with replacedFor for the given id")
67
- .uponReceiving("checkout projection")
68
- .withRequest({
69
- method: "POST",
70
- path: "/api/view-checkout-by-id",
71
- headers: DEFAULT_REQUEST_HEADERS,
72
- body: { checkoutId },
73
- })
74
- .willRespondWith({
75
- status: 200,
76
- headers: DEFAULT_RESPONSE_HEADERS,
77
- body: EXPECTED_BODY_WITH_REPLACED_FOR,
78
- });
79
- return provider.executeTest(async (mockserver) => {
80
- const httpPost = fetchHttpPost({
81
- apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
82
- getAuthToken: () => Promise.resolve(AUTH_TOKEN),
83
- device: "web",
84
- version: "1.0.0",
85
- });
86
- const response = await httpCheckoutByIdView({ httpPost })({ checkoutId, signal: undefined });
87
- expect(response).toStrictEqual(checkoutResponseWithReplacedFor.result);
57
+ it("returns a valid checkout with replacedFor for the given id", () => {
58
+ provider
59
+ .given("a valid checkout with replacedFor for the given id")
60
+ .uponReceiving("checkout projection")
61
+ .withRequest({
62
+ method: "POST",
63
+ path: "/api/view-checkout-by-id",
64
+ headers: DEFAULT_REQUEST_HEADERS,
65
+ body: { checkoutId },
66
+ })
67
+ .willRespondWith({
68
+ status: 200,
69
+ headers: DEFAULT_RESPONSE_HEADERS,
70
+ body: EXPECTED_BODY_WITH_REPLACED_FOR,
71
+ });
72
+ return provider.executeTest(async (mockserver) => {
73
+ const httpPost = fetchHttpPost({
74
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
75
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
76
+ device: "web",
77
+ version: "1.0.0",
78
+ });
79
+ const response = await httpCheckoutByIdView({ httpPost })({ checkoutId, signal: undefined });
80
+ expect(response).toStrictEqual(checkoutResponseWithReplacedFor.result);
81
+ });
88
82
  });
89
- });
90
- it("returns a valid checkout without replacedFor for the given id", () => {
91
- provider
92
- .given("a valid checkout without replacedFor for the given id")
93
- .uponReceiving("checkout projection")
94
- .withRequest({
95
- method: "POST",
96
- path: "/api/view-checkout-by-id",
97
- headers: DEFAULT_REQUEST_HEADERS,
98
- body: { checkoutId },
99
- })
100
- .willRespondWith({
101
- status: 200,
102
- headers: DEFAULT_RESPONSE_HEADERS,
103
- body: EXPECTED_BODY_WITHOUT_REPLACED_FOR,
104
- });
105
- return provider.executeTest(async (mockserver) => {
106
- const httpPost = fetchHttpPost({
107
- apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
108
- getAuthToken: () => Promise.resolve(AUTH_TOKEN),
109
- device: "web",
110
- version: "1.0.0",
111
- });
112
- const response = await httpCheckoutByIdView({ httpPost })({ checkoutId, signal: undefined });
113
- expect(response).toStrictEqual(checkoutResponseWithoutReplacedFor.result);
83
+ it("returns a valid checkout without replacedFor for the given id", () => {
84
+ provider
85
+ .given("a valid checkout without replacedFor for the given id")
86
+ .uponReceiving("checkout projection")
87
+ .withRequest({
88
+ method: "POST",
89
+ path: "/api/view-checkout-by-id",
90
+ headers: DEFAULT_REQUEST_HEADERS,
91
+ body: { checkoutId },
92
+ })
93
+ .willRespondWith({
94
+ status: 200,
95
+ headers: DEFAULT_RESPONSE_HEADERS,
96
+ body: EXPECTED_BODY_WITHOUT_REPLACED_FOR,
97
+ });
98
+ return provider.executeTest(async (mockserver) => {
99
+ const httpPost = fetchHttpPost({
100
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
101
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
102
+ device: "web",
103
+ version: "1.0.0",
104
+ });
105
+ const response = await httpCheckoutByIdView({ httpPost })({ checkoutId, signal: undefined });
106
+ expect(response).toStrictEqual(checkoutResponseWithoutReplacedFor.result);
107
+ });
114
108
  });
115
- });
116
109
  });
@@ -1,56 +1,49 @@
1
1
  import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
2
  import { fetchHttpPost } from "@lookiero/sty-psp-http";
3
- import {
4
- AUTH_TOKEN,
5
- DEFAULT_PACT_OPTIONS,
6
- DEFAULT_REQUEST_HEADERS,
7
- DEFAULT_RESPONSE_HEADERS,
8
- fromMockServerUrlToApiUrl,
9
- } from "../../../../pact.config";
3
+ import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
10
4
  import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
11
5
  import { checkout } from "./checkout.mock";
12
6
  import { httpFirstAvailableCheckoutByCustomerIdView } from "./httpFirstAvailableCheckoutByCustomerIdView";
13
-
14
7
  const provider = new PactV3({
15
- ...DEFAULT_PACT_OPTIONS,
16
- consumer: "STY-BOX_CHECKOUT-FRONT",
17
- provider: "STY-BOX_CHECKOUT-BACK_ViewFirstAvailableCheckoutByCustomerId",
8
+ ...DEFAULT_PACT_OPTIONS,
9
+ consumer: "STY-BOX_CHECKOUT-FRONT",
10
+ provider: "STY-BOX_CHECKOUT-BACK_ViewFirstAvailableCheckoutByCustomerId",
18
11
  });
19
12
  const customerId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
20
13
  const checkoutResponse = {
21
- result: checkout({ items: [{ status: CheckoutItemStatus.KEPT }] }),
14
+ result: checkout({ items: [{ status: CheckoutItemStatus.KEPT }] }),
22
15
  };
23
16
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
17
  // @ts-ignore
25
18
  const EXPECTED_BODY = MatchersV3.like(checkoutResponse);
26
19
  describe("STY-BOX_CHECKOUT-BACK_ViewFirstAvailableCheckoutByCustomerId API", () => {
27
- it("returns a first available checkout for the given customer id", () => {
28
- provider
29
- .given("a first available checkout for the given customer id")
30
- .uponReceiving("checkout projection")
31
- .withRequest({
32
- method: "POST",
33
- path: "/api/view-first-available-checkout-by-customer-id",
34
- headers: DEFAULT_REQUEST_HEADERS,
35
- body: { customerId },
36
- })
37
- .willRespondWith({
38
- status: 200,
39
- headers: DEFAULT_RESPONSE_HEADERS,
40
- body: EXPECTED_BODY,
41
- });
42
- return provider.executeTest(async (mockserver) => {
43
- const httpPost = fetchHttpPost({
44
- apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
45
- getAuthToken: () => Promise.resolve(AUTH_TOKEN),
46
- device: "web",
47
- version: "1.0.0",
48
- });
49
- const response = await httpFirstAvailableCheckoutByCustomerIdView({ httpPost })({
50
- customerId,
51
- signal: undefined,
52
- });
53
- expect(response).toStrictEqual(checkoutResponse.result);
20
+ it("returns a first available checkout for the given customer id", () => {
21
+ provider
22
+ .given("a first available checkout for the given customer id")
23
+ .uponReceiving("checkout projection")
24
+ .withRequest({
25
+ method: "POST",
26
+ path: "/api/view-first-available-checkout-by-customer-id",
27
+ headers: DEFAULT_REQUEST_HEADERS,
28
+ body: { customerId },
29
+ })
30
+ .willRespondWith({
31
+ status: 200,
32
+ headers: DEFAULT_RESPONSE_HEADERS,
33
+ body: EXPECTED_BODY,
34
+ });
35
+ return provider.executeTest(async (mockserver) => {
36
+ const httpPost = fetchHttpPost({
37
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
38
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
39
+ device: "web",
40
+ version: "1.0.0",
41
+ });
42
+ const response = await httpFirstAvailableCheckoutByCustomerIdView({ httpPost })({
43
+ customerId,
44
+ signal: undefined,
45
+ });
46
+ expect(response).toStrictEqual(checkoutResponse.result);
47
+ });
54
48
  });
55
- });
56
49
  });
@@ -1,18 +1,11 @@
1
1
  import { MatchersV3, PactV3 } from "@pact-foundation/pact";
2
2
  import { fetchHttpGet } from "@lookiero/sty-psp-http";
3
- import {
4
- AUTH_TOKEN,
5
- DEFAULT_PACT_OPTIONS,
6
- DEFAULT_REQUEST_HEADERS,
7
- DEFAULT_RESPONSE_HEADERS,
8
- fromMockServerUrlToApiUrl,
9
- } from "../../../../pact.config";
3
+ import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
10
4
  import { httpFiveItemsDiscountByCustomerIdView } from "./httpFiveItemsDiscountByCustomerIdView";
11
-
12
5
  const provider = new PactV3({
13
- ...DEFAULT_PACT_OPTIONS,
14
- consumer: "STY-BOX_CHECKOUT-FRONT",
15
- provider: "STY-BOX_CHECKOUT-BACK_ViewFiveItemsDiscountByCustomerId",
6
+ ...DEFAULT_PACT_OPTIONS,
7
+ consumer: "STY-BOX_CHECKOUT-FRONT",
8
+ provider: "STY-BOX_CHECKOUT-BACK_ViewFiveItemsDiscountByCustomerId",
16
9
  });
17
10
  const customerId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
18
11
  const fiveItemsDiscountResponse = 25;
@@ -20,32 +13,32 @@ const fiveItemsDiscountResponse = 25;
20
13
  // @ts-ignore
21
14
  const EXPECTED_BODY = MatchersV3.number(fiveItemsDiscountResponse);
22
15
  describe("STY-BOX_CHECKOUT-BACK_ViewFiveItemsDiscountByCustomerId API", () => {
23
- it("returns a five items discount for the given customer id", () => {
24
- provider
25
- .given("a five items discount for the given customer id")
26
- .uponReceiving("five items discount")
27
- .withRequest({
28
- method: "GET",
29
- path: `/api/view-five-items-discount-by-customer-id/${customerId}`,
30
- headers: DEFAULT_REQUEST_HEADERS,
31
- })
32
- .willRespondWith({
33
- status: 200,
34
- headers: DEFAULT_RESPONSE_HEADERS,
35
- body: EXPECTED_BODY,
36
- });
37
- return provider.executeTest(async (mockserver) => {
38
- const httpGet = fetchHttpGet({
39
- apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
40
- getAuthToken: () => Promise.resolve(AUTH_TOKEN),
41
- device: "web",
42
- version: "1.0.0",
43
- });
44
- const response = await httpFiveItemsDiscountByCustomerIdView({ httpGet })({
45
- customerId,
46
- signal: undefined,
47
- });
48
- expect(response).toStrictEqual(fiveItemsDiscountResponse);
16
+ it("returns a five items discount for the given customer id", () => {
17
+ provider
18
+ .given("a five items discount for the given customer id")
19
+ .uponReceiving("five items discount")
20
+ .withRequest({
21
+ method: "GET",
22
+ path: `/api/view-five-items-discount-by-customer-id/${customerId}`,
23
+ headers: DEFAULT_REQUEST_HEADERS,
24
+ })
25
+ .willRespondWith({
26
+ status: 200,
27
+ headers: DEFAULT_RESPONSE_HEADERS,
28
+ body: EXPECTED_BODY,
29
+ });
30
+ return provider.executeTest(async (mockserver) => {
31
+ const httpGet = fetchHttpGet({
32
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
33
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
34
+ device: "web",
35
+ version: "1.0.0",
36
+ });
37
+ const response = await httpFiveItemsDiscountByCustomerIdView({ httpGet })({
38
+ customerId,
39
+ signal: undefined,
40
+ });
41
+ expect(response).toStrictEqual(fiveItemsDiscountResponse);
42
+ });
49
43
  });
50
- });
51
44
  });