@lookiero/checkout 9.8.4 → 9.9.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.
- package/dist/index.js +1 -1
- package/dist/pact.config.d.ts +21 -0
- package/dist/pact.config.js +16 -0
- package/dist/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/ExpoRoot.js +6 -4
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.js +55 -0
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.js +116 -0
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.js +56 -0
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js +51 -0
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js +51 -0
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js +51 -0
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +13 -0
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +19 -0
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js +56 -0
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.js +57 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.js +55 -0
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js +120 -0
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.js +55 -0
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.js +55 -0
- package/dist/src/infrastructure/ui/Root.d.ts +0 -2
- package/dist/src/infrastructure/ui/Root.js +2 -4
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +22 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +1 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +7 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +5 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +7 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +6 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +4 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +20 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +4 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +43 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +12 -0
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +14 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +7 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +21 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +8 -0
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +12 -0
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +12 -0
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +64 -0
- package/dist/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +3 -2
- package/dist/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +17 -26
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +1 -1
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +22 -55
- package/dist/src/infrastructure/ui/i18n/fetchTranslations.d.ts +10 -0
- package/dist/src/infrastructure/ui/i18n/fetchTranslations.js +17 -0
- package/dist/src/infrastructure/ui/i18n/i18n.d.ts +1 -0
- package/dist/src/infrastructure/ui/i18n/i18n.js +1 -0
- package/dist/src/infrastructure/ui/i18n/translationEndpoint.d.ts +20 -0
- package/dist/src/infrastructure/ui/i18n/translationEndpoint.js +27 -0
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +10 -0
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +27 -0
- package/dist/src/infrastructure/ui/views/App.style.d.ts +6 -0
- package/dist/src/infrastructure/ui/views/App.style.js +8 -0
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +2 -2
- package/dist/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +7 -7
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +7 -0
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +11 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +12 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +64 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +12 -0
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +16 -0
- package/dist/src/infrastructure/ui/views/return/Return.style.d.ts +40 -0
- package/dist/src/infrastructure/ui/views/return/Return.style.js +44 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +14 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +28 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +7 -0
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +11 -0
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +26 -0
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +21 -0
- package/dist/src/projection/customer/customer.d.ts +2 -0
- package/dist/src/projection/shared/country.d.ts +14 -0
- package/dist/src/projection/shared/country.js +15 -0
- package/dist/src/projection/shared/customer.d.ts +9 -0
- package/dist/src/projection/shared/customer.js +1 -0
- package/dist/src/projection/shared/locale.d.ts +12 -0
- package/dist/src/projection/shared/locale.js +13 -0
- package/dist/src/projection/shared/order.d.ts +6 -0
- package/dist/src/projection/shared/order.js +1 -0
- package/dist/src/projection/shared/price.d.ts +11 -0
- package/dist/src/projection/shared/price.js +1 -0
- package/dist/src/projection/shared/size.d.ts +21 -0
- package/dist/src/projection/shared/size.js +4 -0
- package/dist/src/projection/shared/subscription.d.ts +2 -0
- package/dist/src/projection/shared/subscription.js +1 -0
- package/dist/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.d.ts +15 -0
- package/dist/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.js +16 -0
- package/dist/src/shared/ui/components/atoms/error/Error.d.ts +11 -0
- package/dist/src/shared/ui/components/atoms/error/Error.js +6 -0
- package/dist/src/shared/ui/components/atoms/field/Field.d.ts +14 -0
- package/dist/src/shared/ui/components/atoms/field/Field.js +29 -0
- package/dist/src/shared/ui/components/atoms/field/Field.style.d.ts +16 -0
- package/dist/src/shared/ui/components/atoms/field/Field.style.js +19 -0
- package/dist/src/shared/ui/components/molecules/inputField/InputField.d.ts +24 -0
- package/dist/src/shared/ui/components/molecules/inputField/InputField.js +28 -0
- package/dist/src/shared/ui/components/molecules/inputField/InputField.style.d.ts +29 -0
- package/dist/src/shared/ui/components/molecules/inputField/InputField.style.js +37 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/index.ts +1 -1
- package/package.json +3 -3
- package/src/ExpoRoot.tsx +6 -4
- package/src/infrastructure/ui/Root.tsx +17 -30
- package/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.ts +18 -60
- package/src/infrastructure/ui/hooks/useSubmitCheckout.test.ts +0 -58
- package/src/infrastructure/ui/hooks/useSubmitCheckout.ts +33 -77
- package/src/infrastructure/ui/i18n/i18n.ts +1 -0
- package/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.tsx +2 -2
- package/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.tsx +8 -8
- package/src/projection/customer/customer.ts +2 -0
- package/dist/src/infrastructure/ui/hooks/useQueryBus.d.ts +0 -9
- package/dist/src/infrastructure/ui/hooks/useQueryBus.js +0 -10
- package/src/infrastructure/ui/hooks/useQueryBus.test.tsx +0 -23
- package/src/infrastructure/ui/hooks/useQueryBus.tsx +0 -27
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const bootstrap = ({ apiUrl, getAuthToken, translations, sentry, kameleoon }) =>
|
|
|
14
14
|
});
|
|
15
15
|
const firstAvailableCheckoutByCustomerId = ({ customerId }) => queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId: customerId }));
|
|
16
16
|
return {
|
|
17
|
-
root: root({ Messaging, I18n,
|
|
17
|
+
root: root({ Messaging, I18n, getAuthToken, sentry, kameleoon }),
|
|
18
18
|
firstAvailableCheckoutByCustomerId,
|
|
19
19
|
};
|
|
20
20
|
};
|
|
@@ -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
|
+
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/src/ExpoRoot.js
CHANGED
|
@@ -24,9 +24,11 @@ const order = {
|
|
|
24
24
|
coupon: "MYLOOKIERO",
|
|
25
25
|
};
|
|
26
26
|
const customer = {
|
|
27
|
-
customerId: "
|
|
27
|
+
customerId: "9413fe3a-09fc-4264-905e-040bb7b4ca75",
|
|
28
28
|
country: Country.ES,
|
|
29
29
|
segment: Segment.WOMEN,
|
|
30
|
+
email: "email@example.com",
|
|
31
|
+
name: "Adèle Léonce Émilie",
|
|
30
32
|
};
|
|
31
33
|
const sentryConfig = {
|
|
32
34
|
publicKey: "66cadf9444db4ea5945670f12ec08ae7",
|
|
@@ -39,7 +41,7 @@ const apiUrl = Platform.OS !== "web"
|
|
|
39
41
|
: __DEV__
|
|
40
42
|
? "/local-to-dev"
|
|
41
43
|
: "/checkout/api";
|
|
42
|
-
const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
44
|
+
const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU2NTIwMjgsImV4cCI6MTczOTQ0MTYwMSwiZGlzcGxheU5hbWUiOiJNaWtlbCIsImNvdW50cnlfY29kZSI6IkVTIiwiYWNjZXNzVmlhIjoiZW1haWwiLCJzdWJzY3JpcHRpb25TdGFydGluZ0RhdGUiOiIyMDI0LTExLTE4IiwiaW1wZXJzb25hdGVkIjpmYWxzZSwidXVpZCI6Ijk0MTNmZTNhLTA5ZmMtNDI2NC05MDVlLTA0MGJiN2I0Y2E3NSIsImlhdCI6MTczNjc2MzIwMn0.ZaFu4743f9XR0aK3LgMMhbmRHNloHtC1Sm0FDUtj8B8";
|
|
43
45
|
const getAuthToken = () => Promise.resolve(authToken);
|
|
44
46
|
const externalTranslationsUrl = Platform.OS !== "web"
|
|
45
47
|
? "https://backend-for-user.dev.envs.lookiero.tech/api/v2/translations"
|
|
@@ -74,12 +76,13 @@ setPaymentsBridge({
|
|
|
74
76
|
useFeatureFlags: () => ({}),
|
|
75
77
|
locale: () => Promise.resolve("es-ES"),
|
|
76
78
|
scrollView: ScrollView,
|
|
79
|
+
hostUrl: "",
|
|
77
80
|
});
|
|
78
81
|
const kameleoonConfig = {
|
|
79
82
|
siteCode: "aplm4v3ckn",
|
|
80
83
|
experiments: {},
|
|
81
84
|
};
|
|
82
|
-
const { Component: Messaging
|
|
85
|
+
const { Component: Messaging } = process.env.EXPO_PUBLIC_APP_VARIANT === "test"
|
|
83
86
|
? checkoutMockBootstrap()
|
|
84
87
|
: checkoutBootstrap({ apiUrl: () => apiUrl, getAuthToken });
|
|
85
88
|
const I18n = i18n({
|
|
@@ -89,7 +92,6 @@ const I18n = i18n({
|
|
|
89
92
|
const Root = root({
|
|
90
93
|
Messaging,
|
|
91
94
|
I18n,
|
|
92
|
-
queryBus,
|
|
93
95
|
getAuthToken,
|
|
94
96
|
development: false,
|
|
95
97
|
sentry: () => (process.env.EXPO_PUBLIC_APP_VARIANT === "test" ? {} : sentryConfig),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
});
|
package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js
ADDED
|
@@ -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
|
+
});
|
package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js
ADDED
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js
ADDED
|
@@ -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 };
|
package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js
ADDED
|
@@ -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 };
|
package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js
ADDED
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
});
|