@lookiero/checkout 8.14.0-beta.100 → 8.14.0-beta.102
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/pact.config.d.ts +12 -4
- package/dist/pact.config.js +11 -4
- package/dist/src/infrastructure/projection/bookedProductsVariants/bookedProductsVariants.mock.d.ts +1 -0
- package/dist/src/infrastructure/projection/bookedProductsVariants/bookedProductsVariants.mock.js +24 -24
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.js +40 -33
- package/dist/src/infrastructure/projection/checkout/checkout.mock.d.ts +6 -6
- package/dist/src/infrastructure/projection/checkout/checkout.mock.js +15 -12
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.js +89 -82
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.js +40 -33
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js +38 -31
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js +38 -31
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js +38 -31
- 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/checkoutBooking.mock.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutBooking/checkoutBooking.mock.js +3 -3
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js +40 -33
- package/dist/src/infrastructure/projection/checkoutItem/checkoutItem.mock.d.ts +10 -6
- package/dist/src/infrastructure/projection/checkoutItem/checkoutItem.mock.js +39 -38
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.js +40 -33
- package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.js +97 -96
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.js +40 -33
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js +94 -83
- package/dist/src/infrastructure/projection/payment/paymentFlowPayload.mock.d.ts +7 -1
- package/dist/src/infrastructure/projection/payment/paymentFlowPayload.mock.js +178 -173
- package/dist/src/infrastructure/projection/payment/react/useViewPaymentFlowPayloadByCheckoutId.js +1 -1
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.js +40 -33
- package/dist/src/infrastructure/projection/pricing/pricing.mock.d.ts +3 -2
- package/dist/src/infrastructure/projection/pricing/pricing.mock.js +35 -34
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.js +40 -33
- package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.d.ts +1 -0
- package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.js +378 -377
- 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/i18n/fetchTranslations.d.ts +10 -0
- package/dist/src/infrastructure/ui/i18n/fetchTranslations.js +17 -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.js +7 -5
- package/dist/src/infrastructure/ui/views/App.style.d.ts +3 -3
- package/dist/src/infrastructure/ui/views/App.style.js +4 -3
- 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/return/components/returnQuestionsForm/ReturnQuestionsForm.js +3 -2
- 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/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/error/Error.d.ts +11 -0
- package/dist/src/shared/ui/components/atoms/error/Error.js +6 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/jest.setup.js +0 -20
- package/package.json +3 -3
- package/src/infrastructure/projection/payment/react/useViewPaymentFlowPayloadByCheckoutId.ts +1 -1
- package/src/infrastructure/ui/views/App.tsx +11 -8
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +3 -1
package/dist/pact.config.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { V3MockServer } from "@pact-foundation/pact";
|
|
2
|
+
|
|
2
3
|
interface StringObject {
|
|
3
|
-
|
|
4
|
+
readonly [k: string]: string;
|
|
4
5
|
}
|
|
5
6
|
declare const DEFAULT_PACT_OPTIONS: StringObject;
|
|
6
|
-
declare const AUTH_TOKEN =
|
|
7
|
+
declare const AUTH_TOKEN =
|
|
8
|
+
"eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6InBpY2tlcixwYWNrZXIiLCJzdWIiOiIxIiwiaWF0IjoxNjAyODQ4MzEyfQ.gCs2_vBcJsXt4EdreNSjDI8NWkOTQ5Cy4SwtrGnuJ44";
|
|
7
9
|
declare const DEFAULT_REQUEST_HEADERS: StringObject;
|
|
8
10
|
declare const DEFAULT_RESPONSE_HEADERS: StringObject;
|
|
9
11
|
interface FromMockServerUrlToApiUrlFunction {
|
|
10
|
-
|
|
12
|
+
(mockServer: V3MockServer): string;
|
|
11
13
|
}
|
|
12
14
|
declare const fromMockServerUrlToApiUrl: FromMockServerUrlToApiUrlFunction;
|
|
13
|
-
export {
|
|
15
|
+
export {
|
|
16
|
+
fromMockServerUrlToApiUrl,
|
|
17
|
+
AUTH_TOKEN,
|
|
18
|
+
DEFAULT_PACT_OPTIONS,
|
|
19
|
+
DEFAULT_REQUEST_HEADERS,
|
|
20
|
+
DEFAULT_RESPONSE_HEADERS,
|
|
21
|
+
};
|
package/dist/pact.config.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
const DEFAULT_PACT_OPTIONS = { dir: ".contracts", logDir: ".pact/logs" };
|
|
2
|
-
const AUTH_TOKEN =
|
|
2
|
+
const AUTH_TOKEN =
|
|
3
|
+
"eyJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6InBpY2tlcixwYWNrZXIiLCJzdWIiOiIxIiwiaWF0IjoxNjAyODQ4MzEyfQ.gCs2_vBcJsXt4EdreNSjDI8NWkOTQ5Cy4SwtrGnuJ44";
|
|
3
4
|
const DEFAULT_REQUEST_HEADERS = {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
Authorization: `Bearer ${AUTH_TOKEN}`,
|
|
6
|
+
["Content-Type"]: "application/json",
|
|
6
7
|
};
|
|
7
8
|
const DEFAULT_RESPONSE_HEADERS = { ["Content-Type"]: "application/json" };
|
|
8
9
|
const fromMockServerUrlToApiUrl = (mockServer) => mockServer.url.concat("/api");
|
|
9
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
fromMockServerUrlToApiUrl,
|
|
12
|
+
AUTH_TOKEN,
|
|
13
|
+
DEFAULT_PACT_OPTIONS,
|
|
14
|
+
DEFAULT_REQUEST_HEADERS,
|
|
15
|
+
DEFAULT_RESPONSE_HEADERS,
|
|
16
|
+
};
|
package/dist/src/infrastructure/projection/bookedProductsVariants/bookedProductsVariants.mock.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
const bookedProductsVariants = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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,48 +1,55 @@
|
|
|
1
1
|
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
2
|
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AUTH_TOKEN,
|
|
5
|
+
DEFAULT_PACT_OPTIONS,
|
|
6
|
+
DEFAULT_REQUEST_HEADERS,
|
|
7
|
+
DEFAULT_RESPONSE_HEADERS,
|
|
8
|
+
fromMockServerUrlToApiUrl,
|
|
9
|
+
} from "../../../../pact.config";
|
|
4
10
|
import { bookedProductsVariants } from "./bookedProductsVariants.mock";
|
|
5
11
|
import { httpBookedProductsVariantsForCheckoutItemView } from "./httpBookedProductsVariantsForCheckoutItemView";
|
|
12
|
+
|
|
6
13
|
const provider = new PactV3({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
...DEFAULT_PACT_OPTIONS,
|
|
15
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
16
|
+
provider: "STY-BOX_CHECKOUT-BACK_ViewBookedProductVariantsForCheckoutItem",
|
|
10
17
|
});
|
|
11
18
|
const checkoutItemId = "52440ae5-7a4c-498b-8b35-08ecfde15776";
|
|
12
19
|
const bookedProductsVariantsResponse = {
|
|
13
|
-
|
|
20
|
+
result: bookedProductsVariants,
|
|
14
21
|
};
|
|
15
22
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
23
|
// @ts-ignore
|
|
17
24
|
const EXPECTED_BODY = MatchersV3.like(bookedProductsVariantsResponse);
|
|
18
25
|
describe("STY-BOX_CHECKOUT-BACK_ViewBookedProductVariantsForCheckoutItem API", () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
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);
|
|
47
53
|
});
|
|
54
|
+
});
|
|
48
55
|
});
|
|
@@ -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
|
+
|
|
5
6
|
interface CheckoutDtoFunctionArgs {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
readonly status?: CheckoutStatus;
|
|
8
|
+
readonly items: CheckoutItemFunctionArgs[];
|
|
8
9
|
}
|
|
9
10
|
interface CheckoutDtoFunction {
|
|
10
|
-
|
|
11
|
+
(args: CheckoutDtoFunctionArgs): CheckoutDto;
|
|
11
12
|
}
|
|
12
13
|
declare const checkoutDto: CheckoutDtoFunction;
|
|
13
|
-
interface CheckoutFunctionArgs extends CheckoutDtoFunctionArgs {
|
|
14
|
-
}
|
|
14
|
+
interface CheckoutFunctionArgs extends CheckoutDtoFunctionArgs {}
|
|
15
15
|
interface CheckoutFunction {
|
|
16
|
-
|
|
16
|
+
(args: CheckoutFunctionArgs): CheckoutProjection;
|
|
17
17
|
}
|
|
18
18
|
declare const checkout: CheckoutFunction;
|
|
19
19
|
export { checkout, checkoutDto };
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { CheckoutStatus } from "../../../domain/checkout/model/checkout";
|
|
2
2
|
import { checkoutItem } from "../checkoutItem/checkoutItem.mock";
|
|
3
3
|
import { toCheckoutProjection } from "./checkout";
|
|
4
|
+
|
|
4
5
|
const itemIds = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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",
|
|
10
11
|
];
|
|
11
12
|
const checkoutDto = ({ status = CheckoutStatus.STARTED, items }) => ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
),
|
|
19
22
|
});
|
|
20
23
|
const checkout = ({ status, items }) => toCheckoutProjection(checkoutDto({ status, items }));
|
|
21
24
|
export { checkout, checkoutDto };
|
|
@@ -1,109 +1,116 @@
|
|
|
1
1
|
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
2
|
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AUTH_TOKEN,
|
|
5
|
+
DEFAULT_PACT_OPTIONS,
|
|
6
|
+
DEFAULT_REQUEST_HEADERS,
|
|
7
|
+
DEFAULT_RESPONSE_HEADERS,
|
|
8
|
+
fromMockServerUrlToApiUrl,
|
|
9
|
+
} from "../../../../pact.config";
|
|
4
10
|
import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
|
|
5
11
|
import { MediaPerspective } from "../../../projection/checkoutItem/checkoutItem";
|
|
6
12
|
import { checkout } from "./checkout.mock";
|
|
7
13
|
import { httpCheckoutByIdView } from "./httpCheckoutByIdView";
|
|
14
|
+
|
|
8
15
|
const provider = new PactV3({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
...DEFAULT_PACT_OPTIONS,
|
|
17
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
18
|
+
provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutById",
|
|
12
19
|
});
|
|
13
20
|
const checkoutId = "e2490de5-5bd3-43d5-b7c4-526e33f71304";
|
|
14
21
|
const replacedFor = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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,
|
|
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,
|
|
37
28
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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,
|
|
42
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
|
+
},
|
|
43
50
|
};
|
|
44
51
|
const checkoutResponseWithReplacedFor = {
|
|
45
|
-
|
|
52
|
+
result: checkout({ items: [{ status: CheckoutItemStatus.KEPT, replacedFor }] }),
|
|
46
53
|
};
|
|
47
54
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
48
55
|
// @ts-ignore
|
|
49
56
|
const EXPECTED_BODY_WITH_REPLACED_FOR = MatchersV3.like(checkoutResponseWithReplacedFor);
|
|
50
57
|
const checkoutResponseWithoutReplacedFor = {
|
|
51
|
-
|
|
58
|
+
result: checkout({ items: [{ status: CheckoutItemStatus.KEPT }] }),
|
|
52
59
|
};
|
|
53
60
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
54
61
|
// @ts-ignore
|
|
55
62
|
const EXPECTED_BODY_WITHOUT_REPLACED_FOR = MatchersV3.like(checkoutResponseWithoutReplacedFor);
|
|
56
63
|
describe("STY-BOX_CHECKOUT-BACK_ViewCheckoutById API", () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
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);
|
|
82
88
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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);
|
|
108
114
|
});
|
|
115
|
+
});
|
|
109
116
|
});
|
|
@@ -1,49 +1,56 @@
|
|
|
1
1
|
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
2
|
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AUTH_TOKEN,
|
|
5
|
+
DEFAULT_PACT_OPTIONS,
|
|
6
|
+
DEFAULT_REQUEST_HEADERS,
|
|
7
|
+
DEFAULT_RESPONSE_HEADERS,
|
|
8
|
+
fromMockServerUrlToApiUrl,
|
|
9
|
+
} from "../../../../pact.config";
|
|
4
10
|
import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
|
|
5
11
|
import { checkout } from "./checkout.mock";
|
|
6
12
|
import { httpFirstAvailableCheckoutByCustomerIdView } from "./httpFirstAvailableCheckoutByCustomerIdView";
|
|
13
|
+
|
|
7
14
|
const provider = new PactV3({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
...DEFAULT_PACT_OPTIONS,
|
|
16
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
17
|
+
provider: "STY-BOX_CHECKOUT-BACK_ViewFirstAvailableCheckoutByCustomerId",
|
|
11
18
|
});
|
|
12
19
|
const customerId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
|
|
13
20
|
const checkoutResponse = {
|
|
14
|
-
|
|
21
|
+
result: checkout({ items: [{ status: CheckoutItemStatus.KEPT }] }),
|
|
15
22
|
};
|
|
16
23
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
17
24
|
// @ts-ignore
|
|
18
25
|
const EXPECTED_BODY = MatchersV3.like(checkoutResponse);
|
|
19
26
|
describe("STY-BOX_CHECKOUT-BACK_ViewFirstAvailableCheckoutByCustomerId API", () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
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);
|
|
48
54
|
});
|
|
55
|
+
});
|
|
49
56
|
});
|
package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
2
|
import { fetchHttpGet } from "@lookiero/sty-psp-http";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AUTH_TOKEN,
|
|
5
|
+
DEFAULT_PACT_OPTIONS,
|
|
6
|
+
DEFAULT_REQUEST_HEADERS,
|
|
7
|
+
DEFAULT_RESPONSE_HEADERS,
|
|
8
|
+
fromMockServerUrlToApiUrl,
|
|
9
|
+
} from "../../../../pact.config";
|
|
4
10
|
import { httpFiveItemsDiscountByCustomerIdView } from "./httpFiveItemsDiscountByCustomerIdView";
|
|
11
|
+
|
|
5
12
|
const provider = new PactV3({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
...DEFAULT_PACT_OPTIONS,
|
|
14
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
15
|
+
provider: "STY-BOX_CHECKOUT-BACK_ViewFiveItemsDiscountByCustomerId",
|
|
9
16
|
});
|
|
10
17
|
const customerId = "fab61a4d-c94d-4e33-b098-1945294a5f75";
|
|
11
18
|
const fiveItemsDiscountResponse = 25;
|
|
@@ -13,32 +20,32 @@ const fiveItemsDiscountResponse = 25;
|
|
|
13
20
|
// @ts-ignore
|
|
14
21
|
const EXPECTED_BODY = MatchersV3.number(fiveItemsDiscountResponse);
|
|
15
22
|
describe("STY-BOX_CHECKOUT-BACK_ViewFiveItemsDiscountByCustomerId API", () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
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);
|
|
43
49
|
});
|
|
50
|
+
});
|
|
44
51
|
});
|