@lookiero/checkout 7.0.0-beta.0 → 7.0.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/src/ExpoRoot.js +1 -8
- package/dist/src/infrastructure/ab-testing/kameleoonEnvironment.d.ts +2 -6
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +1 -10
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.d.ts +1 -7
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.js +1 -7
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +2 -7
- package/dist/src/infrastructure/ui/routing/Routing.js +2 -4
- package/dist/src/infrastructure/ui/views/checkout/Checkout.js +4 -4
- package/dist/src/infrastructure/ui/views/feedback/Feedback.d.ts +2 -2
- package/dist/src/infrastructure/ui/views/item/Item.js +4 -33
- package/dist/src/infrastructure/ui/views/return/Return.js +8 -127
- package/dist/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.js +5 -7
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +15 -0
- package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +112 -0
- package/dist/src/infrastructure/ui/views/summary/Summary.js +4 -4
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/ExpoRoot.tsx +1 -8
- package/src/infrastructure/ab-testing/kameleoonEnvironment.ts +3 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.ts +1 -7
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.test.tsx +0 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +2 -17
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.test.tsx +0 -5
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +11 -20
- package/src/infrastructure/ui/routing/Routing.tsx +3 -6
- package/src/infrastructure/ui/views/checkout/Checkout.tsx +6 -6
- package/src/infrastructure/ui/views/feedback/Feedback.tsx +2 -2
- package/src/infrastructure/ui/views/item/Item.test.tsx +6 -62
- package/src/infrastructure/ui/views/item/Item.tsx +5 -48
- package/src/infrastructure/ui/views/return/Return.test.tsx +54 -0
- package/src/infrastructure/ui/views/return/Return.tsx +12 -200
- package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.test.tsx +32 -0
- package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.tsx +12 -7
- package/src/infrastructure/ui/views/return/components/productVariantPreview/__snapshots__/ProductVariantPreview.test.tsx.snap +221 -0
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.test.tsx +95 -0
- package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +184 -0
- package/src/infrastructure/ui/views/summary/Summary.tsx +6 -6
- 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/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +0 -10
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +0 -17
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +0 -21
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +0 -1
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +0 -6
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +0 -4
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +0 -6
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +0 -5
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +0 -4
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +0 -19
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +0 -3
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +0 -18
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +0 -12
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +0 -13
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +0 -6
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +0 -11
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +0 -8
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +0 -11
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +0 -11
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +0 -49
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +0 -9
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +0 -21
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +0 -7
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +0 -10
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +0 -11
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +0 -40
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +0 -12
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +0 -15
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +0 -13
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +0 -9
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +0 -7
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +0 -10
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +0 -17
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +0 -13
- package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.test.tsx +0 -84
- package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.tsx +0 -82
- package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.ts +0 -18
- package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.tsx +0 -79
- /package/dist/src/infrastructure/ui/views/return/{Return.style.d.ts → components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts} +0 -0
- /package/dist/src/infrastructure/ui/views/return/{Return.style.js → components/returnQuestionsForm/ReturnQuestionsForm.style.js} +0 -0
- /package/src/infrastructure/ui/views/return/{Return.style.ts → components/returnQuestionsForm/ReturnQuestionsForm.style.ts} +0 -0
package/package.json
CHANGED
package/src/ExpoRoot.tsx
CHANGED
|
@@ -117,14 +117,7 @@ setPaymentsBridge({
|
|
|
117
117
|
|
|
118
118
|
const kameleoonConfig: KameleoonEnvironment = {
|
|
119
119
|
siteCode: "aplm4v3ckn",
|
|
120
|
-
experiments: {
|
|
121
|
-
newFeedback: {
|
|
122
|
-
id: "245000",
|
|
123
|
-
variations: {
|
|
124
|
-
v1: "964072",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
},
|
|
120
|
+
experiments: {},
|
|
128
121
|
};
|
|
129
122
|
|
|
130
123
|
// const { Component: Messaging } = checkoutMockBootstrap();
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly variations: Record<string, string>;
|
|
4
|
-
}
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
2
|
+
interface Experiments {}
|
|
5
3
|
|
|
6
4
|
interface KameleoonEnvironment {
|
|
7
5
|
readonly siteCode: string;
|
|
8
|
-
readonly experiments:
|
|
9
|
-
readonly newFeedback: Experiment;
|
|
10
|
-
};
|
|
6
|
+
readonly experiments: Experiments;
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
export type { KameleoonEnvironment };
|
|
@@ -4,16 +4,10 @@ import { theme } from "@lookiero/sty-psp-ui";
|
|
|
4
4
|
const { colorBgBase, space4, space6 } = theme();
|
|
5
5
|
|
|
6
6
|
const style = StyleSheet.create({
|
|
7
|
-
allOptionsTitle: {
|
|
8
|
-
display: "none",
|
|
9
|
-
},
|
|
10
|
-
formTitle: {
|
|
11
|
-
paddingLeft: space6,
|
|
12
|
-
},
|
|
13
7
|
title: {
|
|
14
8
|
backgroundColor: colorBgBase,
|
|
15
9
|
paddingBottom: space4,
|
|
16
|
-
|
|
10
|
+
paddingHorizontal: space6,
|
|
17
11
|
paddingTop: space6,
|
|
18
12
|
},
|
|
19
13
|
});
|
|
@@ -12,11 +12,6 @@ jest.mock("../../behaviors/useReturnQuestionFeedback", () => ({
|
|
|
12
12
|
useReturnQuestionFeedbackForReturnQuestion: () => ({ feedback: "", onChange: mockOnChange }),
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
-
jest.mock("../../../../../hooks/useNewFeedbackExperiment", () => ({
|
|
16
|
-
...jest.requireActual("../../../../../hooks/useNewFeedbackExperiment"),
|
|
17
|
-
useNewFeedbackExperiment: () => "control",
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
15
|
const returnQuestion: ReturnQuestionProjection = {
|
|
21
16
|
id: "9251dc2c-d76a-484d-9299-346929af932f",
|
|
22
17
|
name: "size_large",
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Text, View } from "@lookiero/aurora";
|
|
3
3
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
-
import {
|
|
5
|
-
NewFeedbackExperimentVariation,
|
|
6
|
-
useNewFeedbackExperiment,
|
|
7
|
-
} from "../../../../../hooks/useNewFeedbackExperiment";
|
|
8
4
|
import { I18nMessages } from "../../../../../i18n/i18n";
|
|
9
5
|
import { ReturnQuestionItem, ReturnQuestionItemProps } from "../ReturnQuestionItem";
|
|
10
6
|
import { style } from "./HostDefaultReturnQuestionItem.style";
|
|
@@ -13,21 +9,10 @@ const HostDefaultReturnQuestionItem: ReturnQuestionItem = ({ returnQuestion, chi
|
|
|
13
9
|
const titleText = useI18nMessage({ id: returnQuestion.name });
|
|
14
10
|
const isAllOptions = returnQuestion.name === I18nMessages.RETURN_QUESTION_MAIN_ALL_OPINION;
|
|
15
11
|
|
|
16
|
-
/* Kameleoon experiment */
|
|
17
|
-
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
18
|
-
const isReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
19
|
-
/* Kameleoon experiment */
|
|
20
|
-
|
|
21
12
|
return (
|
|
22
13
|
<>
|
|
23
|
-
{titleText && titleText !== " " ? (
|
|
24
|
-
<View
|
|
25
|
-
style={[
|
|
26
|
-
style.title,
|
|
27
|
-
isAllOptions ? style.allOptionsTitle : undefined,
|
|
28
|
-
isReturnPage ? style.formTitle : undefined,
|
|
29
|
-
]}
|
|
30
|
-
>
|
|
14
|
+
{titleText && titleText !== " " && !isAllOptions ? (
|
|
15
|
+
<View style={style.title}>
|
|
31
16
|
<Text level={3} action>
|
|
32
17
|
{titleText}
|
|
33
18
|
</Text>
|
|
@@ -12,11 +12,6 @@ jest.mock("../../behaviors/useReturnQuestionFeedback", () => ({
|
|
|
12
12
|
useReturnQuestionFeedbackForReturnQuestion: () => ({ feedback: "", onChange: mockOnChange }),
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
-
jest.mock("../../../../../hooks/useNewFeedbackExperiment", () => ({
|
|
16
|
-
...jest.requireActual("../../../../../hooks/useNewFeedbackExperiment"),
|
|
17
|
-
useNewFeedbackExperiment: () => "control",
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
15
|
const returnQuestionParent = {
|
|
21
16
|
id: "0ad1dba8-b02c-4121-a1e3-981f1c30800d",
|
|
22
17
|
} as ReturnQuestionProjection;
|
|
@@ -2,10 +2,6 @@ import React, { useCallback, useMemo } from "react";
|
|
|
2
2
|
import { View } from "@lookiero/aurora";
|
|
3
3
|
import { useIntl } from "@lookiero/i18n-react";
|
|
4
4
|
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
5
|
-
import {
|
|
6
|
-
NewFeedbackExperimentVariation,
|
|
7
|
-
useNewFeedbackExperiment,
|
|
8
|
-
} from "../../../../../hooks/useNewFeedbackExperiment";
|
|
9
5
|
import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
|
|
10
6
|
import { ReturnQuestionItem, ReturnQuestionItemProps } from "../ReturnQuestionItem";
|
|
11
7
|
import { style } from "./TextareaReturnQuestionItem.style";
|
|
@@ -17,11 +13,6 @@ const TextareaReturnQuestionItem: ReturnQuestionItem = ({
|
|
|
17
13
|
}: ReturnQuestionItemProps) => {
|
|
18
14
|
const { formatMessage } = useIntl();
|
|
19
15
|
|
|
20
|
-
/* Kameleoon experiment */
|
|
21
|
-
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
22
|
-
const isReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
23
|
-
/* Kameleoon experiment */
|
|
24
|
-
|
|
25
16
|
const placeholderText = useMemo(
|
|
26
17
|
() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""),
|
|
27
18
|
[formatMessage, returnQuestion.placeholder],
|
|
@@ -33,18 +24,18 @@ const TextareaReturnQuestionItem: ReturnQuestionItem = ({
|
|
|
33
24
|
[onChange, returnQuestionParent.id],
|
|
34
25
|
);
|
|
35
26
|
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
return (
|
|
28
|
+
<View style={style.wrapper}>
|
|
29
|
+
<InputField
|
|
30
|
+
label={placeholderText}
|
|
31
|
+
placeholder={placeholderText}
|
|
32
|
+
testID={testID}
|
|
33
|
+
value={feedback}
|
|
34
|
+
multiline
|
|
35
|
+
onChange={handleOnChange}
|
|
36
|
+
/>
|
|
37
|
+
</View>
|
|
45
38
|
);
|
|
46
|
-
|
|
47
|
-
return isReturnPage ? <View style={style.wrapper}>{fieldComponent}</View> : fieldComponent;
|
|
48
39
|
};
|
|
49
40
|
|
|
50
41
|
export { TextareaReturnQuestionItem };
|
|
@@ -8,7 +8,6 @@ import { Customer } from "../../../projection/shared/customer";
|
|
|
8
8
|
import { Order } from "../../../projection/shared/order";
|
|
9
9
|
import { Subscription } from "../../../projection/shared/subscription";
|
|
10
10
|
import { KameleoonEnvironment } from "../../ab-testing/kameleoonEnvironment";
|
|
11
|
-
import { NewFeedbackExperimentProvider } from "../hooks/useNewFeedbackExperiment";
|
|
12
11
|
import { StaticInfoProvider } from "../hooks/useStaticInfo";
|
|
13
12
|
import { App } from "../views/App";
|
|
14
13
|
import { Checkout } from "../views/checkout/Checkout";
|
|
@@ -64,11 +63,9 @@ const Routing: FC<RoutingProps> = ({
|
|
|
64
63
|
<I18n loader={<Spinner />} locale={locale} onError={onI18nError}>
|
|
65
64
|
<Kameleoon loader={<Spinner />} siteCode={kameleoon.siteCode}>
|
|
66
65
|
<CheckoutMiddleware customerId={customer?.customerId as string} onNotAccessible={onNotAccessible}>
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
</App>
|
|
71
|
-
</NewFeedbackExperimentProvider>
|
|
66
|
+
<App>
|
|
67
|
+
<Outlet />
|
|
68
|
+
</App>
|
|
72
69
|
</CheckoutMiddleware>
|
|
73
70
|
</Kameleoon>
|
|
74
71
|
</I18n>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC, ReactNode, useCallback, useMemo, useState } from "react";
|
|
2
2
|
import { LayoutRectangle, Platform, ScrollView, View } from "react-native";
|
|
3
3
|
import { useNavigate } from "react-router-native";
|
|
4
|
-
import { Box, Button, Layout, Spinner, Text, useDevice } from "@lookiero/aurora";
|
|
4
|
+
import { Box, Button, Layout as AuroraLayout, Spinner, Text, useDevice } from "@lookiero/aurora";
|
|
5
5
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
6
6
|
import { QueryStatus } from "@lookiero/messaging-react";
|
|
7
7
|
import { Layout as UiLayout, Sticky } from "@lookiero/sty-psp-ui";
|
|
@@ -30,7 +30,7 @@ interface CheckoutProps {
|
|
|
30
30
|
readonly useRedirect: () => Record<string, string>;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const Checkout: FC<CheckoutProps> = ({ children, layout:
|
|
33
|
+
const Checkout: FC<CheckoutProps> = ({ children, layout: Layout, useRedirect }) => {
|
|
34
34
|
const {
|
|
35
35
|
customer: { customerId, country, segment },
|
|
36
36
|
} = useStaticInfo();
|
|
@@ -99,7 +99,7 @@ const Checkout: FC<CheckoutProps> = ({ children, layout: UiLayout, useRedirect }
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
return (
|
|
102
|
-
<
|
|
102
|
+
<Layout
|
|
103
103
|
header={<CheckoutHeader onBack={handleOnBack} />}
|
|
104
104
|
scrollEnabled={false}
|
|
105
105
|
style={{
|
|
@@ -110,7 +110,7 @@ const Checkout: FC<CheckoutProps> = ({ children, layout: UiLayout, useRedirect }
|
|
|
110
110
|
<ScrollView showsVerticalScrollIndicator={false}>
|
|
111
111
|
{hasReplacedCheckoutItem && <DeliveryBanner />}
|
|
112
112
|
|
|
113
|
-
<
|
|
113
|
+
<AuroraLayout
|
|
114
114
|
fullWidth={!screen.L}
|
|
115
115
|
style={[screen.L && style.desktopLayoutSpacing, !screen.L && { paddingBottom: pricingHeight }]}
|
|
116
116
|
>
|
|
@@ -158,7 +158,7 @@ const Checkout: FC<CheckoutProps> = ({ children, layout: UiLayout, useRedirect }
|
|
|
158
158
|
</View>
|
|
159
159
|
) : null}
|
|
160
160
|
</Box>
|
|
161
|
-
</
|
|
161
|
+
</AuroraLayout>
|
|
162
162
|
</ScrollView>
|
|
163
163
|
|
|
164
164
|
{pricing && !screen.L ? (
|
|
@@ -172,7 +172,7 @@ const Checkout: FC<CheckoutProps> = ({ children, layout: UiLayout, useRedirect }
|
|
|
172
172
|
) : null}
|
|
173
173
|
|
|
174
174
|
{children}
|
|
175
|
-
</
|
|
175
|
+
</Layout>
|
|
176
176
|
);
|
|
177
177
|
};
|
|
178
178
|
|
|
@@ -2,7 +2,7 @@ import React, { FC, useCallback, useEffect, useRef } from "react";
|
|
|
2
2
|
import { Spinner } from "@lookiero/aurora";
|
|
3
3
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
4
4
|
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
5
|
-
import { Layout, useScreenSize } from "@lookiero/sty-psp-ui";
|
|
5
|
+
import { Layout as UiLayout, useScreenSize } from "@lookiero/sty-psp-ui";
|
|
6
6
|
import { CheckoutFeedbackProjection } from "../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
7
7
|
import { CheckoutQuestionType } from "../../../../projection/checkoutQuestion/checkoutQuestion";
|
|
8
8
|
import { useGiveCheckoutFeedback } from "../../../domain/checkoutFeedback/react/useGiveCheckoutFeedback";
|
|
@@ -28,7 +28,7 @@ interface HandleOnChangedFeedbackFunction {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
interface FeedbackProps {
|
|
31
|
-
readonly layout:
|
|
31
|
+
readonly layout: UiLayout;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fireEvent, RenderAPI, waitFor, screen
|
|
1
|
+
import { fireEvent, RenderAPI, waitFor, screen } from "@testing-library/react-native";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
4
4
|
import { Segment } from "@lookiero/sty-psp-segment";
|
|
@@ -9,7 +9,6 @@ import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutB
|
|
|
9
9
|
import { useKeepCheckoutItem } from "../../../domain/checkoutItem/react/useKeepCheckoutItem";
|
|
10
10
|
import { useReplaceCheckoutItem } from "../../../domain/checkoutItem/react/useReplaceCheckoutItem";
|
|
11
11
|
import { useResetCheckoutItem } from "../../../domain/checkoutItem/react/useResetCheckoutItem";
|
|
12
|
-
import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
13
12
|
import { bookedProductsVariants as mockBookedProductsVariants } from "../../../projection/bookedProductsVariants/bookedProductsVariants.mock";
|
|
14
13
|
import { useViewBookedProductsVariantsForCheckoutItem } from "../../../projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem";
|
|
15
14
|
import { checkout } from "../../../projection/checkout/checkout.mock";
|
|
@@ -32,10 +31,11 @@ jest.mock("../../hooks/useStaticInfo", () => ({
|
|
|
32
31
|
useStaticInfo: () => ({ customer: { customerId, country, segment } }),
|
|
33
32
|
}));
|
|
34
33
|
|
|
34
|
+
const mockNavigate = jest.fn();
|
|
35
35
|
jest.mock("react-router-native", () => ({
|
|
36
36
|
...jest.requireActual("react-router-native"),
|
|
37
37
|
useLocation: () => jest.fn(),
|
|
38
|
-
useNavigate: () =>
|
|
38
|
+
useNavigate: () => mockNavigate,
|
|
39
39
|
useMatch: () => false,
|
|
40
40
|
useParams: () => ({ id: mockFirstCheckoutItemId }),
|
|
41
41
|
}));
|
|
@@ -45,7 +45,6 @@ jest.mock("../../../projection/checkout/react/useViewIsSizeChangeEnabledByChecko
|
|
|
45
45
|
jest.mock("../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId");
|
|
46
46
|
jest.mock("../../../projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem");
|
|
47
47
|
jest.mock("../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem");
|
|
48
|
-
jest.mock("../../../domain/checkoutItem/react/useReturnCheckoutItem");
|
|
49
48
|
jest.mock("../../../domain/checkoutItem/react/useKeepCheckoutItem");
|
|
50
49
|
jest.mock("../../../domain/checkoutItem/react/useReplaceCheckoutItem");
|
|
51
50
|
jest.mock("../../../domain/checkoutItem/react/useResetCheckoutItem");
|
|
@@ -60,17 +59,8 @@ jest.mock("../../../tracking/useTrackKeepItem", () => ({
|
|
|
60
59
|
jest.mock("../../../tracking/useTrackReplaceItem", () => ({
|
|
61
60
|
useTrackReplaceItem: () => jest.fn(),
|
|
62
61
|
}));
|
|
63
|
-
const mockTrackReturnItem = jest.fn();
|
|
64
|
-
jest.mock("../../../tracking/useTrackReturnItem", () => ({
|
|
65
|
-
useTrackReturnItem: () => mockTrackReturnItem,
|
|
66
|
-
}));
|
|
67
62
|
jest.mock("../../../tracking/useTrackItemPageView");
|
|
68
63
|
|
|
69
|
-
jest.mock("../../hooks/useNewFeedbackExperiment", () => ({
|
|
70
|
-
...jest.requireActual("../../hooks/useNewFeedbackExperiment"),
|
|
71
|
-
useNewFeedbackExperiment: () => "control",
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
64
|
const mockCheckout = checkout({
|
|
75
65
|
items: [
|
|
76
66
|
{ id: mockFirstCheckoutItemId, status: CheckoutItemStatus.INITIAL },
|
|
@@ -87,8 +77,6 @@ interface RenderItemFunction {
|
|
|
87
77
|
|
|
88
78
|
const renderItem: RenderItemFunction = () => render(<Item layout={DummyLayout} />);
|
|
89
79
|
|
|
90
|
-
beforeEach(() => mockTrackReturnItem.mockClear());
|
|
91
|
-
|
|
92
80
|
beforeAll(() => {
|
|
93
81
|
jest.useFakeTimers();
|
|
94
82
|
});
|
|
@@ -110,8 +98,6 @@ describe("Item view", () => {
|
|
|
110
98
|
]);
|
|
111
99
|
const mockBookCheckoutBookingForCheckoutItem = jest.fn();
|
|
112
100
|
(useBookCheckoutBookingForCheckoutItem as jest.Mock).mockReturnValue([mockBookCheckoutBookingForCheckoutItem]);
|
|
113
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
114
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
115
101
|
(useKeepCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
116
102
|
(useReplaceCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
117
103
|
(useResetCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
@@ -133,8 +119,6 @@ describe("Item view", () => {
|
|
|
133
119
|
]);
|
|
134
120
|
const mockBookCheckoutBookingForCheckoutItem = jest.fn();
|
|
135
121
|
(useBookCheckoutBookingForCheckoutItem as jest.Mock).mockReturnValue([mockBookCheckoutBookingForCheckoutItem]);
|
|
136
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
137
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
138
122
|
(useKeepCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
139
123
|
(useReplaceCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
140
124
|
(useResetCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
@@ -156,31 +140,6 @@ describe("Item view", () => {
|
|
|
156
140
|
]);
|
|
157
141
|
const mockBookCheckoutBookingForCheckoutItem = jest.fn();
|
|
158
142
|
(useBookCheckoutBookingForCheckoutItem as jest.Mock).mockReturnValue([mockBookCheckoutBookingForCheckoutItem]);
|
|
159
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
160
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
161
|
-
(useKeepCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
162
|
-
(useReplaceCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
163
|
-
(useResetCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
164
|
-
|
|
165
|
-
const { findByTestId } = renderItem();
|
|
166
|
-
const spinner = await findByTestId("spinner");
|
|
167
|
-
|
|
168
|
-
expect(spinner).toBeDefined();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("renders a Spinner while 'returning' the item", async () => {
|
|
172
|
-
(useViewFiveItemsDiscountByCustomerId as jest.Mock).mockReturnValue([5, QueryStatus.SUCCESS]);
|
|
173
|
-
(useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([mockCheckout, QueryStatus.SUCCESS]);
|
|
174
|
-
(useViewIsSizeChangeEnabledByCheckoutId as jest.Mock).mockReturnValue([true, QueryStatus.SUCCESS]);
|
|
175
|
-
(useListReturnQuestionsByCheckoutItemId as jest.Mock).mockReturnValue([mockReturnQuestions, QueryStatus.SUCCESS]);
|
|
176
|
-
(useViewBookedProductsVariantsForCheckoutItem as jest.Mock).mockReturnValue([
|
|
177
|
-
mockBookedProductsVariants,
|
|
178
|
-
QueryStatus.SUCCESS,
|
|
179
|
-
]);
|
|
180
|
-
const mockBookCheckoutBookingForCheckoutItem = jest.fn();
|
|
181
|
-
(useBookCheckoutBookingForCheckoutItem as jest.Mock).mockReturnValue([mockBookCheckoutBookingForCheckoutItem]);
|
|
182
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
183
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.LOADING]);
|
|
184
143
|
(useKeepCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
185
144
|
(useReplaceCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
186
145
|
(useResetCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
@@ -202,8 +161,6 @@ describe("Item view", () => {
|
|
|
202
161
|
]);
|
|
203
162
|
const mockBookCheckoutBookingForCheckoutItem = jest.fn();
|
|
204
163
|
(useBookCheckoutBookingForCheckoutItem as jest.Mock).mockReturnValue([mockBookCheckoutBookingForCheckoutItem]);
|
|
205
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
206
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
207
164
|
(useKeepCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
208
165
|
(useReplaceCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
209
166
|
(useResetCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
@@ -225,8 +182,6 @@ describe("Item view", () => {
|
|
|
225
182
|
(useViewBookedProductsVariantsForCheckoutItem as jest.Mock).mockReturnValue([null, QueryStatus.SUCCESS]);
|
|
226
183
|
const mockBookCheckoutBookingForCheckoutItem = jest.fn();
|
|
227
184
|
(useBookCheckoutBookingForCheckoutItem as jest.Mock).mockReturnValue([mockBookCheckoutBookingForCheckoutItem]);
|
|
228
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
229
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
230
185
|
(useKeepCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
231
186
|
(useReplaceCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
232
187
|
(useResetCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
@@ -247,8 +202,6 @@ describe("Item view", () => {
|
|
|
247
202
|
]);
|
|
248
203
|
const mockBookCheckoutBookingForCheckoutItem = jest.fn();
|
|
249
204
|
(useBookCheckoutBookingForCheckoutItem as jest.Mock).mockReturnValue([mockBookCheckoutBookingForCheckoutItem]);
|
|
250
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
251
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
252
205
|
(useKeepCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
253
206
|
(useReplaceCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
254
207
|
(useResetCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
@@ -258,7 +211,7 @@ describe("Item view", () => {
|
|
|
258
211
|
expect(mockBookCheckoutBookingForCheckoutItem).not.toHaveBeenCalled();
|
|
259
212
|
});
|
|
260
213
|
|
|
261
|
-
it("calls
|
|
214
|
+
it("calls navigate to return page when pressing the return-button", async () => {
|
|
262
215
|
(useViewFiveItemsDiscountByCustomerId as jest.Mock).mockReturnValue([5, QueryStatus.SUCCESS]);
|
|
263
216
|
(useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([mockCheckout, QueryStatus.SUCCESS]);
|
|
264
217
|
(useViewIsSizeChangeEnabledByCheckoutId as jest.Mock).mockReturnValue([true, QueryStatus.SUCCESS]);
|
|
@@ -269,26 +222,17 @@ describe("Item view", () => {
|
|
|
269
222
|
]);
|
|
270
223
|
const mockBookCheckoutBookingForCheckoutItem = jest.fn();
|
|
271
224
|
(useBookCheckoutBookingForCheckoutItem as jest.Mock).mockReturnValue([mockBookCheckoutBookingForCheckoutItem]);
|
|
272
|
-
const mockReturnCheckoutItem = jest.fn();
|
|
273
|
-
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
274
225
|
(useKeepCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
275
226
|
(useReplaceCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
276
227
|
(useResetCheckoutItem as jest.Mock).mockReturnValue([jest.fn(), CommandStatus.IDLE]);
|
|
277
228
|
|
|
278
|
-
const { findByText
|
|
229
|
+
const { findByText } = renderItem();
|
|
279
230
|
|
|
280
231
|
const returnButton = await findByText(I18nMessages.ITEM_RETURN_BUTTON);
|
|
281
232
|
|
|
282
233
|
fireEvent.press(returnButton);
|
|
283
234
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const submitButton = await within(modal).findByText(I18nMessages.RETURN_QUESTIONS_SUBMIT_BUTTON);
|
|
287
|
-
|
|
288
|
-
fireEvent.press(submitButton);
|
|
289
|
-
|
|
290
|
-
expect(mockReturnCheckoutItem).toHaveBeenCalled();
|
|
291
|
-
expect(mockTrackReturnItem).toHaveBeenCalled();
|
|
235
|
+
expect(mockNavigate).toHaveBeenCalled();
|
|
292
236
|
});
|
|
293
237
|
|
|
294
238
|
it("shows discount banner when the user have purchased items", async () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { FC, useCallback, useEffect, useMemo, useRef
|
|
1
|
+
import React, { FC, useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import { generatePath, useMatch, useNavigate, useParams } from "react-router-native";
|
|
3
3
|
import { Box, Spinner } from "@lookiero/aurora";
|
|
4
|
-
import {
|
|
4
|
+
import { QueryStatus } from "@lookiero/messaging-react";
|
|
5
5
|
import { useLogger } from "@lookiero/sty-psp-logging";
|
|
6
6
|
import { useScreenSize } from "@lookiero/sty-psp-ui";
|
|
7
7
|
import { Layout } from "@lookiero/sty-psp-ui";
|
|
@@ -11,9 +11,7 @@ import {
|
|
|
11
11
|
ProductVariantProjection,
|
|
12
12
|
} from "../../../../projection/bookedProductsVariants/bookedProductsVariants";
|
|
13
13
|
import { CheckoutItemProjection } from "../../../../projection/checkoutItem/checkoutItem";
|
|
14
|
-
import { FeedbackProjection } from "../../../../projection/feedback/feedback";
|
|
15
14
|
import { useBookCheckoutBookingForCheckoutItem } from "../../../domain/checkoutBooking/react/useBookCheckoutBookingForCheckoutItem";
|
|
16
|
-
import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
17
15
|
import { useViewBookedProductsVariantsForCheckoutItem } from "../../../projection/bookedProductsVariants/react/useViewBookedProductsVariantsForCheckoutItem";
|
|
18
16
|
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
19
17
|
import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
|
|
@@ -24,17 +22,14 @@ import { useTrackItemPageView } from "../../../tracking/useTrackItemPageView";
|
|
|
24
22
|
import { useTrackPressBack } from "../../../tracking/useTrackPressBack";
|
|
25
23
|
import { useTrackPressNext } from "../../../tracking/useTrackPressNext";
|
|
26
24
|
import { useTrackPressPrevious } from "../../../tracking/useTrackPressPrevious";
|
|
27
|
-
import { useTrackReturnItem } from "../../../tracking/useTrackReturnItem";
|
|
28
25
|
import { FiveItemsDiscountBanner } from "../../components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner";
|
|
29
26
|
import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
30
27
|
import { ItemDetailHeader } from "../../components/templates/header/itemDetailHeader/ItemDetailHeader";
|
|
31
28
|
import { ItemHeader } from "../../components/templates/header/itemHeader/ItemHeader";
|
|
32
|
-
import { NewFeedbackExperimentVariation, useNewFeedbackExperiment } from "../../hooks/useNewFeedbackExperiment";
|
|
33
29
|
import { useStaticInfo } from "../../hooks/useStaticInfo";
|
|
34
30
|
import { Routes } from "../../routing/routes";
|
|
35
31
|
import { useBasePath } from "../../routing/useBasePath";
|
|
36
32
|
import { style } from "./Item.style";
|
|
37
|
-
import { ReturnQuestionsForm } from "./components/returnQuestionsForm/ReturnQuestionsForm";
|
|
38
33
|
import {
|
|
39
34
|
CheckoutItemWithCustomerDecission,
|
|
40
35
|
ItemWithCustomerDecission,
|
|
@@ -78,11 +73,6 @@ const Item: FC<ItemProps> = ({ layout: Layout }) => {
|
|
|
78
73
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
79
74
|
const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id) as CheckoutItemProjection;
|
|
80
75
|
|
|
81
|
-
/* Kameleoon experiment */
|
|
82
|
-
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
83
|
-
const redirectToReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
84
|
-
/* Kameleoon experiment */
|
|
85
|
-
|
|
86
76
|
/* SizeChange and Booking */
|
|
87
77
|
const [isSizeChangeEnabled, sizeChangeEnabledStatus] = useViewIsSizeChangeEnabledByCheckoutId({
|
|
88
78
|
checkoutId: checkout?.id,
|
|
@@ -111,32 +101,9 @@ const Item: FC<ItemProps> = ({ layout: Layout }) => {
|
|
|
111
101
|
const [returnQuestions] = useListReturnQuestionsByCheckoutItemId({
|
|
112
102
|
checkoutItemId: checkoutItem.id,
|
|
113
103
|
});
|
|
114
|
-
const [returnQuestionsVisible, setReturnQuestionsVisible] = useState(false);
|
|
115
|
-
const showReturnQuestions = useCallback(() => setReturnQuestionsVisible(true), []);
|
|
116
|
-
const hideReturnQuestions = useCallback(() => setReturnQuestionsVisible(false), []);
|
|
117
104
|
const goToReturnPage = useCallback(() => {
|
|
118
105
|
navigate(`${basePath}/${generatePath(Routes.RETURN, { id: checkoutItem.id })}`);
|
|
119
106
|
}, [basePath, checkoutItem.id, navigate]);
|
|
120
|
-
|
|
121
|
-
const [returnCheckoutItem, returnCheckoutItemStatus] = useReturnCheckoutItem({
|
|
122
|
-
checkoutItemId: checkoutItem.id,
|
|
123
|
-
logger,
|
|
124
|
-
});
|
|
125
|
-
const trackReturnItem = useTrackReturnItem({
|
|
126
|
-
page: TrackingPage.ITEM,
|
|
127
|
-
country,
|
|
128
|
-
segment,
|
|
129
|
-
checkoutId: checkout?.id,
|
|
130
|
-
checkoutItemId: checkoutItem.id,
|
|
131
|
-
});
|
|
132
|
-
const returnItem = useCallback(
|
|
133
|
-
async (feedbacks: FeedbackProjection) => {
|
|
134
|
-
hideReturnQuestions();
|
|
135
|
-
returnCheckoutItem({ feedbacks });
|
|
136
|
-
trackReturnItem();
|
|
137
|
-
},
|
|
138
|
-
[hideReturnQuestions, returnCheckoutItem, trackReturnItem],
|
|
139
|
-
);
|
|
140
107
|
/* ReturnCheckoutItem */
|
|
141
108
|
|
|
142
109
|
const currentProductVariant: ProductVariantProjection = useMemo(
|
|
@@ -242,8 +209,7 @@ const Item: FC<ItemProps> = ({ layout: Layout }) => {
|
|
|
242
209
|
bookedProductsVariantsStatus !== QueryStatus.LOADING &&
|
|
243
210
|
fiveItemsDiscountStatus !== QueryStatus.LOADING &&
|
|
244
211
|
sizeChangeEnabledStatus !== QueryStatus.LOADING &&
|
|
245
|
-
(isBookingRequired ? checkout.checkoutBookingId && bookedProductsVariants : true)
|
|
246
|
-
returnCheckoutItemStatus !== CommandStatus.LOADING;
|
|
212
|
+
(isBookingRequired ? checkout.checkoutBookingId && bookedProductsVariants : true);
|
|
247
213
|
|
|
248
214
|
if (!dependenciesLoaded) {
|
|
249
215
|
return <Spinner testID="spinner" />;
|
|
@@ -266,7 +232,7 @@ const Item: FC<ItemProps> = ({ layout: Layout }) => {
|
|
|
266
232
|
checkoutId={checkout.id}
|
|
267
233
|
checkoutItem={checkoutItem as CheckoutItemWithoutCustomerDecission}
|
|
268
234
|
currentProductVariant={currentProductVariant}
|
|
269
|
-
onReturn={
|
|
235
|
+
onReturn={goToReturnPage}
|
|
270
236
|
/>
|
|
271
237
|
) : (
|
|
272
238
|
<ItemWithCustomerDecission
|
|
@@ -274,19 +240,10 @@ const Item: FC<ItemProps> = ({ layout: Layout }) => {
|
|
|
274
240
|
checkoutItem={checkoutItem as CheckoutItemWithCustomerDecission}
|
|
275
241
|
currentProductVariant={currentProductVariant}
|
|
276
242
|
returnQuestions={returnQuestions}
|
|
277
|
-
onEditFeedback={
|
|
243
|
+
onEditFeedback={goToReturnPage}
|
|
278
244
|
/>
|
|
279
245
|
)}
|
|
280
246
|
</Layout>
|
|
281
|
-
|
|
282
|
-
{!redirectToReturnPage ? (
|
|
283
|
-
<ReturnQuestionsForm
|
|
284
|
-
returnQuestions={returnQuestions}
|
|
285
|
-
visible={returnQuestionsVisible}
|
|
286
|
-
onClose={hideReturnQuestions}
|
|
287
|
-
onSubmit={returnItem}
|
|
288
|
-
/>
|
|
289
|
-
) : null}
|
|
290
247
|
</ReturnQuestionFeedbackProvider>
|
|
291
248
|
);
|
|
292
249
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
|
|
3
|
+
import { Country } from "@lookiero/sty-psp-locale";
|
|
4
|
+
import { Segment } from "@lookiero/sty-psp-segment";
|
|
5
|
+
import { DummyLayout } from "@lookiero/sty-psp-ui";
|
|
6
|
+
import { CheckoutItemStatus } from "../../../../domain/checkoutItem/model/checkoutItem";
|
|
7
|
+
import { useReturnCheckoutItem } from "../../../domain/checkoutItem/react/useReturnCheckoutItem";
|
|
8
|
+
import { checkout } from "../../../projection/checkout/checkout.mock";
|
|
9
|
+
import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
10
|
+
import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
|
|
11
|
+
import { returnQuestions as mockReturnQuestions } from "../../../projection/returnQuestion/returnQuestions.mock";
|
|
12
|
+
import { render } from "../../test/render";
|
|
13
|
+
import { Return } from "./Return";
|
|
14
|
+
|
|
15
|
+
const customerId = "a8fff6d7-708c-41a7-b42a-58c5706d33df";
|
|
16
|
+
const country = Country.ES;
|
|
17
|
+
const segment = Segment.WOMEN;
|
|
18
|
+
const mockCheckout = checkout({
|
|
19
|
+
items: [
|
|
20
|
+
{ status: CheckoutItemStatus.KEPT },
|
|
21
|
+
{ status: CheckoutItemStatus.RETURNED },
|
|
22
|
+
{ status: CheckoutItemStatus.REPLACED },
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
const mockFirstCheckoutItemId = mockCheckout.items[0]?.id;
|
|
26
|
+
|
|
27
|
+
jest.mock("../../hooks/useStaticInfo", () => ({
|
|
28
|
+
useStaticInfo: () => ({ customer: { customerId, country, segment } }),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
jest.mock("react-router-native", () => ({
|
|
32
|
+
...jest.requireActual("react-router-native"),
|
|
33
|
+
useLocation: () => jest.fn(),
|
|
34
|
+
useNavigate: () => jest.fn(),
|
|
35
|
+
useMatch: () => false,
|
|
36
|
+
useParams: () => ({ id: mockFirstCheckoutItemId }),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
jest.mock("../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId");
|
|
40
|
+
jest.mock("../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId");
|
|
41
|
+
jest.mock("../../../domain/checkoutItem/react/useReturnCheckoutItem");
|
|
42
|
+
|
|
43
|
+
describe("Return", () => {
|
|
44
|
+
test("renders correctly", async () => {
|
|
45
|
+
(useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([mockCheckout, QueryStatus.SUCCESS]);
|
|
46
|
+
(useListReturnQuestionsByCheckoutItemId as jest.Mock).mockReturnValue([mockReturnQuestions, QueryStatus.SUCCESS]);
|
|
47
|
+
const mockReturnCheckoutItem = jest.fn();
|
|
48
|
+
(useReturnCheckoutItem as jest.Mock).mockReturnValue([mockReturnCheckoutItem, CommandStatus.IDLE]);
|
|
49
|
+
|
|
50
|
+
const { findByTestId } = render(<Return layout={DummyLayout} />);
|
|
51
|
+
|
|
52
|
+
expect(await findByTestId("return-questions-form")).toBeTruthy();
|
|
53
|
+
});
|
|
54
|
+
});
|