@lookiero/checkout 9.3.0 → 9.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/pact.config.d.ts +21 -0
  2. package/dist/pact.config.js +16 -0
  3. package/dist/public/public/assets/adaptive-icon.png +0 -0
  4. package/dist/public/public/assets/favicon.png +0 -0
  5. package/dist/public/public/assets/icon.png +0 -0
  6. package/dist/public/public/assets/splash.png +0 -0
  7. package/dist/public/public/images/not-found.png +0 -0
  8. package/dist/src/ExpoRoot.js +2 -2
  9. package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.d.ts +1 -0
  10. package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.js +55 -0
  11. package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.d.ts +1 -0
  12. package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.js +116 -0
  13. package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.d.ts +1 -0
  14. package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.js +56 -0
  15. package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.d.ts +1 -0
  16. package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js +51 -0
  17. package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.d.ts +1 -0
  18. package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js +51 -0
  19. package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.d.ts +1 -0
  20. package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js +51 -0
  21. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +13 -0
  22. package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +19 -0
  23. package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.d.ts +1 -0
  24. package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js +56 -0
  25. package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.d.ts +1 -0
  26. package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.js +57 -0
  27. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.d.ts +1 -0
  28. package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.js +55 -0
  29. package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.d.ts +1 -0
  30. package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js +120 -0
  31. package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.d.ts +1 -0
  32. package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.js +55 -0
  33. package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.d.ts +1 -0
  34. package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.js +55 -0
  35. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +22 -0
  36. package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +1 -0
  37. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +7 -0
  38. package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +5 -0
  39. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +7 -0
  40. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +6 -0
  41. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +4 -0
  42. package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +20 -0
  43. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +4 -0
  44. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +43 -0
  45. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +12 -0
  46. package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +14 -0
  47. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.js +8 -6
  48. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +7 -0
  49. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +21 -0
  50. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +8 -0
  51. package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +12 -0
  52. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +12 -0
  53. package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +64 -0
  54. package/dist/src/infrastructure/ui/i18n/fetchTranslations.d.ts +10 -0
  55. package/dist/src/infrastructure/ui/i18n/fetchTranslations.js +17 -0
  56. package/dist/src/infrastructure/ui/i18n/translationEndpoint.d.ts +20 -0
  57. package/dist/src/infrastructure/ui/i18n/translationEndpoint.js +27 -0
  58. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +10 -0
  59. package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +27 -0
  60. package/dist/src/infrastructure/ui/views/App.style.d.ts +6 -0
  61. package/dist/src/infrastructure/ui/views/App.style.js +8 -0
  62. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +7 -0
  63. package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +11 -0
  64. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +12 -0
  65. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +64 -0
  66. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +12 -0
  67. package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +16 -0
  68. package/dist/src/infrastructure/ui/views/return/Return.style.d.ts +40 -0
  69. package/dist/src/infrastructure/ui/views/return/Return.style.js +44 -0
  70. package/dist/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.js +9 -5
  71. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +14 -0
  72. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +28 -0
  73. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +7 -0
  74. package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +11 -0
  75. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +26 -0
  76. package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +21 -0
  77. package/dist/src/projection/shared/country.d.ts +14 -0
  78. package/dist/src/projection/shared/country.js +15 -0
  79. package/dist/src/projection/shared/customer.d.ts +9 -0
  80. package/dist/src/projection/shared/customer.js +1 -0
  81. package/dist/src/projection/shared/locale.d.ts +12 -0
  82. package/dist/src/projection/shared/locale.js +13 -0
  83. package/dist/src/projection/shared/order.d.ts +6 -0
  84. package/dist/src/projection/shared/order.js +1 -0
  85. package/dist/src/projection/shared/price.d.ts +11 -0
  86. package/dist/src/projection/shared/price.js +1 -0
  87. package/dist/src/projection/shared/size.d.ts +21 -0
  88. package/dist/src/projection/shared/size.js +4 -0
  89. package/dist/src/projection/shared/subscription.d.ts +2 -0
  90. package/dist/src/projection/shared/subscription.js +1 -0
  91. package/dist/src/shared/ui/components/atoms/error/Error.d.ts +11 -0
  92. package/dist/src/shared/ui/components/atoms/error/Error.js +6 -0
  93. package/dist/src/shared/ui/components/atoms/field/Field.js +15 -12
  94. package/dist/src/version.d.ts +1 -1
  95. package/dist/src/version.js +1 -1
  96. package/package.json +1 -2
  97. package/src/ExpoRoot.tsx +2 -2
  98. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.test.tsx +1 -1
  99. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostStackReturnQuestionItem/modal/HostStackReturnQuestionItem.tsx +10 -8
  100. package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/__snapshots__/GetOutOfCheckoutModal.test.tsx.snap +26 -2
  101. package/src/infrastructure/ui/views/item/components/itemActions/__snapshots__/ItemActions.test.tsx.snap +375 -0
  102. package/src/infrastructure/ui/views/item/components/productVariantSlider/__snapshots__/ProductVariantSlider.test.tsx.snap +20 -0
  103. package/src/infrastructure/ui/views/item/components/selectModal/__snapshots__/SelecModal.test.tsx.snap +26 -2
  104. package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.test.tsx +2 -2
  105. package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/__snapshots__/SizeWithoutStockModal.test.tsx.snap +26 -2
  106. package/src/infrastructure/ui/views/item/views/productVariant/__snapshots__/ProductVariant.test.tsx.snap +60 -0
  107. package/src/infrastructure/ui/views/summary/components/collapsiblePricing/CollapsiblePricing.tsx +17 -7
  108. package/src/infrastructure/ui/views/summary/components/collapsiblePricing/__snapshots__/CollapsiblePricing.test.tsx.snap +16 -0
  109. package/src/infrastructure/ui/views/summaryTabs/components/checkoutItemsTabs/__snapshots__/CheckoutItemsTabs.test.tsx.snap +15 -8
  110. package/src/shared/ui/components/atoms/field/Field.tsx +18 -18
  111. package/src/shared/ui/components/atoms/field/__snapshots__/Field.test.tsx.snap +36 -0
  112. package/src/shared/ui/components/molecules/inputField/__snapshots__/InputField.test.tsx.snap +18 -0
