@lookiero/checkout 7.0.0-beta.0 → 7.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/src/ExpoRoot.js +1 -8
  2. package/dist/src/infrastructure/ab-testing/kameleoonEnvironment.d.ts +2 -6
  3. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +1 -10
  4. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.d.ts +1 -7
  5. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.js +1 -7
  6. package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +2 -7
  7. package/dist/src/infrastructure/ui/routing/CheckoutMiddleware.js +5 -1
  8. package/dist/src/infrastructure/ui/routing/Routing.js +2 -4
  9. package/dist/src/infrastructure/ui/views/checkout/Checkout.js +4 -4
  10. package/dist/src/infrastructure/ui/views/feedback/Feedback.d.ts +2 -2
  11. package/dist/src/infrastructure/ui/views/item/Item.js +4 -33
  12. package/dist/src/infrastructure/ui/views/return/Return.js +8 -127
  13. package/dist/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.js +5 -7
  14. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +15 -0
  15. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.js +112 -0
  16. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +40 -0
  17. package/dist/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.style.js +43 -0
  18. package/dist/src/infrastructure/ui/views/summary/Summary.js +4 -4
  19. package/dist/src/version.d.ts +1 -1
  20. package/dist/src/version.js +1 -1
  21. package/package.json +1 -1
  22. package/src/ExpoRoot.tsx +1 -8
  23. package/src/infrastructure/ab-testing/kameleoonEnvironment.ts +3 -7
  24. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.style.ts +1 -7
  25. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.test.tsx +0 -5
  26. package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.tsx +2 -17
  27. package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.test.tsx +0 -5
  28. package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +11 -20
  29. package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +10 -0
  30. package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +7 -1
  31. package/src/infrastructure/ui/routing/Routing.tsx +3 -6
  32. package/src/infrastructure/ui/views/checkout/Checkout.tsx +6 -6
  33. package/src/infrastructure/ui/views/feedback/Feedback.tsx +2 -2
  34. package/src/infrastructure/ui/views/item/Item.test.tsx +6 -62
  35. package/src/infrastructure/ui/views/item/Item.tsx +5 -48
  36. package/src/infrastructure/ui/views/return/Return.test.tsx +54 -0
  37. package/src/infrastructure/ui/views/return/Return.tsx +12 -200
  38. package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.test.tsx +32 -0
  39. package/src/infrastructure/ui/views/return/components/productVariantPreview/ProductVariantPreview.tsx +12 -7
  40. package/src/infrastructure/ui/views/return/components/productVariantPreview/__snapshots__/ProductVariantPreview.test.tsx.snap +221 -0
  41. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.test.tsx +95 -0
  42. package/src/infrastructure/ui/views/return/components/returnQuestionsForm/ReturnQuestionsForm.tsx +184 -0
  43. package/src/infrastructure/ui/views/summary/Summary.tsx +6 -6
  44. package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.test.tsx +0 -84
  45. package/src/infrastructure/ui/hooks/useNewFeedbackExperiment.tsx +0 -82
  46. package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.ts +0 -18
  47. package/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.tsx +0 -79
  48. /package/src/infrastructure/ui/views/return/{Return.style.ts → components/returnQuestionsForm/ReturnQuestionsForm.style.ts} +0 -0
@@ -0,0 +1,40 @@
1
+ declare const style: {
2
+ description: {
3
+ color: string;
4
+ };
5
+ desktopInfo: {
6
+ borderTopLeftRadius: number;
7
+ borderTopRightRadius: number;
8
+ };
9
+ desktopLayoutSpacing: {
10
+ paddingVertical: number;
11
+ };
12
+ headerWrapper: {
13
+ display: "flex";
14
+ flexDirection: "column";
15
+ };
16
+ info: {
17
+ backgroundColor: string;
18
+ paddingBottom: number;
19
+ paddingHorizontal: number;
20
+ paddingTop: number;
21
+ };
22
+ layout: {
23
+ flex: number;
24
+ justifyContent: "center";
25
+ };
26
+ safeAreaView: {
27
+ backgroundColor: string;
28
+ flex: number;
29
+ };
30
+ scrollView: {
31
+ flex: number;
32
+ };
33
+ submit: {
34
+ backgroundColor: string;
35
+ borderBottomLeftRadius: number;
36
+ borderBottomRightRadius: number;
37
+ padding: number;
38
+ };
39
+ };
40
+ export { style };
@@ -0,0 +1,43 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "@lookiero/sty-psp-ui";
3
+ const { borderRadius5, colorBgPrimaryLight, colorBgBase, colorTextMedium, space4, space6, space8 } = theme();
4
+ const style = StyleSheet.create({
5
+ description: {
6
+ color: colorTextMedium,
7
+ },
8
+ desktopInfo: {
9
+ borderTopLeftRadius: borderRadius5,
10
+ borderTopRightRadius: borderRadius5,
11
+ },
12
+ desktopLayoutSpacing: {
13
+ paddingVertical: space8,
14
+ },
15
+ headerWrapper: {
16
+ display: "flex",
17
+ flexDirection: "column",
18
+ },
19
+ info: {
20
+ backgroundColor: colorBgBase,
21
+ paddingBottom: space4,
22
+ paddingHorizontal: space6,
23
+ paddingTop: space8,
24
+ },
25
+ layout: {
26
+ flex: 1,
27
+ justifyContent: "center",
28
+ },
29
+ safeAreaView: {
30
+ backgroundColor: colorBgPrimaryLight,
31
+ flex: 1,
32
+ },
33
+ scrollView: {
34
+ flex: 1,
35
+ },
36
+ submit: {
37
+ backgroundColor: colorBgBase,
38
+ borderBottomLeftRadius: borderRadius5,
39
+ borderBottomRightRadius: borderRadius5,
40
+ padding: space6,
41
+ },
42
+ });
43
+ export { style };
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useMemo, useState } from "react";
2
2
  import { Platform, ScrollView, View } from "react-native";
