@riosst100/pwa-marketplace 1.2.4 → 1.2.5
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/package.json +1 -1
- package/src/componentOverrideMapping.js +2 -1
- package/src/components/Filter/index.js +7 -7
- package/src/components/OperatingHours/index.js +1 -0
- package/src/components/OperatingHours/operatingHours.js +32 -0
- package/src/components/Pagination/index.js +26 -17
- package/src/components/Search/index.js +1 -1
- package/src/components/Seller/seller.js +137 -46
- package/src/components/Seller/sellerAddressCard.js +48 -0
- package/src/components/SellerDetail/index.js +1 -0
- package/src/components/SellerDetail/sellerDetail.js +158 -0
- package/src/components/SellerInformation/sellerInformation.js +51 -26
- package/src/components/SellerLocation/sellerLocation.js +6 -2
- package/src/components/SellerLocation/sellerLocationItem.js +6 -8
- package/src/components/SellerProducts/sellerProducts.js +33 -12
- package/src/components/SellerReview/sellerReview.js +29 -29
- package/src/components/SellerReviewItem/sellerReviewItem.js +8 -8
- package/src/components/SortBy/index.js +13 -5
- package/src/components/commons/Tabs/index.js +11 -9
- package/src/overwrites/venia-ui/lib/components/Header/header.js +46 -34
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +31 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +43 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -0
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +50 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.module.css +0 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -0
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -0
- package/src/talons/Seller/seller.gql.js +70 -5
- package/src/talons/Seller/useSeller.js +6 -1
- package/src/talons/SellerProducts/useSellerProducts.js +129 -0
- package/src/theme/vars.js +7 -0
|
@@ -9,16 +9,16 @@ const SellerReviewItem = () => {
|
|
|
9
9
|
<div class="inline-flex flex-col items-start gap-[10px] relative flex-[0_0_auto]">
|
|
10
10
|
<div class="inline-flex items-center gap-[15px] relative flex-[0_0_auto]">
|
|
11
11
|
<div class="flex w-[40px] h-[40px] items-center justify-around gap-[10px] p-[10px] relative bg-[#4e31db] rounded-[30px]">
|
|
12
|
-
<div class="relative w-fit
|
|
12
|
+
<div class="relative w-fit font-semibold text-white text-[16px] text-center tracking-[0] leading-[18px] whitespace-nowrap">JD</div>
|
|
13
13
|
</div>
|
|
14
14
|
<div class="inline-flex flex-col items-start gap-[10px] relative flex-[0_0_auto]">
|
|
15
|
-
<div class="relative w-fit mt-[-1.00px]
|
|
16
|
-
<div class="relative w-fit
|
|
15
|
+
<div class="relative w-fit mt-[-1.00px] font-medium text-[14px] text-center tracking-[0] leading-[18px] whitespace-nowrap">John Doe</div>
|
|
16
|
+
<div class="relative w-fit font-medium text-[#999999] text-[12px] text-center tracking-[0] leading-[18px] whitespace-nowrap">18 January 2024</div>
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
|
-
<div class="
|
|
19
|
+
<div class="flex xs_flex-col sm_flex-row items-start xs_gap-1 sm_gap-[20px] relative flex-[0_0_auto]">
|
|
20
20
|
<div class="inline-flex items-center gap-[10px] relative flex-[0_0_auto]">
|
|
21
|
-
<div class="relative w-fit
|
|
21
|
+
<div class="relative w-fit font-normal text-[14px] tracking-[0] leading-[18px] whitespace-nowrap">Price</div>
|
|
22
22
|
<div class="inline-flex items-start gap-[6px] relative flex-[0_0_auto]">
|
|
23
23
|
<Star1 color='#F7C317' size={14} className='fill-[#F7C317]' />
|
|
24
24
|
<Star1 color='#F7C317' size={14} className='fill-[#F7C317]' />
|
|
@@ -28,7 +28,7 @@ const SellerReviewItem = () => {
|
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
30
30
|
<div class="inline-flex items-center gap-[10px] relative flex-[0_0_auto]">
|
|
31
|
-
<div class="relative w-[37px]
|
|
31
|
+
<div class="relative w-[37px] font-normal text-[14px] tracking-[0] leading-[18px]">Value</div>
|
|
32
32
|
<div class="inline-flex items-start gap-[6px] relative flex-[0_0_auto]">
|
|
33
33
|
<Star1 color='#F7C317' size={14} className='fill-[#F7C317]' />
|
|
34
34
|
<Star1 color='#F7C317' size={14} className='fill-[#F7C317]' />
|
|
@@ -38,7 +38,7 @@ const SellerReviewItem = () => {
|
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
40
40
|
<div class="inline-flex items-center gap-[10px] relative flex-[0_0_auto]">
|
|
41
|
-
<div class="relative w-fit
|
|
41
|
+
<div class="relative w-fit font-normal text-[14px] tracking-[0] leading-[18px] whitespace-nowrap">Quality</div>
|
|
42
42
|
<div class="inline-flex items-start gap-[6px] relative flex-[0_0_auto]">
|
|
43
43
|
<Star1 color='#F7C317' size={14} className='fill-[#F7C317]' />
|
|
44
44
|
<Star1 color='#F7C317' size={14} className='fill-[#F7C317]' />
|
|
@@ -49,7 +49,7 @@ const SellerReviewItem = () => {
|
|
|
49
49
|
</div>
|
|
50
50
|
</div>
|
|
51
51
|
</div>
|
|
52
|
-
<p class="relative self-stretch
|
|
52
|
+
<p class="relative self-stretch font-normal text-[14px] tracking-[0] leading-[18px]">
|
|
53
53
|
Got item at a great price. Arrived way quicker than expected, extremely well packaged and exactly as described. Highly recommend the seller.
|
|
54
54
|
</p>
|
|
55
55
|
</div>
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ArrowDown2 } from 'iconsax-react';
|
|
2
|
+
import { ArrowDown2, Filter } from 'iconsax-react';
|
|
3
3
|
|
|
4
4
|
const Sort = () => {
|
|
5
5
|
return (
|
|
6
6
|
<>
|
|
7
|
-
<div
|
|
8
|
-
<div class="
|
|
9
|
-
<div class="
|
|
10
|
-
|
|
7
|
+
<div className='x-container xs_flex xs_justify-between xs_w-full xl_w-fit'>
|
|
8
|
+
<div class="xs_flex xl_hidden flex-col items-start gap-[10px] px-[15px] py-[10px] relative flex-[0_0_auto] bg-white rounded-[30px] border border-solid border-gray-100">
|
|
9
|
+
<div class="inline-flex items-center gap-[20px] relative flex-[0_0_auto]">
|
|
10
|
+
<Filter color="#292D32" size={14} variant="Outline" className='stroke-[#292D32]' />
|
|
11
|
+
<div class="relative w-fit text-[14px] tracking-[0] leading-[normal] whitespace-nowrap">Filter</div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="inline-flex flex-col items-start gap-[10px] px-[15px] py-[10px] relative flex-[0_0_auto] bg-white rounded-[30px] border border-solid border-gray-100">
|
|
15
|
+
<div class="inline-flex items-center gap-[20px] relative flex-[0_0_auto]">
|
|
16
|
+
<div class="relative w-fit text-[14px] tracking-[0] leading-[normal] whitespace-nowrap">Most relevant</div>
|
|
17
|
+
<ArrowDown2 color="#292D32" size={14} variant="Outline" className='stroke-[#292D32]' />
|
|
18
|
+
</div>
|
|
11
19
|
</div>
|
|
12
20
|
</div>
|
|
13
21
|
</>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import cn from 'classnames';
|
|
3
3
|
|
|
4
4
|
const Tabs = (props) => {
|
|
5
5
|
const {
|
|
@@ -11,14 +11,16 @@ const Tabs = (props) => {
|
|
|
11
11
|
tabContentContainerClassName = '',
|
|
12
12
|
tabContentWrapperClassName = '',
|
|
13
13
|
tabActiveClassName = '',
|
|
14
|
+
tabWrapperClassName = '',
|
|
14
15
|
} = props
|
|
15
16
|
|
|
16
17
|
const [activeTabs, setActiveTabs] = React.useState(0);
|
|
17
|
-
const rootClass =
|
|
18
|
-
const tabTitleClass =
|
|
19
|
-
const tabContainerClass =
|
|
20
|
-
const tabContentWrapperClass =
|
|
21
|
-
const tabActiveClass =
|
|
18
|
+
const rootClass = cn('mb-4 border-b border-gray-100', rootClassName);
|
|
19
|
+
const tabTitleClass = cn('inline-block p-[10px] rounded-t-lg text-[16px] font-semibold', tabTitleClassName);
|
|
20
|
+
const tabContainerClass = cn('tab-content-container', tabContentContainerClassName);
|
|
21
|
+
const tabContentWrapperClass = cn('tab-content-wrapper', tabContentWrapperClassName);
|
|
22
|
+
const tabActiveClass = cn('border-solid border-b-2', tabActiveClassName);
|
|
23
|
+
const tabWrapperClass = cn('flex flex-wrap -mb-px text-sm font-medium text-center gap-4', tabWrapperClassName);
|
|
22
24
|
|
|
23
25
|
const handleSwicthTab = (index) => {
|
|
24
26
|
setActiveTabs(index);
|
|
@@ -27,11 +29,11 @@ const Tabs = (props) => {
|
|
|
27
29
|
return (
|
|
28
30
|
<>
|
|
29
31
|
<div className={rootClass}>
|
|
30
|
-
<ul className=
|
|
32
|
+
<ul className={tabWrapperClass} role='tablist'>
|
|
31
33
|
{data.map((item, index) => (
|
|
32
34
|
<li className='me-2' role='presentation'>
|
|
33
35
|
<button
|
|
34
|
-
className={
|
|
36
|
+
className={cn(tabTitleClass, index === activeTabs ? tabActiveClass : '')}
|
|
35
37
|
id={item.id}
|
|
36
38
|
role='tab'
|
|
37
39
|
aria-controls={`${item.id}-tab`}
|
|
@@ -50,7 +52,7 @@ const Tabs = (props) => {
|
|
|
50
52
|
{hasContent ? (
|
|
51
53
|
<div className={tabContainerClass}>
|
|
52
54
|
{data.map((item, index) => (
|
|
53
|
-
<div className={
|
|
55
|
+
<div className={cn(index !== activeTabs ? 'hidden' : '', tabContentWrapperClass)} role='tabpanel' aria-labelledby={`${item.id}-tab`}>
|
|
54
56
|
{item.content}
|
|
55
57
|
</div>
|
|
56
58
|
))}
|
|
@@ -19,8 +19,9 @@ import BecomeSellerLink from '@riosst100/pwa-marketplace/src/components/BecomeSe
|
|
|
19
19
|
import MegaMenu from '@magento/venia-ui/lib/components/MegaMenu';
|
|
20
20
|
import PageLoadingIndicator from '@magento/venia-ui/lib/components/PageLoadingIndicator';
|
|
21
21
|
import { useIntl } from 'react-intl';
|
|
22
|
-
|
|
23
|
-
const SearchBar = React.lazy(() => import('@magento/venia-ui/lib/components/SearchBar'));
|
|
22
|
+
import cn from 'classnames';
|
|
23
|
+
// const SearchBar = React.lazy(() => import('@magento/venia-ui/lib/components/SearchBar'));
|
|
24
|
+
const SearchBar = React.lazy(() => import('@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/SearchBar'));
|
|
24
25
|
|
|
25
26
|
const Header = props => {
|
|
26
27
|
const {
|
|
@@ -45,19 +46,20 @@ const Header = props => {
|
|
|
45
46
|
</div>
|
|
46
47
|
</div>
|
|
47
48
|
);
|
|
48
|
-
const searchBar = isSearchOpen ? (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
) : null;
|
|
49
|
+
// const searchBar = isSearchOpen ? (
|
|
50
|
+
// <Suspense fallback={searchBarFallback}>
|
|
51
|
+
// <Route>
|
|
52
|
+
// <SearchBar isOpen={true} ref={searchRef} />
|
|
53
|
+
// </Route>
|
|
54
|
+
// </Suspense>
|
|
55
|
+
// ) : null;
|
|
55
56
|
|
|
56
57
|
const { formatMessage } = useIntl();
|
|
57
58
|
const title = formatMessage({ id: 'logo.title', defaultMessage: 'Venia' });
|
|
58
59
|
|
|
59
60
|
return (
|
|
60
61
|
<Fragment>
|
|
62
|
+
<PageLoadingIndicator absolute />
|
|
61
63
|
<div className={classes.switchersContainer}>
|
|
62
64
|
<div className={classes.switchers} data-cy="Header-switchers">
|
|
63
65
|
<BecomeSellerLink />
|
|
@@ -66,33 +68,43 @@ const Header = props => {
|
|
|
66
68
|
<CurrencySwitcher />
|
|
67
69
|
</div>
|
|
68
70
|
</div>
|
|
69
|
-
<header className={rootClass} data-cy="Header-root">
|
|
70
|
-
<div className={
|
|
71
|
-
<div className={
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<
|
|
71
|
+
<header className={cn(rootClass, '!flex flex-col !px-0 border-gray-100 ')} data-cy="Header-root">
|
|
72
|
+
<div className={cn('middle-header border-b border-gray-100')}>
|
|
73
|
+
<div className={cn('w-full max-w-[1210px] px-[15px] py-[20px] mx-[auto] flex justify-between items-center')}>
|
|
74
|
+
<div className='flex'>
|
|
75
|
+
<NavTrigger />
|
|
76
|
+
<Link
|
|
77
|
+
aria-label={title}
|
|
78
|
+
to={resourceUrl('/')}
|
|
79
|
+
className={''}
|
|
80
|
+
data-cy="Header-logoContainer"
|
|
81
|
+
>
|
|
82
|
+
<div><b>TCG Collective</b></div>
|
|
83
|
+
<small>Toys | Card | Games</small>
|
|
84
|
+
</Link>
|
|
85
|
+
</div>
|
|
86
|
+
<div className='flex'>
|
|
87
|
+
<Suspense fallback={searchBarFallback}>
|
|
88
|
+
<Route>
|
|
89
|
+
<SearchBar isOpen={true} ref={searchRef} />
|
|
90
|
+
</Route>
|
|
91
|
+
</Suspense>
|
|
92
|
+
</div>
|
|
93
|
+
<div className={classes.secondaryActions}>
|
|
94
|
+
{/* <SearchTrigger
|
|
95
|
+
onClick={handleSearchTriggerClick}
|
|
96
|
+
ref={searchTriggerRef}
|
|
97
|
+
/> */}
|
|
98
|
+
<AccountTrigger />
|
|
99
|
+
<CartTrigger />
|
|
100
|
+
</div>
|
|
92
101
|
</div>
|
|
93
102
|
</div>
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
<MegaMenu
|
|
104
|
+
rootClassName={cn('nav-menu w-full max-w-[1210px] px-[15px] mx-[auto] flex-row gap-x-[40px]')}
|
|
105
|
+
megaMenuItemClassname={cn('px-0 py-[15px] leading-[20px]')}
|
|
106
|
+
titleClassName={cn('font-medium leading-[20px]')}
|
|
107
|
+
/>
|
|
96
108
|
</header>
|
|
97
109
|
<OnlineIndicator
|
|
98
110
|
hasBeenOffline={hasBeenOffline}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
5
|
+
import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
|
|
6
|
+
|
|
7
|
+
import MegaMenu from '../megaMenu';
|
|
8
|
+
|
|
9
|
+
jest.mock('@magento/venia-ui/lib/classify');
|
|
10
|
+
jest.mock('@magento/peregrine/lib/hooks/useIsInViewport');
|
|
11
|
+
jest.mock('@magento/peregrine/lib/talons/MegaMenu/useMegaMenu', () => ({
|
|
12
|
+
useMegaMenu: jest.fn().mockReturnValue({
|
|
13
|
+
megaMenuData: {
|
|
14
|
+
id: 1,
|
|
15
|
+
name: 'Clothing',
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
id: 2,
|
|
19
|
+
name: 'Women',
|
|
20
|
+
url_path: 'women',
|
|
21
|
+
children: [
|
|
22
|
+
{
|
|
23
|
+
id: 5,
|
|
24
|
+
name: 'Bottoms',
|
|
25
|
+
url_path: 'bottoms',
|
|
26
|
+
isActive: true,
|
|
27
|
+
children: []
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 3,
|
|
33
|
+
name: 'Men',
|
|
34
|
+
url_path: 'men',
|
|
35
|
+
children: []
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 4,
|
|
39
|
+
name: 'Gear',
|
|
40
|
+
url_path: 'gear',
|
|
41
|
+
children: []
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
activeCategoryId: 5,
|
|
46
|
+
categoryUrlSuffix: '.html',
|
|
47
|
+
useOutsideAlerter: () => {}
|
|
48
|
+
})
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
describe('#MegaMenu', () => {
|
|
52
|
+
test('useEffect', () => {
|
|
53
|
+
const useEffect = jest.spyOn(React, 'useEffect');
|
|
54
|
+
|
|
55
|
+
const mockUseEffect = () => {
|
|
56
|
+
useEffect.mockImplementationOnce(mockFunction => mockFunction());
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
mockUseEffect();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('not resetting the menu', () => {
|
|
63
|
+
const handleClickOutside = jest.fn();
|
|
64
|
+
|
|
65
|
+
expect(handleClickOutside).toHaveBeenCalledTimes(0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('renders empty div if not in viewport', () => {
|
|
69
|
+
useIsInViewport.mockReturnValue(false);
|
|
70
|
+
|
|
71
|
+
const instance = createTestInstance(
|
|
72
|
+
<MemoryRouter>
|
|
73
|
+
<MegaMenu />
|
|
74
|
+
</MemoryRouter>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('renders menu if in viewport', () => {
|
|
81
|
+
useIsInViewport.mockReturnValue(true);
|
|
82
|
+
|
|
83
|
+
const instance = createTestInstance(
|
|
84
|
+
<MemoryRouter>
|
|
85
|
+
<MegaMenu />
|
|
86
|
+
</MemoryRouter>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { act } from 'react-test-renderer';
|
|
4
|
+
|
|
5
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
6
|
+
|
|
7
|
+
import MegaMenuItem from '../megaMenuItem';
|
|
8
|
+
|
|
9
|
+
jest.mock('../../../classify');
|
|
10
|
+
jest.mock('../../Icon', () => props => <mock-Icon {...props} />);
|
|
11
|
+
jest.mock('../submenu', () => props => <mock-Submenu {...props} />);
|
|
12
|
+
jest.mock('react', () => {
|
|
13
|
+
const React = jest.requireActual('react');
|
|
14
|
+
const memoSpy = jest.spyOn(React, 'useMemo');
|
|
15
|
+
|
|
16
|
+
return Object.assign(React, {
|
|
17
|
+
useMemo: memoSpy
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const mockHandleKeyDown = jest.fn();
|
|
22
|
+
|
|
23
|
+
jest.mock('react-router-dom', () => ({
|
|
24
|
+
Link: jest.fn(() => props => <mock-Link {...props} />)
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
jest.mock('@magento/peregrine/lib/talons/MegaMenu/useMegaMenuItem', () => ({
|
|
28
|
+
useMegaMenuItem: jest.fn(() => {
|
|
29
|
+
return {
|
|
30
|
+
isFocused: false,
|
|
31
|
+
isActive: false,
|
|
32
|
+
handleMenuItemFocus: jest.fn(),
|
|
33
|
+
handleCloseSubMenu: jest.fn(),
|
|
34
|
+
isMenuActive: false,
|
|
35
|
+
handleKeyDown: mockHandleKeyDown
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
let inputProps = {};
|
|
41
|
+
|
|
42
|
+
const Component = () => {
|
|
43
|
+
return <MegaMenuItem {...inputProps} />;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const givenDefaultValues = () => {
|
|
47
|
+
inputProps = {
|
|
48
|
+
activeCategoryId: 1,
|
|
49
|
+
category: {
|
|
50
|
+
id: 1,
|
|
51
|
+
name: 'Women',
|
|
52
|
+
url_path: 'women',
|
|
53
|
+
isActive: true,
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
id: 2,
|
|
57
|
+
name: 'Bottoms',
|
|
58
|
+
url_path: 'bottoms',
|
|
59
|
+
children: []
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 3,
|
|
63
|
+
name: 'Tops',
|
|
64
|
+
url_path: 'tops',
|
|
65
|
+
isActive: false,
|
|
66
|
+
children: []
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
rootCategoryName: 'Clothing',
|
|
71
|
+
categoryUrlSuffix: '.html',
|
|
72
|
+
mainNavWidth: 200,
|
|
73
|
+
subMenuState: 'test',
|
|
74
|
+
disableFocus: false
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
describe('Mega menu item renders correctly', () => {
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
givenDefaultValues();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('it renders correctly', () => {
|
|
84
|
+
const instance = createTestInstance(<Component />);
|
|
85
|
+
|
|
86
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('it marks the active category', () => {
|
|
90
|
+
const { root } = createTestInstance(<Component />);
|
|
91
|
+
|
|
92
|
+
expect(root.findByType(Link).props.className).toEqual('megaMenuLink');
|
|
93
|
+
expect(root.findByType(Link).props.to).toEqual('/women.html');
|
|
94
|
+
expect(root.findByType(Link).props.children[0]).toEqual('Women');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should call a11yClick', () => {
|
|
98
|
+
const { root } = createTestInstance(<Component />);
|
|
99
|
+
|
|
100
|
+
act(() => {
|
|
101
|
+
root.findByType(Link).props.onKeyDown();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(mockHandleKeyDown).toHaveBeenCalled();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('it does not render submenu when item does not have children', () => {
|
|
108
|
+
const categoryWithoutChildren = {
|
|
109
|
+
id: 3,
|
|
110
|
+
name: 'Tops',
|
|
111
|
+
url_path: 'tops',
|
|
112
|
+
isActive: false,
|
|
113
|
+
children: []
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const instance = createTestInstance(
|
|
117
|
+
<Component category={categoryWithoutChildren} />
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(instance.toJSON().children.length).toEqual(1);
|
|
121
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import Submenu from '../submenu';
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../classify');
|
|
8
|
+
jest.mock('../submenuColumn', () => props => <mock-SubmenuColumn {...props} />);
|
|
9
|
+
jest.mock('react', () => {
|
|
10
|
+
const React = jest.requireActual('react');
|
|
11
|
+
const callbackSpy = jest.spyOn(React, 'useCallback');
|
|
12
|
+
|
|
13
|
+
return Object.assign(React, {
|
|
14
|
+
callbackSpy: callbackSpy
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const handleCloseSubMenu = jest.fn().mockName('handleCloseSubMenu');
|
|
19
|
+
|
|
20
|
+
describe('Submenu renders correctly', () => {
|
|
21
|
+
const props = {
|
|
22
|
+
items: [
|
|
23
|
+
{
|
|
24
|
+
id: 1,
|
|
25
|
+
name: 'Bottoms',
|
|
26
|
+
url_path: 'bottoms',
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
id: 3,
|
|
30
|
+
name: 'Pants',
|
|
31
|
+
url_path: 'pants',
|
|
32
|
+
isActive: false,
|
|
33
|
+
children: []
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 2,
|
|
39
|
+
name: 'Tops',
|
|
40
|
+
url_path: 'tops',
|
|
41
|
+
isActive: false,
|
|
42
|
+
children: []
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
rootCategoryName: 'Clothing',
|
|
46
|
+
firstLevelCategoryName: 'Women',
|
|
47
|
+
categoryUrlSuffix: '.html',
|
|
48
|
+
handleCloseSubMenu,
|
|
49
|
+
isFocused: false,
|
|
50
|
+
subMenuState: false
|
|
51
|
+
};
|
|
52
|
+
test('it renders correctly', () => {
|
|
53
|
+
const instance = createTestInstance(
|
|
54
|
+
<MemoryRouter>
|
|
55
|
+
<Submenu {...props} />
|
|
56
|
+
</MemoryRouter>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import SubmenuColumn from '../submenuColumn';
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../classify');
|
|
8
|
+
|
|
9
|
+
describe('Submenu column renders correctly', () => {
|
|
10
|
+
const props = {
|
|
11
|
+
category: {
|
|
12
|
+
id: 1,
|
|
13
|
+
name: 'Pants',
|
|
14
|
+
url_path: 'pants',
|
|
15
|
+
children: [
|
|
16
|
+
{
|
|
17
|
+
id: 2,
|
|
18
|
+
name: 'Jeans',
|
|
19
|
+
url_path: 'jeans',
|
|
20
|
+
isActive: true,
|
|
21
|
+
children: []
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
categoryUrlSuffix: '.html'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
test('it renders correctly', () => {
|
|
29
|
+
const instance = createTestInstance(
|
|
30
|
+
<MemoryRouter>
|
|
31
|
+
<SubmenuColumn {...props} />
|
|
32
|
+
</MemoryRouter>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('it renders active state', () => {
|
|
39
|
+
const instance = createTestInstance(
|
|
40
|
+
<MemoryRouter>
|
|
41
|
+
<SubmenuColumn {...props} />
|
|
42
|
+
</MemoryRouter>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const activeLink = instance.root.findByProps({
|
|
46
|
+
className: 'linkActive'
|
|
47
|
+
});
|
|
48
|
+
expect(activeLink.props.children).toEqual('Jeans');
|
|
49
|
+
});
|
|
50
|
+
});
|