@@ -0,0 +1,21 @@
1
+ import { V3MockServer } from "@pact-foundation/pact";
2
+
3
+ interface StringObject {
4
+ readonly [k: string]: string;
5
+ }
6
+ declare const DEFAULT_PACT_OPTIONS: StringObject;
7
+ declare const AUTH_TOKEN =
8
+ "eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6InBpY2tlcixwYWNrZXIiLCJzdWIiOiIxIiwiaWF0IjoxNjAyODQ4MzEyfQ.gCs2_vBcJsXt4EdreNSjDI8NWkOTQ5Cy4SwtrGnuJ44";
9
+ declare const DEFAULT_REQUEST_HEADERS: StringObject;
10
+ declare const DEFAULT_RESPONSE_HEADERS: StringObject;
11
+ interface FromMockServerUrlToApiUrlFunction {
12
+ (mockServer: V3MockServer): string;
13
+ }
14
+ declare const fromMockServerUrlToApiUrl: FromMockServerUrlToApiUrlFunction;
15
+ export {
16
+ fromMockServerUrlToApiUrl,
17
+ AUTH_TOKEN,
18
+ DEFAULT_PACT_OPTIONS,
19
+ DEFAULT_REQUEST_HEADERS,
20
+ DEFAULT_RESPONSE_HEADERS,
21
+ };
@@ -0,0 +1,16 @@
1
+ const DEFAULT_PACT_OPTIONS = { dir: ".contracts", logDir: ".pact/logs" };
2
+ const AUTH_TOKEN =
3
+ "eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6InBpY2tlcixwYWNrZXIiLCJzdWIiOiIxIiwiaWF0IjoxNjAyODQ4MzEyfQ.gCs2_vBcJsXt4EdreNSjDI8NWkOTQ5Cy4SwtrGnuJ44";
4
+ const DEFAULT_REQUEST_HEADERS = {
5
+ Authorization: `Bearer ${AUTH_TOKEN}`,
6
+ ["Content-Type"]: "application/json",
7
+ };
8
+ const DEFAULT_RESPONSE_HEADERS = { ["Content-Type"]: "application/json" };
9
+ 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
+ };
@@ -24,7 +24,7 @@ const order = {
24
24
  coupon: "MYLOOKIERO",
25
25
  };
