@bytebrand/fe-ui-core 4.2.53 → 4.2.55

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.
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react'
3
+ import OrderStatusCar from '../../../../../source/components/UserDashboardPage/sections/OrderStatusSection/OrderStatusCar';
4
+
5
+ const t = (phrase: string | string[], options: object) => {
6
+ if (options) {
7
+ const value = Object.values(options).map((option) => option)
8
+ return `${phrase} ${value}`;
9
+ }
10
+ return phrase;
11
+ }
12
+
13
+ const mockProps = {
14
+ t,
15
+ make: 'Test Make',
16
+ model: 'Test Model',
17
+ subModel: 'test car',
18
+ buyingType: 'buy',
19
+ imageUrl: 'https://images.autode-dev.de/carimage/28121b1a-398c-4e9c-9097-51be545817c5/RQ_mHNek5hIk/small-cached.webp',
20
+ selfPickup: false,
21
+ paybackPeriod: 12,
22
+ monthlyInstallment: 2000,
23
+ status: 'selector_status_order_received',
24
+ request: '1234abcd',
25
+ registration: false,
26
+ currentSalesPrice: 30000,
27
+ onClick: jest.fn()
28
+ }
29
+
30
+ describe('OrderStatusCar', () => {
31
+ it('renders OrderStatusCar component without error', () => {
32
+ const { container } = render(<OrderStatusCar {...mockProps} />);
33
+ expect(container).toBeInTheDocument();
34
+ });
35
+
36
+ it('should display correct car make and model', () => {
37
+ const { getByText } = render(<OrderStatusCar {...mockProps} />);
38
+ expect(getByText(`${mockProps.make} ${mockProps.model}`)).toBeInTheDocument();
39
+ });
40
+
41
+ it('should display correct car characteristics', () => {
42
+ const { getByText } = render(<OrderStatusCar {...mockProps} />);
43
+ expect(getByText(mockProps.subModel)).toBeInTheDocument();
44
+ });
45
+
46
+ it('should display correct car image', () => {
47
+ const { getByTestId } = render(<OrderStatusCar {...mockProps}/>);
48
+ const carImage = getByTestId('car-image')
49
+ expect(carImage).toHaveAttribute('src', mockProps.imageUrl);
50
+ });
51
+
52
+ it('should call onClick function when user clicks on the car card', () => {
53
+ const { getByTestId } = render(<OrderStatusCar {...mockProps} />);
54
+ const carCard = getByTestId('car-card');
55
+ fireEvent.click(carCard);
56
+ expect(mockProps.onClick).toHaveBeenCalled();
57
+ });
58
+ });
@@ -6,6 +6,17 @@ describe('OrderStatusCard', () => {
6
6
  const icon = 'orderReceivedDashboard';
7
7
  const title = 'Test title';
8
8
  const description = 'Test description';
9
+ it('render container without errors', () => {
10
+ const { container } = render(
11
+ <OrderStatusCard
12
+ icon={icon}
13
+ title={title}
14
+ description={description}
15
+ />
16
+ );
17
+ expect(container).toBeInTheDocument();
18
+ });
19
+
9
20
  it('renders a card with title, description, and icon', () => {
10
21
  const { getByText, container, debug } = render(
11
22
  <OrderStatusCard
@@ -23,7 +34,7 @@ describe('OrderStatusCard', () => {
23
34
  expect(svgElement).toBeInTheDocument();
24
35
  });
25
36
 
26
- it('adds "isDisabled" class when isDisabled prop is set', () => {
37
+ it('adds "notReachedTitle" class for title when "isDisabled" prop is set', () => {
27
38
  const { getByTestId, debug } = render(
28
39
  <OrderStatusCard
29
40
  icon={icon}
@@ -36,4 +47,32 @@ describe('OrderStatusCard', () => {
36
47
  const cardTitle = getByTestId('cardTitle');
37
48
  expect(cardTitle).toHaveClass('notReachedTitle');
38
49
  });
50
+
51
+ it('adds "isDoneTitle" class for title when "isDone" prop is set', () => {
52
+ const { getByTestId, debug } = render(
53
+ <OrderStatusCard
54
+ icon={icon}
55
+ title={title}
56
+ description={description}
57
+ isDone={true}
58
+ />
59
+ );
60
+ debug();
61
+ const cardTitle = getByTestId('cardTitle');
62
+ expect(cardTitle).toHaveClass('isDoneTitle');
63
+ });
64
+
65
+ it('adds "cardInProgress" class for card when "isActive" prop is set', () => {
66
+ const { getByTestId, debug } = render(
67
+ <OrderStatusCard
68
+ icon={icon}
69
+ title={title}
70
+ description={description}
71
+ isActive={true}
72
+ />
73
+ );
74
+ debug();
75
+ const orderStatusCard = getByTestId('orderStatusCard');
76
+ expect(orderStatusCard).toHaveClass('cardInProgress');
77
+ });
39
78
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.53",
3
+ "version": "4.2.55",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -1,10 +1,13 @@
1
1
  import React, { useRef, useEffect, useState } from 'react';
2
2
  import styles from './OrderStatusSection.styl';
3
3
  import OrderStatusCard from './OrderStatusCard';
4
- import i18n from 'i18next';
5
4
  import Image from '../../../_common/Image/Image';
6
5
  import { getFormattedPrice } from '../../../../framework/utils/CommonUtils';
7
6
 
7
+ interface TFunction {
8
+ <T = string>(key: string, options?: object): T;
9
+ <T = string>(keys: string[], options?: object): T;
10
+ }
8
11
  interface IOrderStatusCar {
9
12
  make?: string;
10
13
  model?: string;
@@ -15,7 +18,7 @@ interface IOrderStatusCar {
15
18
  paybackPeriod?: number;
16
19
  monthlyInstallment?: number;
17
20
  status?: string;
18
- t: i18n.TFunction;
21
+ t: TFunction;
19
22
  request: string;
20
23
  registration: boolean;
21
24
  currentSalesPrice: number;
@@ -58,13 +61,13 @@ const OrderStatusCar = ({
58
61
  setActiveStep(index + 1);
59
62
  }
60
63
  });
61
- if (ref && ref.current) {
62
- ref.current.parentElement.scrollBy({
63
- top: 0,
64
- left: 156 * activeStep,
65
- behavior: 'smooth'
66
- });
67
- }
64
+ // if (!!ref && !!ref.current) { TODO: fix scroll for active element for mobile
65
+ // ref.current.scrollBy({
66
+ // top: 0,
67
+ // left: 156 * activeStep,
68
+ // behavior: 'smooth'
69
+ // });
70
+ // }
68
71
  },
69
72
  []
70
73
  );
@@ -72,7 +75,7 @@ const OrderStatusCar = ({
72
75
  return (
73
76
  <div className={styles.orderedCar}>
74
77
  <div className={styles.orderReceivedSection}>
75
- <div className={styles.carCardWrapper} onClick={onClick}>
78
+ <div className={styles.carCardWrapper} data-testid='car-card' onClick={onClick}>
76
79
  <div className={styles.carCard}>
77
80
  <div className={styles.carMarke}>
78
81
  {make} {model}
@@ -82,7 +85,7 @@ const OrderStatusCar = ({
82
85
  </div>
83
86
  <div className={styles.carImg}>
84
87
  {/* <Image className={styles.carImg} width='100%' ratioW={4} ratioH={3} src={imageUrl} /> */}
85
- <img src={imageUrl}/>
88
+ <img data-testid='car-image' src={imageUrl}/>
86
89
  </div>
87
90
  <div className={styles.requestId}>{request}</div>
88
91
  <div className={styles.carPayment} >
@@ -27,7 +27,7 @@ const OrderStatusCard = ({ icon, title, description, isDisabled, cardRef, isActi
27
27
 
28
28
  return (
29
29
  <div className={styles.orderReceivedCardContainer}>
30
- <div className={orderReceivedCardClasses} ref={cardRef}>
30
+ <div data-testid='orderStatusCard' className={orderReceivedCardClasses} ref={cardRef}>
31
31
  <div className={styles.cardIcon}>
32
32
  <IconSVG disabled={isDisabled} customDimensions name={icon} width={87}/>
33
33
  </div>
@@ -41,15 +41,47 @@ const orderedCars = [
41
41
  selfPickup: false,
42
42
  paybackPeriod: 24,
43
43
  monthlyInstallment: 1000,
44
- status: 'selector_status_preparation',
44
+ status: 'selector_status_registration',
45
45
  request: '010203',
46
46
  registration: false,
47
47
  currentSalesPrice: 20000
48
48
  }
49
49
  ];
50
50
 
51
+ const translates = {
52
+ 'orderStatus.title': 'Order status',
53
+ 'orderStatus.selector_status_order_received': 'order received',
54
+ 'orderStatus.selector_status_preparation': 'preparation',
55
+ 'orderStatus.selector_status_registration': 'registration',
56
+ 'orderStatus.selector_status_pick_up': 'pickup',
57
+ 'orderStatus.selector_status_handing_over': 'handing over',
58
+ 'orderStatus.selector_status_delivery': 'delivery',
59
+ 'orderStatus.independentRegistration': 'independent registration',
60
+ 'orderStatus.selector_status_order_received_desc': 'order received description',
61
+ 'orderStatus.selector_status_preparation_desc': 'preparation description',
62
+ 'orderStatus.selector_status_registration_desc': 'registration description',
63
+ 'orderStatus.selector_status_pick_up_desc': 'pickup description',
64
+ 'orderStatus.selector_status_handing_over_desc': 'handing over description',
65
+ 'orderStatus.selector_status_delivery_desc': 'delivery description',
66
+ 'buyingType.buy': 'buy',
67
+ 'buyingType.leasing': 'leasing',
68
+ 'buyingType.financing': 'financing',
69
+ 'paybackPeriod': 'payback period',
70
+ 'currentSalesPrice': 'current sales price',
71
+ 'monthlyInstallment': 'monthly installment'
72
+ }
73
+
74
+ const t = (phrase, options) => {
75
+ if (options) {
76
+ console.log('qqqq options ====', options);
77
+ const value = Object.values(options).map((option) => option)
78
+ return `${translates[phrase]} ${value}`;
79
+ }
80
+ return translates[phrase];
81
+ }
82
+
51
83
  const props = {
52
- t: (phrase) => phrase,
84
+ t,
53
85
  redirectToCar: (id) => console.log(`redirect to car with id: ${id}`),
54
86
  getSupportedImageFormat: (id, mainImageId, size) => 'https://images.autode-dev.de/carimage/28121b1a-398c-4e9c-9097-51be545817c5/RQ_mHNek5hIk/small-cached.webp',
55
87
  isFetching: false,
@@ -12,7 +12,7 @@ interface IPreviewCookieModal {
12
12
 
13
13
  const PreviewCookieModal = ({ toggleModal, setModal }: IPreviewCookieModal) => {
14
14
  const onAcceptAll = () => {
15
- localStorage.setItem('cookieConfig', JSON.stringify([]));
15
+ localStorage.setItem('cookieConfig', JSON.stringify({}));
16
16
  updateCookieList();
17
17
  toggleModal();
18
18
  };
@@ -14,6 +14,15 @@ import { SearchPage as SearchPageTranslate } from '../../locales/data';
14
14
 
15
15
  const PRICE_DEFAULT = DROP_DOWN_GROUP[PRICE].defaultValue;
16
16
 
17
+ declare global {
18
+ interface Window {
19
+ grantHotjarCookieConsent?: () => void;
20
+ grantCookieConsent?: (list: string[]) => void;
21
+ allowGoogle?: () => void;
22
+ fbq?: (option1: string, option2: string) => void;
23
+ }
24
+ }
25
+
17
26
  export const formatMileage = (millage: number | string) => {
18
27
  return millage.toLocaleString('en-US').replace(/,/g, '.');
19
28
  };