3
3
  import { generatePath, useMatch, useNavigate } from "react-router-native";
4
- import { Box, Text, Layout, useDevice, Spinner } from "@lookiero/aurora";
4
+ import { Box, Text, Layout as AuroraLayout, useDevice, Spinner } from "@lookiero/aurora";
5
5
  import { useI18nMessage } from "@lookiero/i18n-react";
6
6
  import { QueryStatus } from "@lookiero/messaging-react";
7
7
  import { Sticky } from "@lookiero/sty-psp-ui";
@@ -21,7 +21,7 @@ import { Routes } from "../../routing/routes";
21
21
  import { useBasePath } from "../../routing/useBasePath";
22
22
  import { style } from "./Summary.style";
23
23
  import { CollapsiblePricing } from "./components/collapsiblePricing/CollapsiblePricing";
24
- const Summary = ({ layout: UiLayout, children }) => {
24
+ const Summary = ({ layout: Layout, children }) => {
25
25
  const { customer: { customerId, country, segment }, } = useStaticInfo();
26
26
  const [pricingCollapsed, setPricingCollapsed] = useState(true);
27
27
  const [pricingHeight, setPricingHeight] = useState(0);
@@ -79,13 +79,13 @@ const Summary = ({ layout: UiLayout, children }) => {
79
79
  if (!dependenciesLoaded) {
80
80
  return React.createElement(Spinner, null);
81
81
  }
82
- return (React.createElement(UiLayout, { scrollEnabled: false, style: {
82
+ return (React.createElement(Layout, { scrollEnabled: false, style: {
83
83
  header: style.header,
84
84
  scrollView: style.scrollView,
85
85
  } },
86
86
  React.createElement(ScrollView, { showsVerticalScrollIndicator: false },
87
87
  fiveItemsDiscount !== 0 && React.createElement(FiveItemsDiscountBanner, { fiveItemsDiscount: fiveItemsDiscount }),
88
- React.createElement(Layout, { fullWidth: !screen.L, style: [screen.L && style.desktopLayoutSpacing, !screen.L && { paddingBottom: pricingHeight }] },
88
+ React.createElement(AuroraLayout, { fullWidth: !screen.L, style: [screen.L && style.desktopLayoutSpacing, !screen.L && { paddingBottom: pricingHeight }] },
89
89
  React.createElement(Box, { size: { L: "2/3" }, style: screen.L && style.desktopListSpacing },
90
90
  React.createElement(View, { style: [style.contentWrapper, screen.L && style.desktopContentWrapper] },
91
91
  React.createElement(View, { style: !screen.L && style.mobileInfo },
@@ -1 +1 @@
1
- export declare const VERSION = "7.0.0-beta.0";
1
+ export declare const VERSION = "7.0.1-beta.0";
@@ -1 +1 @@
1
- export const VERSION = "7.0.0-beta.0";
1
+ export const VERSION = "7.0.1-beta.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "7.0.0-beta.0",
3
+ "version": "7.0.1-beta.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": "false",
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
- interface Experiment {
2
- readonly id: string;
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
- paddingRight: space6,
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
- const fieldComponent = (
37
- <InputField
38
- label={placeholderText}
39
- placeholder={placeholderText}
40
- testID={testID}
41
- value={feedback}
42
- multiline
43
- onChange={handleOnChange}
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 };
@@ -140,6 +140,16 @@ describe("CheckoutMiddleware component", () => {
140
140
  expect(mockStartCheckout).toHaveBeenCalled();
141
141
  });
142
142
 
143
+ it("should call onNotAccessible when no checkout is found", async () => {
144
+ (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([null, QueryStatus.SUCCESS]);
145
+ (useStartCheckout as jest.Mock).mockReturnValue([mockStartCheckout, CommandStatus.SUCCESS]);
146
+
147
+ const onNotAccessible = jest.fn();
148
+ renderCheckoutMiddleware({ path: Routes.HOME, onNotAccessible });
149
+
150
+ expect(onNotAccessible).toHaveBeenCalled();
151
+ });
152
+
143
153
  it("payment route should not be directly accessible", async () => {
144
154
  const checkoutMock = checkout({ items: [{ status: CheckoutItemStatus.INITIAL }] });
145
155
  (useViewFirstAvailableCheckoutByCustomerId as jest.Mock).mockReturnValue([checkoutMock, QueryStatus.SUCCESS]);
@@ -117,10 +117,16 @@ const CheckoutMiddleware: FC<CheckoutMiddlewareProps> = ({
117
117
  }
118
118
  }, [basePath, checkout?.status, checkout?.items]);
119
119
 
120
- if (!checkout) {
120
+ if (checkout === undefined) {
121
121
  return loader;
122
122
  }
123
123
 
124
+ if (checkout === null) {
125
+ onNotAccessible();
126
+
127
+ return null;
128
+ }
129
+
124
130
  /* Prevent direct payment access */
125
131
  if (checkoutPaymentRouteMatch && !checkoutShown.current) {
126
132
  onNotAccessible();
@@ -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
- <NewFeedbackExperimentProvider>
68
- <App>
69
- <Outlet />
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: UiLayout, useRedirect }) => {
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
- <UiLayout
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
- <Layout
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
- </Layout>
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
- </UiLayout>
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: 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, within } from "@testing-library/react-native";
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: () => jest.fn(),
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 returnCheckoutItem and trackReturnCheckoutItem when pressing the return-button", async () => {
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, findByTestId } = renderItem();
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
- const modal = await findByTestId("return-questions-form-modal");
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 () => {