26
26
  const customer = {
27
- customerId: "f2c07153-940c-4156-bf28-41ebb98391e4",
27
+ customerId: "9413fe3a-09fc-4264-905e-040bb7b4ca75",
28
28
  country: Country.ES,
29
29
  segment: Segment.WOMEN,
30
30
  };
@@ -39,7 +39,7 @@ const apiUrl = Platform.OS !== "web"
39
39
  : __DEV__
40
40
  ? "/local-to-dev"
41
41
  : "/checkout/api";
42
- const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU2NTc1MDEsImV4cCI6MTczOTUxOTE3MiwiZGlzcGxheU5hbWUiOiJUZXN0aW5nIiwiY291bnRyeV9jb2RlIjoiRVMiLCJhY2Nlc3NWaWEiOiJlbWFpbCIsInN1YnNjcmlwdGlvblN0YXJ0aW5nRGF0ZSI6IjIwMjQtMTItMDUiLCJpbXBlcnNvbmF0ZWQiOmZhbHNlLCJ1dWlkIjoiZjJjMDcxNTMtOTQwYy00MTU2LWJmMjgtNDFlYmI5ODM5MWU0IiwiaWF0IjoxNzM2ODQwNzcyfQ.mjJR6ZmRfCiBpISVaZwgwA7tiX-10mC0gSPh1tN9y0o";
42
+ const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU2NTIwMjgsImV4cCI6MTczOTQ0MTYwMSwiZGlzcGxheU5hbWUiOiJNaWtlbCIsImNvdW50cnlfY29kZSI6IkVTIiwiYWNjZXNzVmlhIjoiZW1haWwiLCJzdWJzY3JpcHRpb25TdGFydGluZ0RhdGUiOiIyMDI0LTExLTE4IiwiaW1wZXJzb25hdGVkIjpmYWxzZSwidXVpZCI6Ijk0MTNmZTNhLTA5ZmMtNDI2NC05MDVlLTA0MGJiN2I0Y2E3NSIsImlhdCI6MTczNjc2MzIwMn0.ZaFu4743f9XR0aK3LgMMhbmRHNloHtC1Sm0FDUtj8B8";
43
43
  const getAuthToken = () => Promise.resolve(authToken);
44
44
  const externalTranslationsUrl = Platform.OS !== "web"
45
45
  ? "https://backend-for-user.dev.envs.lookiero.tech/api/v2/translations"
