@lookiero/checkout 8.17.0 → 8.17.1-beta.1
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 +13 -0
- package/dist/pact.config.js +9 -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/infrastructure/projection/bookedProductsVariants/bookedProductsVariants.mock.d.ts +3 -0
- package/dist/src/infrastructure/projection/bookedProductsVariants/bookedProductsVariants.mock.js +27 -0
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.js +48 -0
- package/dist/src/infrastructure/projection/checkout/checkout.mock.d.ts +19 -0
- package/dist/src/infrastructure/projection/checkout/checkout.mock.js +21 -0
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.js +109 -0
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.js +49 -0
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js +44 -0
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js +44 -0
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js +44 -0
- package/dist/src/infrastructure/projection/checkoutBooking/checkoutBooking.mock.d.ts +3 -0
- package/dist/src/infrastructure/projection/checkoutBooking/checkoutBooking.mock.js +6 -0
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js +49 -0
- package/dist/src/infrastructure/projection/checkoutItem/checkoutItem.mock.d.ts +15 -0
- package/dist/src/infrastructure/projection/checkoutItem/checkoutItem.mock.js +43 -0
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.js +50 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.d.ts +3 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/checkoutQuestions.mock.js +103 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.js +48 -0
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js +109 -0
- package/dist/src/infrastructure/projection/payment/paymentFlowPayload.mock.d.ts +6 -0
- package/dist/src/infrastructure/projection/payment/paymentFlowPayload.mock.js +183 -0
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.js +48 -0
- package/dist/src/infrastructure/projection/pricing/pricing.mock.d.ts +9 -0
- package/dist/src/infrastructure/projection/pricing/pricing.mock.js +42 -0
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.d.ts +1 -0
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.js +48 -0
- package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.d.ts +3 -0
- package/dist/src/infrastructure/projection/returnQuestion/returnQuestions.mock.js +400 -0
- package/dist/src/infrastructure/ui/views/App.style.d.ts +6 -0
- package/dist/src/infrastructure/ui/views/App.style.js +7 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.d.ts +9 -0
- package/dist/src/projection/returnQuestion/returnQuestion.constants.js +10 -0
- package/dist/src/projection/returnQuestion/returnQuestion.metadata.d.ts +12 -0
- package/dist/src/projection/returnQuestion/returnQuestion.metadata.js +1 -0
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.d.ts +5 -0
- package/dist/src/projection/returnQuestion/returnQuestion.typeguard.js +10 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
|
+
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
+
import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
|
|
4
|
+
import { CheckoutItemStatus } from "../../../domain/checkoutItem/model/checkoutItem";
|
|
5
|
+
import { checkoutItem } from "./checkoutItem.mock";
|
|
6
|
+
import { httpCheckoutItemByIdView } from "./httpCheckoutItemByIdView";
|
|
7
|
+
const provider = new PactV3({
|
|
8
|
+
...DEFAULT_PACT_OPTIONS,
|
|
9
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
10
|
+
provider: "STY-BOX_CHECKOUT-BACK_ViewCheckoutItemById",
|
|
11
|
+
});
|
|
12
|
+
const checkoutItemProjection = checkoutItem({ status: CheckoutItemStatus.INITIAL });
|
|
13
|
+
const checkoutItemId = checkoutItemProjection.id;
|
|
14
|
+
const checkoutItemResponse = {
|
|
15
|
+
result: checkoutItemProjection,
|
|
16
|
+
};
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const EXPECTED_BODY = MatchersV3.like(checkoutItemResponse);
|
|
20
|
+
describe("STY-BOX_CHECKOUT-BACK_ViewCheckoutItemById API", () => {
|
|
21
|
+
it("returns a valid checkout item for the given id", () => {
|
|
22
|
+
provider
|
|
23
|
+
.given("a valid checkout item for the given id")
|
|
24
|
+
.uponReceiving("checkout item projection")
|
|
25
|
+
.withRequest({
|
|
26
|
+
method: "POST",
|
|
27
|
+
path: "/api/view-checkout-item-by-id",
|
|
28
|
+
headers: DEFAULT_REQUEST_HEADERS,
|
|
29
|
+
body: { checkoutItemId },
|
|
30
|
+
})
|
|
31
|
+
.willRespondWith({
|
|
32
|
+
status: 200,
|
|
33
|
+
headers: DEFAULT_RESPONSE_HEADERS,
|
|
34
|
+
body: EXPECTED_BODY,
|
|
35
|
+
});
|
|
36
|
+
return provider.executeTest(async (mockserver) => {
|
|
37
|
+
const httpPost = fetchHttpPost({
|
|
38
|
+
apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
|
|
39
|
+
getAuthToken: () => Promise.resolve(AUTH_TOKEN),
|
|
40
|
+
device: "web",
|
|
41
|
+
version: "1.0.0",
|
|
42
|
+
});
|
|
43
|
+
const response = await httpCheckoutItemByIdView({ httpPost })({
|
|
44
|
+
checkoutItemId,
|
|
45
|
+
signal: undefined,
|
|
46
|
+
});
|
|
47
|
+
expect(response).toStrictEqual(checkoutItemResponse.result);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CheckoutQuestionType, } from "../../../projection/checkoutQuestion/checkoutQuestion";
|
|
2
|
+
const checkoutQuestions = [
|
|
3
|
+
{
|
|
4
|
+
id: "efe07b97-f6fb-4b6a-ba92-b68519320b2c",
|
|
5
|
+
name: "checkout_question.selection.question",
|
|
6
|
+
placeholder: "checkout_question.selection.placeholder",
|
|
7
|
+
type: CheckoutQuestionType.HOST_SELECT,
|
|
8
|
+
showCondition: [],
|
|
9
|
+
children: [
|
|
10
|
+
{
|
|
11
|
+
id: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
12
|
+
name: "checkout_question.icon.bad",
|
|
13
|
+
placeholder: "",
|
|
14
|
+
type: CheckoutQuestionType.ICON,
|
|
15
|
+
showCondition: [],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "85e84a77-461c-41e6-8544-95b5294d0b80",
|
|
19
|
+
name: "checkout_question.icon.regular",
|
|
20
|
+
placeholder: "",
|
|
21
|
+
type: CheckoutQuestionType.ICON,
|
|
22
|
+
showCondition: [],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "29441d25-8d9f-471e-a13e-a03f61c88091",
|
|
26
|
+
name: "checkout_question.icon.good",
|
|
27
|
+
placeholder: "",
|
|
28
|
+
type: CheckoutQuestionType.ICON,
|
|
29
|
+
showCondition: [],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "6a6d3878-5561-412c-96f3-7ed79ee587bb",
|
|
35
|
+
name: "checkout_question.experience.question",
|
|
36
|
+
placeholder: "checkout_question.experience.placeholder",
|
|
37
|
+
type: CheckoutQuestionType.HOST_SELECT,
|
|
38
|
+
showCondition: [],
|
|
39
|
+
children: [
|
|
40
|
+
{
|
|
41
|
+
id: "a3d937b6-7499-4a3c-86bf-5c0af9ab2e23",
|
|
42
|
+
name: "checkout_question.icon.bad",
|
|
43
|
+
placeholder: "",
|
|
44
|
+
type: CheckoutQuestionType.ICON,
|
|
45
|
+
showCondition: [],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "7970edd3-fb5c-42d3-afe3-ce31bcbb856c",
|
|
49
|
+
name: "checkout_question.icon.regular",
|
|
50
|
+
placeholder: "",
|
|
51
|
+
type: CheckoutQuestionType.ICON,
|
|
52
|
+
showCondition: [],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "bab3d4f9-0227-4550-a53f-3c125d68429c",
|
|
56
|
+
name: "checkout_question.icon.good",
|
|
57
|
+
placeholder: "",
|
|
58
|
+
type: CheckoutQuestionType.ICON,
|
|
59
|
+
showCondition: [],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "a1acdb2d-62c8-467f-b7cc-dc24d967290c",
|
|
65
|
+
name: "checkout_question.personalshopper.question",
|
|
66
|
+
placeholder: "checkout_question.personalshopper.placeholder",
|
|
67
|
+
type: CheckoutQuestionType.HOST_SELECT,
|
|
68
|
+
showCondition: ["68c0bb98-b00a-4b86-af43-528fe903cb69"],
|
|
69
|
+
children: [
|
|
70
|
+
{
|
|
71
|
+
id: "cce7851c-92c7-461b-8dcb-903c5de59ed1",
|
|
72
|
+
name: "checkout_question.personalshopper.yes",
|
|
73
|
+
placeholder: "",
|
|
74
|
+
type: CheckoutQuestionType.BUTTON,
|
|
75
|
+
showCondition: [],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "4bf8f27d-669b-4d36-8d39-b5599c671816",
|
|
79
|
+
name: "checkout_question.personalshopper.no",
|
|
80
|
+
placeholder: "",
|
|
81
|
+
type: CheckoutQuestionType.BUTTON,
|
|
82
|
+
showCondition: [],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "ce3e8d57-5eea-4dd3-bef4-2e811a143612",
|
|
88
|
+
name: "checkout_question.comment.question",
|
|
89
|
+
placeholder: "",
|
|
90
|
+
type: CheckoutQuestionType.HOST_TEXTAREA,
|
|
91
|
+
showCondition: [],
|
|
92
|
+
children: [
|
|
93
|
+
{
|
|
94
|
+
id: "1123a37d-bc00-43a4-9d28-cee1dfaf356c",
|
|
95
|
+
name: "checkout_question.comment.question",
|
|
96
|
+
placeholder: "checkout_question.comment.placeholder",
|
|
97
|
+
type: CheckoutQuestionType.TEXTAREA,
|
|
98
|
+
showCondition: [],
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
export { checkoutQuestions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
|
+
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
+
import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
|
|
4
|
+
import { checkoutQuestions } from "./checkoutQuestions.mock";
|
|
5
|
+
import { httpCheckoutQuestionsByCheckoutIdView } from "./httpCheckoutQuestionsByCheckoutIdView";
|
|
6
|
+
const provider = new PactV3({
|
|
7
|
+
...DEFAULT_PACT_OPTIONS,
|
|
8
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
9
|
+
provider: "STY-BOX_CHECKOUT-BACK_ListCheckoutQuestionsByCheckoutId",
|
|
10
|
+
});
|
|
11
|
+
const checkoutId = "52440ae5-7a4c-498b-8b35-08ecfde15776";
|
|
12
|
+
const checkoutQuestionsResponse = {
|
|
13
|
+
result: checkoutQuestions,
|
|
14
|
+
};
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const EXPECTED_BODY = MatchersV3.like(checkoutQuestionsResponse);
|
|
18
|
+
describe("STY-BOX_CHECKOUT-BACK_ListCheckoutQuestionsByCheckoutId API", () => {
|
|
19
|
+
it("returns a valid checkout questions for the given checkout id", () => {
|
|
20
|
+
provider
|
|
21
|
+
.given("a valid checkout questions for the given checkout id")
|
|
22
|
+
.uponReceiving("checkout questions projection")
|
|
23
|
+
.withRequest({
|
|
24
|
+
method: "POST",
|
|
25
|
+
path: "/api/list-checkout-questions-by-checkout-id",
|
|
26
|
+
headers: DEFAULT_REQUEST_HEADERS,
|
|
27
|
+
body: { checkoutId },
|
|
28
|
+
})
|
|
29
|
+
.willRespondWith({
|
|
30
|
+
status: 200,
|
|
31
|
+
headers: DEFAULT_RESPONSE_HEADERS,
|
|
32
|
+
body: EXPECTED_BODY,
|
|
33
|
+
});
|
|
34
|
+
return provider.executeTest(async (mockserver) => {
|
|
35
|
+
const httpPost = fetchHttpPost({
|
|
36
|
+
apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
|
|
37
|
+
getAuthToken: () => Promise.resolve(AUTH_TOKEN),
|
|
38
|
+
device: "web",
|
|
39
|
+
version: "1.0.0",
|
|
40
|
+
});
|
|
41
|
+
const response = await httpCheckoutQuestionsByCheckoutIdView({ httpPost })({
|
|
42
|
+
checkoutId,
|
|
43
|
+
signal: undefined,
|
|
44
|
+
});
|
|
45
|
+
expect(response).toStrictEqual(checkoutQuestionsResponse.result);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
|
+
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
+
import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
|
|
4
|
+
import { httpPaymentFlowPayloadByCheckoutIdView } from "./httpPaymentFlowPayloadByCheckoutIdView";
|
|
5
|
+
import { paymentFlowPayloadForKeptItems, paymentFlowPayloadForReturnedItems, paymentFlowPayloadForReplacedItems, } from "./paymentFlowPayload.mock";
|
|
6
|
+
const provider = new PactV3({
|
|
7
|
+
...DEFAULT_PACT_OPTIONS,
|
|
8
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
9
|
+
provider: "STY-BOX_CHECKOUT-BACK_ViewPaymentFlowPayloadByCheckoutId",
|
|
10
|
+
});
|
|
11
|
+
const checkoutId = "e2490de5-5bd3-43d5-b7c4-526e33f71304";
|
|
12
|
+
const paymentFlowPayloadForKeptItemsResponse = {
|
|
13
|
+
result: paymentFlowPayloadForKeptItems,
|
|
14
|
+
};
|
|
15
|
+
const paymentFlowPayloadForReturnedItemsResponse = {
|
|
16
|
+
result: paymentFlowPayloadForReturnedItems,
|
|
17
|
+
};
|
|
18
|
+
const paymentFlowPayloadForReplacedItemsResponse = {
|
|
19
|
+
result: paymentFlowPayloadForReplacedItems,
|
|
20
|
+
};
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
const EXPECTED_BODY_FOR_KEPT_ITEMS = MatchersV3.like(paymentFlowPayloadForKeptItemsResponse);
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
const EXPECTED_BODY_FOR_RETURNED_ITEMS = MatchersV3.like(paymentFlowPayloadForReturnedItemsResponse);
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
const EXPECTED_BODY_FOR_REPLACED_ITEMS = MatchersV3.like(paymentFlowPayloadForReplacedItemsResponse);
|
|
30
|
+
describe("STY-BOX_CHECKOUT-BACK_ViewPaymentFlowPayloadByCheckoutId API", () => {
|
|
31
|
+
it("returns a valid payment-flow payload for the given checkout id [KEPT items] ", () => {
|
|
32
|
+
provider
|
|
33
|
+
.given("a valid payment-flow payload for the given checkout id [KEPT items] ")
|
|
34
|
+
.uponReceiving("payment-flow payload projection")
|
|
35
|
+
.withRequest({
|
|
36
|
+
method: "POST",
|
|
37
|
+
path: "/api/view-payment-flow-payload-by-checkout-id",
|
|
38
|
+
headers: DEFAULT_REQUEST_HEADERS,
|
|
39
|
+
body: { checkoutId },
|
|
40
|
+
})
|
|
41
|
+
.willRespondWith({
|
|
42
|
+
status: 200,
|
|
43
|
+
headers: DEFAULT_RESPONSE_HEADERS,
|
|
44
|
+
body: EXPECTED_BODY_FOR_KEPT_ITEMS,
|
|
45
|
+
});
|
|
46
|
+
return provider.executeTest(async (mockserver) => {
|
|
47
|
+
const httpPost = fetchHttpPost({
|
|
48
|
+
apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
|
|
49
|
+
getAuthToken: () => Promise.resolve(AUTH_TOKEN),
|
|
50
|
+
device: "web",
|
|
51
|
+
version: "1.0.0",
|
|
52
|
+
});
|
|
53
|
+
const response = await httpPaymentFlowPayloadByCheckoutIdView({ httpPost })({ checkoutId, signal: undefined });
|
|
54
|
+
expect(response).toStrictEqual(paymentFlowPayloadForKeptItemsResponse.result);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
it("returns a valid payment-flow payload for the given checkout id [RETURNED items] ", () => {
|
|
58
|
+
provider
|
|
59
|
+
.given("a valid payment-flow payload for the given checkout id [RETURNED items] ")
|
|
60
|
+
.uponReceiving("payment-flow payload projection")
|
|
61
|
+
.withRequest({
|
|
62
|
+
method: "POST",
|
|
63
|
+
path: "/api/view-payment-flow-payload-by-checkout-id",
|
|
64
|
+
headers: DEFAULT_REQUEST_HEADERS,
|
|
65
|
+
body: { checkoutId },
|
|
66
|
+
})
|
|
67
|
+
.willRespondWith({
|
|
68
|
+
status: 200,
|
|
69
|
+
headers: DEFAULT_RESPONSE_HEADERS,
|
|
70
|
+
body: EXPECTED_BODY_FOR_RETURNED_ITEMS,
|
|
71
|
+
});
|
|
72
|
+
return provider.executeTest(async (mockserver) => {
|
|
73
|
+
const httpPost = fetchHttpPost({
|
|
74
|
+
apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
|
|
75
|
+
getAuthToken: () => Promise.resolve(AUTH_TOKEN),
|
|
76
|
+
device: "web",
|
|
77
|
+
version: "1.0.0",
|
|
78
|
+
});
|
|
79
|
+
const response = await httpPaymentFlowPayloadByCheckoutIdView({ httpPost })({ checkoutId, signal: undefined });
|
|
80
|
+
expect(response).toStrictEqual(paymentFlowPayloadForReturnedItemsResponse.result);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
it("returns a valid payment-flow payload for the given checkout id [REPLACED items] ", () => {
|
|
84
|
+
provider
|
|
85
|
+
.given("a valid payment-flow payload for the given checkout id [REPLACED items] ")
|
|
86
|
+
.uponReceiving("payment-flow payload projection")
|
|
87
|
+
.withRequest({
|
|
88
|
+
method: "POST",
|
|
89
|
+
path: "/api/view-payment-flow-payload-by-checkout-id",
|
|
90
|
+
headers: DEFAULT_REQUEST_HEADERS,
|
|
91
|
+
body: { checkoutId },
|
|
92
|
+
})
|
|
93
|
+
.willRespondWith({
|
|
94
|
+
status: 200,
|
|
95
|
+
headers: DEFAULT_RESPONSE_HEADERS,
|
|
96
|
+
body: EXPECTED_BODY_FOR_REPLACED_ITEMS,
|
|
97
|
+
});
|
|
98
|
+
return provider.executeTest(async (mockserver) => {
|
|
99
|
+
const httpPost = fetchHttpPost({
|
|
100
|
+
apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
|
|
101
|
+
getAuthToken: () => Promise.resolve(AUTH_TOKEN),
|
|
102
|
+
device: "web",
|
|
103
|
+
version: "1.0.0",
|
|
104
|
+
});
|
|
105
|
+
const response = await httpPaymentFlowPayloadByCheckoutIdView({ httpPost })({ checkoutId, signal: undefined });
|
|
106
|
+
expect(response).toStrictEqual(paymentFlowPayloadForReplacedItemsResponse.result);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PaymentFlowPayloadProjection } from "../../../projection/payment/paymentFlowPayload";
|
|
2
|
+
declare const paymentFlowPayloadForKeptItems: PaymentFlowPayloadProjection;
|
|
3
|
+
declare const paymentFlowPayloadForReturnedItems: PaymentFlowPayloadProjection;
|
|
4
|
+
declare const paymentFlowPayloadForReplacedItems: PaymentFlowPayloadProjection;
|
|
5
|
+
declare const paymentFlowPayload: PaymentFlowPayloadProjection;
|
|
6
|
+
export { paymentFlowPayload, paymentFlowPayloadForKeptItems, paymentFlowPayloadForReturnedItems, paymentFlowPayloadForReplacedItems, };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const paymentFlowPayloadForKeptItems = {
|
|
2
|
+
bookingId: "",
|
|
3
|
+
orderId: "3062898",
|
|
4
|
+
comment: "",
|
|
5
|
+
items: [
|
|
6
|
+
{ reference: "9P1435C9L" },
|
|
7
|
+
{ reference: "9C2017C22M" },
|
|
8
|
+
{ reference: "9J1800C22M" },
|
|
9
|
+
{ reference: "9M608C15L" },
|
|
10
|
+
{ reference: "10S769C48S" },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
const paymentFlowPayloadForReturnedItems = {
|
|
14
|
+
bookingId: "",
|
|
15
|
+
orderId: "3071170",
|
|
16
|
+
comment: "",
|
|
17
|
+
items: [
|
|
18
|
+
{
|
|
19
|
+
reference: "9J1800C22M",
|
|
20
|
+
feedback: {
|
|
21
|
+
size: { name: "La talla es...", value: "3" },
|
|
22
|
+
price: { name: "El precio es...", value: "8" },
|
|
23
|
+
quality: { name: "La calidad es...", value: "15" },
|
|
24
|
+
style: { name: "El estilo es...", value: "5" },
|
|
25
|
+
shape: { name: "La forma es...", value: "12" },
|
|
26
|
+
comment: { name: "¿Algo más sobre esta prenda?", value: "Me queda pequeño" },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
reference: "10S769C48S",
|
|
31
|
+
feedback: {
|
|
32
|
+
size: { name: "La talla es...", value: "1" },
|
|
33
|
+
price: { name: "El precio es...", value: "10" },
|
|
34
|
+
quality: { name: "La calidad es...", value: "15" },
|
|
35
|
+
style: { name: "El estilo es...", value: "5" },
|
|
36
|
+
shape: { name: "La forma es...", value: "14" },
|
|
37
|
+
comment: { name: "¿Algo más sobre esta prenda?", value: "Me queda grande y no me gusta demasiado" },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
reference: "9C2017C22M",
|
|
42
|
+
feedback: {
|
|
43
|
+
size: { name: "La talla es...", value: "2" },
|
|
44
|
+
price: { name: "El precio es...", value: "10" },
|
|
45
|
+
quality: { name: "La calidad es...", value: "15" },
|
|
46
|
+
style: { name: "El estilo es...", value: "5" },
|
|
47
|
+
shape: { name: "La forma es...", value: "12" },
|
|
48
|
+
comment: { name: "¿Algo más sobre esta prenda?", value: "Demasiado caro para mi presupuesto" },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
reference: "9M608C15L",
|
|
53
|
+
feedback: {
|
|
54
|
+
style: { name: "El estilo es...", value: "7" },
|
|
55
|
+
shape: { name: "La forma es...", value: "14" },
|
|
56
|
+
quality: { name: "La calidad es...", value: "15" },
|
|
57
|
+
price: { name: "El precio es...", value: "9" },
|
|
58
|
+
size: { name: "La talla es...", value: "2" },
|
|
59
|
+
comment: { name: "¿Algo más sobre esta prenda?", value: "No me gusta nada" },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
reference: "9P1435C9L",
|
|
64
|
+
feedback: {
|
|
65
|
+
quality: { name: "La calidad es...", value: "17" },
|
|
66
|
+
size: { name: "La talla es...", value: "2" },
|
|
67
|
+
price: { name: "El precio es...", value: "10" },
|
|
68
|
+
style: { name: "El estilo es...", value: "5" },
|
|
69
|
+
shape: { name: "La forma es...", value: "12" },
|
|
70
|
+
comment: { name: "¿Algo más sobre esta prenda?", value: "Demasiado caro para la calidad que ofrece" },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
const paymentFlowPayloadForReplacedItems = {
|
|
76
|
+
bookingId: "ca2e03e6-1644-4406-a379-0e5c3c321f32",
|
|
77
|
+
orderId: "3071171",
|
|
78
|
+
comment: "",
|
|
79
|
+
items: [
|
|
80
|
+
{
|
|
81
|
+
reference: "9J1800C22M",
|
|
82
|
+
sizeChange: {
|
|
83
|
+
brand: "ONLY",
|
|
84
|
+
color: "blue_dark",
|
|
85
|
+
description: "Onlglamour Sweater knit T. XS C. blue_dark",
|
|
86
|
+
id: "5a95dffc-5031-4c2a-b8bc-f100c4710336",
|
|
87
|
+
reference: "9J1800C22XS",
|
|
88
|
+
size: "XS",
|
|
89
|
+
title: "Onlglamour Sweater knit ",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
reference: "10S769C48S",
|
|
94
|
+
sizeChange: {
|
|
95
|
+
brand: "FRANSA",
|
|
96
|
+
color: "brick",
|
|
97
|
+
description: "Zawov Shirt fransa T. XS C. brick",
|
|
98
|
+
id: "b74df550-a4ab-4fb0-9a34-5767c700dcd0",
|
|
99
|
+
reference: "10S769C48XS",
|
|
100
|
+
size: "XS",
|
|
101
|
+
title: "Zawov Shirt fransa ",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
reference: "9C2017C22M",
|
|
106
|
+
sizeChange: {
|
|
107
|
+
brand: "VERO MODA",
|
|
108
|
+
color: "blue_dark",
|
|
109
|
+
description: "Vmlina Tshirt vback T. XS C. blue_dark",
|
|
110
|
+
id: "349a4aeb-d8ca-4f3d-9efb-5b333da22290",
|
|
111
|
+
reference: "9C2017C22XS",
|
|
112
|
+
size: "XS",
|
|
113
|
+
title: "Vmlina Tshirt vback ",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
reference: "9M608C15L",
|
|
118
|
+
sizeChange: {
|
|
119
|
+
brand: "ESPRIT CASUAL",
|
|
120
|
+
color: "beige",
|
|
121
|
+
description: "Hope Jeans skinny T. S C. beige",
|
|
122
|
+
id: "86aed12f-81e1-4a09-9c68-15dce7a844b7",
|
|
123
|
+
reference: "9M608C15S",
|
|
124
|
+
size: "S",
|
|
125
|
+
title: "Hope Jeans skinny ",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
reference: "9P1435C9L",
|
|
130
|
+
sizeChange: {
|
|
131
|
+
brand: "ICHI",
|
|
132
|
+
color: "orange",
|
|
133
|
+
description: "Kate Pant mazarine T. S C. orange",
|
|
134
|
+
id: "34f311e2-ba8e-4261-bf70-6f25fc0e9ed9",
|
|
135
|
+
reference: "9P1435C9S",
|
|
136
|
+
size: "S",
|
|
137
|
+
title: "Kate Pant mazarine ",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
};
|
|
142
|
+
const paymentFlowPayload = {
|
|
143
|
+
bookingId: "7a3c298a-a3ee-45ac-a452-e276c1c98069",
|
|
144
|
+
orderId: "3062898",
|
|
145
|
+
comment: "",
|
|
146
|
+
items: [
|
|
147
|
+
{
|
|
148
|
+
reference: "9P1435C9L",
|
|
149
|
+
feedback: {
|
|
150
|
+
size: {
|
|
151
|
+
name: "La talla es...",
|
|
152
|
+
value: "1",
|
|
153
|
+
},
|
|
154
|
+
price: {
|
|
155
|
+
name: "El precio es...",
|
|
156
|
+
value: "10",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
reference: "9C2017C22M",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
reference: "9J1800C22M",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
reference: "9M608C15L",
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
reference: "10S769C48S",
|
|
171
|
+
sizeChange: {
|
|
172
|
+
brand: "FRANSA",
|
|
173
|
+
color: "brick",
|
|
174
|
+
description: "Zawov Shirt fransa T. M C. brick",
|
|
175
|
+
id: "dbabf321-2ca8-4ac0-a727-05e39779e3b3",
|
|
176
|
+
reference: "10S769C48M",
|
|
177
|
+
size: "M",
|
|
178
|
+
title: "Zawov Shirt fransa ",
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
export { paymentFlowPayload, paymentFlowPayloadForKeptItems, paymentFlowPayloadForReturnedItems, paymentFlowPayloadForReplacedItems, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
|
+
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
+
import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
|
|
4
|
+
import { httpPricingByCheckoutIdView } from "./httpPricingByCheckoutIdView";
|
|
5
|
+
import { pricing } from "./pricing.mock";
|
|
6
|
+
const provider = new PactV3({
|
|
7
|
+
...DEFAULT_PACT_OPTIONS,
|
|
8
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
9
|
+
provider: "STY-BOX_CHECKOUT-BACK_ViewPricingByCheckoutId",
|
|
10
|
+
});
|
|
11
|
+
const checkoutId = "6f720954-8039-4bed-9596-34fc5a02131b";
|
|
12
|
+
const pricingResponse = {
|
|
13
|
+
result: pricing(),
|
|
14
|
+
};
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const EXPECTED_BODY = MatchersV3.like(pricingResponse);
|
|
18
|
+
describe("STY-BOX_CHECKOUT-BACK_ViewPricingByCheckoutId API", () => {
|
|
19
|
+
it("returns a valid pricing for the given checkout", () => {
|
|
20
|
+
provider
|
|
21
|
+
.given("a valid pricing for the given checkout")
|
|
22
|
+
.uponReceiving("pricing projection")
|
|
23
|
+
.withRequest({
|
|
24
|
+
method: "POST",
|
|
25
|
+
path: "/api/view-pricing-by-checkout-id",
|
|
26
|
+
headers: DEFAULT_REQUEST_HEADERS,
|
|
27
|
+
body: { checkoutId },
|
|
28
|
+
})
|
|
29
|
+
.willRespondWith({
|
|
30
|
+
status: 200,
|
|
31
|
+
headers: DEFAULT_RESPONSE_HEADERS,
|
|
32
|
+
body: EXPECTED_BODY,
|
|
33
|
+
});
|
|
34
|
+
return provider.executeTest(async (mockserver) => {
|
|
35
|
+
const httpPost = fetchHttpPost({
|
|
36
|
+
apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
|
|
37
|
+
getAuthToken: () => Promise.resolve(AUTH_TOKEN),
|
|
38
|
+
device: "web",
|
|
39
|
+
version: "1.0.0",
|
|
40
|
+
});
|
|
41
|
+
const response = await httpPricingByCheckoutIdView({ httpPost })({
|
|
42
|
+
checkoutId,
|
|
43
|
+
signal: undefined,
|
|
44
|
+
});
|
|
45
|
+
expect(response).toStrictEqual(pricingResponse.result);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PricingProjection } from "../../../projection/pricing/pricing";
|
|
2
|
+
interface PricingFunctionArgs {
|
|
3
|
+
readonly paidWithPromocode: boolean;
|
|
4
|
+
}
|
|
5
|
+
interface PricingFunction {
|
|
6
|
+
(args?: PricingFunctionArgs): PricingProjection;
|
|
7
|
+
}
|
|
8
|
+
declare const pricing: PricingFunction;
|
|
9
|
+
export { pricing };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Currency } from "../../../domain/checkoutItem/model/currency";
|
|
2
|
+
const pricing = ({ paidWithPromocode } = { paidWithPromocode: false }) => ({
|
|
3
|
+
orderTotal: {
|
|
4
|
+
amount: 18301,
|
|
5
|
+
currency: Currency.EUR,
|
|
6
|
+
},
|
|
7
|
+
pendingToPay: {
|
|
8
|
+
amount: 16301,
|
|
9
|
+
currency: Currency.EUR,
|
|
10
|
+
},
|
|
11
|
+
subtotal: {
|
|
12
|
+
amount: 21801,
|
|
13
|
+
currency: Currency.EUR,
|
|
14
|
+
},
|
|
15
|
+
discount: {
|
|
16
|
+
amount: -2500,
|
|
17
|
+
currency: Currency.EUR,
|
|
18
|
+
},
|
|
19
|
+
discountPercentage: 25,
|
|
20
|
+
balanceDiscount: {
|
|
21
|
+
amount: -2000,
|
|
22
|
+
currency: Currency.EUR,
|
|
23
|
+
},
|
|
24
|
+
service: {
|
|
25
|
+
reference: "LK-service",
|
|
26
|
+
originalPrice: {
|
|
27
|
+
amount: 10.0,
|
|
28
|
+
currency: Currency.EUR,
|
|
29
|
+
},
|
|
30
|
+
discount: {
|
|
31
|
+
amount: 0,
|
|
32
|
+
currency: Currency.EUR,
|
|
33
|
+
},
|
|
34
|
+
finalPrice: {
|
|
35
|
+
amount: -1000,
|
|
36
|
+
currency: Currency.EUR,
|
|
37
|
+
},
|
|
38
|
+
prepaid: true,
|
|
39
|
+
paidWithPromocode,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
export { pricing };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MatchersV3, PactV3 } from "@pact-foundation/pact";
|
|
2
|
+
import { fetchHttpPost } from "@lookiero/sty-psp-http";
|
|
3
|
+
import { AUTH_TOKEN, DEFAULT_PACT_OPTIONS, DEFAULT_REQUEST_HEADERS, DEFAULT_RESPONSE_HEADERS, fromMockServerUrlToApiUrl, } from "../../../../pact.config";
|
|
4
|
+
import { httpReturnQuestionsByCheckoutItemIdView } from "./httpReturnQuestionsByCheckoutItemIdView";
|
|
5
|
+
import { returnQuestions } from "./returnQuestions.mock";
|
|
6
|
+
const provider = new PactV3({
|
|
7
|
+
...DEFAULT_PACT_OPTIONS,
|
|
8
|
+
consumer: "STY-BOX_CHECKOUT-FRONT",
|
|
9
|
+
provider: "STY-BOX_CHECKOUT-BACK_ListReturnQuestionsByCheckoutItemId",
|
|
10
|
+
});
|
|
11
|
+
const checkoutItemId = "52440ae5-7a4c-498b-8b35-08ecfde15776";
|
|
12
|
+
const returnQuestionsResponse = {
|
|
13
|
+
result: returnQuestions,
|
|
14
|
+
};
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const EXPECTED_BODY = MatchersV3.like(returnQuestionsResponse);
|
|
18
|
+
describe("STY-BOX_CHECKOUT-BACK_ListReturnQuestionsByCheckoutItemId API", () => {
|
|
19
|
+
it("returns a valid return questions for the given checkout item id", () => {
|
|
20
|
+
provider
|
|
21
|
+
.given("a valid return questions for the given checkout item id")
|
|
22
|
+
.uponReceiving("return questions projection")
|
|
23
|
+
.withRequest({
|
|
24
|
+
method: "POST",
|
|
25
|
+
path: "/api/list-return-questions-by-checkout-item-id",
|
|
26
|
+
headers: DEFAULT_REQUEST_HEADERS,
|
|
27
|
+
body: { checkoutItemId },
|
|
28
|
+
})
|
|
29
|
+
.willRespondWith({
|
|
30
|
+
status: 200,
|
|
31
|
+
headers: DEFAULT_RESPONSE_HEADERS,
|
|
32
|
+
body: EXPECTED_BODY,
|
|
33
|
+
});
|
|
34
|
+
return provider.executeTest(async (mockserver) => {
|
|
35
|
+
const httpPost = fetchHttpPost({
|
|
36
|
+
apiUrl: () => fromMockServerUrlToApiUrl(mockserver),
|
|
37
|
+
getAuthToken: () => Promise.resolve(AUTH_TOKEN),
|
|
38
|
+
device: "web",
|
|
39
|
+
version: "1.0.0",
|
|
40
|
+
});
|
|
41
|
+
const response = await httpReturnQuestionsByCheckoutItemIdView({ httpPost })({
|
|
42
|
+
checkoutItemId,
|
|
43
|
+
signal: undefined,
|
|
44
|
+
});
|
|
45
|
+
expect(response).toStrictEqual(returnQuestionsResponse.result);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|