@@ -0,0 +1,55 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
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";
10
+ import { bookedProductsVariants } from "./bookedProductsVariants.mock";
11
+ import { httpBookedProductsVariantsForCheckoutItemView } from "./httpBookedProductsVariantsForCheckoutItemView";
12
+
13
+ const provider = new PactV3({
14
+ ...DEFAULT_PACT_OPTIONS,
15
+ consumer: "STY-BOX_CHECKOUT-FRONT",
16
+ provider: "STY-BOX_CHECKOUT-BACK_ViewBookedProductVariantsForCheckoutItem",
17
+ });
18
+ const checkoutItemId = "52440ae5-7a4c-498b-8b35-08ecfde15776";
19
+ const bookedProductsVariantsResponse = {
20
+ result: bookedProductsVariants,
21
+ };
22
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
+ // @ts-ignore
24
+ const EXPECTED_BODY = MatchersV3.like(bookedProductsVariantsResponse);
25
+ 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);
53
+ });
54
+ });
55
+ });
@@ -0,0 +1,116 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
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";
10
+ import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
11
+ import { MediaPerspective } from "../../../projection/checkoutItem/checkoutItem";
12
+ import { checkout } from "./checkout.mock";
13
+ import { httpCheckoutByIdView } from "./httpCheckoutByIdView";
14
+
15
+ const provider = new PactV3({
16
+ ...DEFAULT_PACT_OPTIONS,
17
+ consumer: "STY-BOX_CHECKOUT-FRONT",
18
+ provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutById",
19
+ });
20
+ const checkoutId = "e2490de5-5bd3-43d5-b7c4-526e33f71304";
21
+ 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,
28
+ },
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,
33
+ },
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
+ };
51
+ const checkoutResponseWithReplacedFor = {
52
+ result: checkout({ items: [{ status: CheckoutItemStatus.KEPT, replacedFor }] }),
53
+ };
54
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
+ // @ts-ignore
56
+ const EXPECTED_BODY_WITH_REPLACED_FOR = MatchersV3.like(checkoutResponseWithReplacedFor);
57
+ const checkoutResponseWithoutReplacedFor = {
58
+ result: checkout({ items: [{ status: CheckoutItemStatus.KEPT }] }),
59
+ };
60
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
61
+ // @ts-ignore
62
+ const EXPECTED_BODY_WITHOUT_REPLACED_FOR = MatchersV3.like(checkoutResponseWithoutReplacedFor);
63
+ 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);
88
+ });
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);
114
+ });
115
+ });
116
+ });
@@ -0,0 +1,56 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
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";
10
+ import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
11
+ import { checkout } from "./checkout.mock";
12
+ import { httpFirstAvailableCheckoutByCustomerIdView } from "./httpFirstAvailableCheckoutByCustomerIdView";
13
+
14
+ const provider = new PactV3({
15
+ ...DEFAULT_PACT_OPTIONS,
16
+ consumer: "STY-BOX_CHECKOUT-FRONT",
17
+ provider: "STY-BOX_CHECKOUT-BACK_ViewFirstAvailableCheckoutByCustomerId",
18
+ });
19
+ const customerId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
20
+ const checkoutResponse = {
21
+ result: checkout({ items: [{ status: CheckoutItemStatus.KEPT }] }),
22
+ };
23
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
+ // @ts-ignore
25
+ const EXPECTED_BODY = MatchersV3.like(checkoutResponse);
26
+ 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);
54
+ });
55
+ });
56
+ });
@@ -0,0 +1,51 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
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";
10
+ import { httpFiveItemsDiscountByCustomerIdView } from "./httpFiveItemsDiscountByCustomerIdView";
11
+
12
+ const provider = new PactV3({
13
+ ...DEFAULT_PACT_OPTIONS,
14
+ consumer: "STY-BOX_CHECKOUT-FRONT",
15
+ provider: "STY-BOX_CHECKOUT-BACK_ViewFiveItemsDiscountByCustomerId",
16
+ });
17
+ const customerId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
18
+ const fiveItemsDiscountResponse = 25;
19
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20
+ // @ts-ignore
21
+ const EXPECTED_BODY = MatchersV3.number(fiveItemsDiscountResponse);
22
+ 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);
49
+ });
50
+ });
51
+ });
@@ -0,0 +1,51 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
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";
10
+ import { httpIsCheckoutEnabledByCustomerIdView } from "./httpIsCheckoutEnabledByCustomerIdView";
11
+
12
+ const provider = new PactV3({
13
+ ...DEFAULT_PACT_OPTIONS,
14
+ consumer: "STY-BOX_CHECKOUT-FRONT",
15
+ provider: "STY-BOX_CHECKOUT-BACK_ViewIsCheckoutEnabledByCustomerId",
16
+ });
17
+ const customerId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
18
+ const isCheckoutEnabledResponse = true;
19
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20
+ // @ts-ignore
21
+ const EXPECTED_BODY = MatchersV3.boolean(isCheckoutEnabledResponse);
22
+ describe("STY-BOX_CHECKOUT-BACK_ViewIsCheckoutEnabledByCustomerId API", () => {
23
+ it("returns is new checkout enabled for the given customer id", () => {
24
+ provider
25
+ .given("is new checkout enabled for the given customer id")
26
+ .uponReceiving("is new checkout enabled")
27
+ .withRequest({
28
+ method: "GET",
29
+ path: `/api/is-new-checkout-enabled/${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 httpIsCheckoutEnabledByCustomerIdView({ httpGet })({
45
+ customerId,
46
+ signal: undefined,
47
+ });
48
+ expect(response).toStrictEqual(isCheckoutEnabledResponse);
49
+ });
50
+ });
51
+ });
@@ -0,0 +1,51 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
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";
10
+ import { httpIsSizeChangeEnabledByCheckoutIdView } from "./httpIsSizeChangeEnabledByCheckoutIdView";
11
+
12
+ const provider = new PactV3({
13
+ ...DEFAULT_PACT_OPTIONS,
14
+ consumer: "STY-BOX_CHECKOUT-FRONT",
15
+ provider: "STY-BOX_CHECKOUT-BACK_ViewIsSizeChangeEnabledByCheckoutId",
16
+ });
17
+ const checkoutId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
18
+ const isSizeChangeEnabledResponse = true;
19
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20
+ // @ts-ignore
21
+ const EXPECTED_BODY = MatchersV3.like(isSizeChangeEnabledResponse);
22
+ describe("STY-BOX_CHECKOUT-BACK_ViewIsSizeChangeEnabledByCheckoutId API", () => {
23
+ it("returns is size-change enabled for the given checkout id", () => {
24
+ provider
25
+ .given("is size-change enabled for the given checkout id")
26
+ .uponReceiving("is size-change enabled")
27
+ .withRequest({
28
+ method: "GET",
29
+ path: `/api/is-size-change-enabled-by-checkout-id/${checkoutId}`,
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 httpIsSizeChangeEnabledByCheckoutIdView({ httpGet })({
45
+ checkoutId,
46
+ signal: undefined,
47
+ });
48
+ expect(response).toStrictEqual(isSizeChangeEnabledResponse);
49
+ });
50
+ });
51
+ });
@@ -0,0 +1,13 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { IsCheckoutAccessibleByCustomerIdProjection } from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
3
+
4
+ interface UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs {
5
+ readonly customerId: string | undefined;
6
+ }
7
+ interface UseViewIsCheckoutAccessibleByCustomerIdFunction {
8
+ (
9
+ args: UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs,
10
+ ): UseQueryFunctionResult<IsCheckoutAccessibleByCustomerIdProjection>;
11
+ }
12
+ declare const useViewIsCheckoutAccessibleByCustomerId: UseViewIsCheckoutAccessibleByCustomerIdFunction;
13
+ export { useViewIsCheckoutAccessibleByCustomerId };
@@ -0,0 +1,19 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { isCheckoutFeedbackGiven } from "../../../../domain/checkoutFeedback/model/checkoutFeedbackGiven";
3
+ import { viewIsCheckoutAccessibleByCustomerId } from "../../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
4
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
5
+
6
+ const useViewIsCheckoutAccessibleByCustomerId = ({ customerId }) =>
7
+ useQuery({
8
+ query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
9
+ contextId: MESSAGING_CONTEXT_ID,
10
+ invalidation: isCheckoutFeedbackGiven,
11
+ options: {
12
+ refetchOnMount: "always",
13
+ staleTime: Infinity,
14
+ retry: false,
15
+ refetchOnWindowFocus: false,
16
+ cacheTime: 0,
17
+ },
18
+ });
19
+ export { useViewIsCheckoutAccessibleByCustomerId };
@@ -0,0 +1,56 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
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";
10
+ import { checkoutBooking as checkoutBookingMock } from "./checkoutBooking.mock";
11
+ import { httpCheckoutBookingByIdView } from "./httpCheckoutBookingByIdView";
12
+
13
+ const provider = new PactV3({
14
+ ...DEFAULT_PACT_OPTIONS,
15
+ consumer: "STY-BOX_CHECKOUT-FRONT",
16
+ provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutBookingById",
17
+ });
18
+ const checkoutBookingProjection = checkoutBookingMock;
19
+ const checkoutBookingId = checkoutBookingProjection.id;
20
+ const checkoutBookingResponse = {
21
+ result: checkoutBookingProjection,
22
+ };
23
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
+ // @ts-ignore
25
+ const EXPECTED_BODY = MatchersV3.like(checkoutBookingResponse);
26
+ describe("STY-BOX_CHECKOUT-BACK_ViewCheckoutBookingById API", () => {
27
+ it("returns a valid checkout booking for the given id", () => {
28
+ provider
29
+ .given("a valid checkout booking for the given id")
30
+ .uponReceiving("checkout booking projection")
31
+ .withRequest({
32
+ method: "POST",
33
+ path: "/api/view-checkout-booking-by-id",
34
+ headers: DEFAULT_REQUEST_HEADERS,
35
+ body: { checkoutBookingId },
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 httpCheckoutBookingByIdView({ httpPost })({
50
+ checkoutBookingId,
51
+ signal: undefined,
52
+ });
53
+ expect(response).toStrictEqual(checkoutBookingResponse.result);
54
+ });
55
+ });
56
+ });
@@ -0,0 +1,57 @@
1
+ import { MatchersV3, PactV3 } from "@pact-foundation/pact";
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";
10
+ import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
11
+ import { checkoutItem } from "./checkoutItem.mock";
12
+ import { httpCheckoutItemByIdView } from "./httpCheckoutItemByIdView";
13
+
14
+ const provider = new PactV3({
15
+ ...DEFAULT_PACT_OPTIONS,
16
+ consumer: "STY-BOX_CHECKOUT-FRONT",
17
+ provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutItemById",
18
+ });
19
+ const checkoutItemProjection = checkoutItem({ status: CheckoutItemStatus.INITIAL });
20
+ const checkoutItemId = checkoutItemProjection.id;
21
+ const checkoutItemResponse = {
22
+ result: checkoutItemProjection,
23
+ };
24
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25
+ // @ts-ignore
26
+ const EXPECTED_BODY = MatchersV3.like(checkoutItemResponse);
27
+ describe("STY-BOX_CHECKOUT-BACK_ViewCheckoutItemById API", () => {
28
+ it("returns a valid checkout item for the given id", () => {
29
+ provider
30
+ .given("a valid checkout item for the given id")
31
+ .uponReceiving("checkout item projection")
32
+ .withRequest({
33
+ method: "POST",
34
+ path: "/api/view-checkout-item-by-id",
35
+ headers: DEFAULT_REQUEST_HEADERS,
36
+ body: { checkoutItemId },
37
+ })
38
+ .willRespondWith({
39
+ status: 200,
40
+ headers: DEFAULT_RESPONSE_HEADERS,
41
+ body: EXPECTED_BODY,
42
+ });
43
+ return provider.executeTest(async (mockserver) => {
44
+ const httpPost = fetchHttpPost({
45
+ apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
46
+ getAuthToken: () => Promise.resolve(AUTH_TOKEN),
47
+ device: "web",
48
+ version: "1.0.0",
49
+ });
50
+ const response = await httpCheckoutItemByIdView({ httpPost })({
51
+ checkoutItemId,
52
+ signal: undefined,
53
+ });
54
+ expect(response).toStrictEqual(checkoutItemResponse.result);
55
+ });
56
+ });
57
+ });