@riosst100/pwa-marketplace 1.2.5 → 1.2.7

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 (129) hide show
  1. package/.github/workflows/dependabot.yml +28 -28
  2. package/package.json +18 -18
  3. package/src/Utilities/graphQL.js +76 -76
  4. package/src/componentOverrideMapping.js +17 -17
  5. package/src/components/BecomeSeller/becomeSeller.js +335 -335
  6. package/src/components/BecomeSeller/becomeSeller.module.css +46 -46
  7. package/src/components/BecomeSellerLink/becomeSellerLink.js +52 -52
  8. package/src/components/BecomeSellerLink/becomeSellerLink.module.css +12 -12
  9. package/src/components/BecomeSellerPage/becomeSellerPage.js +45 -45
  10. package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -21
  11. package/src/components/Filter/index.js +53 -53
  12. package/src/components/Header/becomeSellerLink.js +28 -28
  13. package/src/components/Header/becomeSellerLink.module.css +12 -12
  14. package/src/components/Header/websiteSwitcher.js +109 -109
  15. package/src/components/Pagination/index.js +49 -49
  16. package/src/components/PhoneTextInput/phoneTextInput.module.css +21 -21
  17. package/src/components/ProductItem/index.js +50 -50
  18. package/src/components/Search/index.js +16 -16
  19. package/src/components/Seller/index.js +1 -1
  20. package/src/components/Seller/seller.js +249 -250
  21. package/src/components/SellerAccountPage/sellerAccountPage.js +110 -110
  22. package/src/components/SellerAccountPage/sellerAccountPage.module.css +55 -55
  23. package/src/components/SellerCountry/sellerCountry.gql.js +11 -11
  24. package/src/components/SellerInformation/index.js +1 -1
  25. package/src/components/SellerInformation/sellerInformation.js +90 -118
  26. package/src/components/SellerLocation/index.js +1 -1
  27. package/src/components/SellerLocation/sellerLocation.js +19 -23
  28. package/src/components/SellerLocation/sellerLocationItem.js +27 -25
  29. package/src/components/SellerPage/sellerPage.js +9 -9
  30. package/src/components/SellerProducts/sellerProducts.js +47 -67
  31. package/src/components/SellerReview/index.js +1 -1
  32. package/src/components/SellerReview/sellerReview.js +143 -143
  33. package/src/components/SellerReviewItem/sellerReviewItem.js +60 -60
  34. package/src/components/SellerVerification/sellerVerification.js +198 -198
  35. package/src/components/SellerVerification/sellerVerification.module.css +47 -47
  36. package/src/components/SellerVerificationPage/sellerVerificationPage.js +43 -43
  37. package/src/components/SellerVerificationPage/sellerVerificationPage.module.css +21 -21
  38. package/src/components/SortBy/index.js +24 -24
  39. package/src/components/WebsiteSwitcher/websiteSwitcher.js +109 -109
  40. package/src/components/commons/Slider/index.js +13 -13
  41. package/src/components/commons/Tabs/index.js +64 -64
  42. package/src/index.js +6 -6
  43. package/src/intercept.js +113 -113
  44. package/src/moduleOverrideWebpackPlugin.js +70 -70
  45. package/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js +96 -96
  46. package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +74 -74
  47. package/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js +208 -208
  48. package/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js +45 -45
  49. package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +204 -204
  50. package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -102
  51. package/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js +56 -56
  52. package/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js +226 -226
  53. package/src/overwrites/peregrine/lib/util/deriveErrorMessage.js +34 -34
  54. package/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql +11 -11
  55. package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +112 -112
  56. package/src/overwrites/venia-ui/lib/components/Header/header.js +130 -130
  57. package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +105 -105
  58. package/src/overwrites/venia-ui/lib/components/Header/switcherItem.js +47 -47
  59. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -91
  60. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -123
  61. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -61
  62. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -50
  63. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -114
  64. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -71
  65. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -59
  66. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -34
  67. package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -1
  68. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -90
  69. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -12
  70. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -156
  71. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +30 -30
  72. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -89
  73. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +42 -42
  74. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -99
  75. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -28
  76. package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -11
  77. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -72
  78. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -30
  79. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -69
  80. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -7
  81. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -12
  82. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -52
  83. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -82
  84. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -87
  85. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -45
  86. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -43
  87. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -45
  88. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -110
  89. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -172
  90. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -62
  91. package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -1
  92. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -74
  93. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +49 -49
  94. package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -40
  95. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -48
  96. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -13
  97. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -49
  98. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -97
  99. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -24
  100. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -43
  101. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -13
  102. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -75
  103. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -6
  104. package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +75 -75
  105. package/src/overwrites/venia-ui/lib/targets/venia-ui-intercept.js +70 -70
  106. package/src/queries/getAvailableWebsitesConfigData.graphql +14 -14
  107. package/src/queries/index.js +30 -30
  108. package/src/talons/BecomeSeller/becomeSeller.gql.js +45 -45
  109. package/src/talons/BecomeSeller/useBecomeSeller.js +145 -145
  110. package/src/talons/BecomeSellerLink/useBecomeSellerLink.js +11 -11
  111. package/src/talons/BecomeSellerPage/useBecomeSellerPage.js +76 -76
  112. package/src/talons/Header/useBecomeSellerLink.js +13 -13
  113. package/src/talons/Header/useWebsiteSwitcher.js +218 -218
  114. package/src/talons/Seller/seller.gql.js +139 -204
  115. package/src/talons/Seller/useSeller.js +66 -71
  116. package/src/talons/SellerAccountPage/useSellerAccountPage.js +174 -174
  117. package/src/talons/SellerCountry/useSellerCountry.js +25 -25
  118. package/src/talons/WebsiteByIp/getWebsiteByIp.gql.js +13 -13
  119. package/src/talons/WebsiteByIp/useWebsiteByIp.js +34 -34
  120. package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +218 -218
  121. package/src/theme/vars.js +6 -6
  122. package/src/util/mapSeller.js +7 -7
  123. package/src/components/OperatingHours/index.js +0 -1
  124. package/src/components/OperatingHours/operatingHours.js +0 -32
  125. package/src/components/Seller/sellerAddressCard.js +0 -48
  126. package/src/components/SellerDetail/index.js +0 -1
  127. package/src/components/SellerDetail/sellerDetail.js +0 -158
  128. package/src/components/SellerPage/core.js +0 -10
  129. package/src/talons/SellerProducts/useSellerProducts.js +0 -129
@@ -1,72 +1,72 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`renders correctly 1`] = `
4
- <form
5
- onKeyDown={[Function]}
6
- onReset={[Function]}
7
- onSubmit={[Function]}
8
- >
9
- <span
10
- className="root"
11
- style={
12
- Object {
13
- "--iconsAfter": 0,
14
- "--iconsBefore": 1,
15
- }
16
- }
17
- >
18
- <span
19
- className="input"
20
- >
21
- <input
22
- className="input"
23
- id="search_query"
24
- name="search_query"
25
- onBlur={[Function]}
26
- onChange={[Function]}
27
- onFocus={[MockFunction]}
28
- value=""
29
- />
30
- </span>
31
- <span
32
- className="before"
33
- >
34
- <span
35
- className="root"
36
- >
37
- <svg
38
- className="icon"
39
- fill="none"
40
- height={24}
41
- stroke="currentColor"
42
- strokeLinecap="round"
43
- strokeLinejoin="round"
44
- strokeWidth="2"
45
- viewBox="0 0 24 24"
46
- width={24}
47
- xmlns="http://www.w3.org/2000/svg"
48
- >
49
- <circle
50
- cx="11"
51
- cy="11"
52
- r="8"
53
- />
54
- <line
55
- x1="21"
56
- x2="16.65"
57
- y1="21"
58
- y2="16.65"
59
- />
60
- </svg>
61
- </span>
62
- </span>
63
- <span
64
- aria-hidden="false"
65
- className="after"
66
- />
67
- </span>
68
- <p
69
- className="root"
70
- />
71
- </form>
72
- `;
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders correctly 1`] = `
4
+ <form
5
+ onKeyDown={[Function]}
6
+ onReset={[Function]}
7
+ onSubmit={[Function]}
8
+ >
9
+ <span
10
+ className="root"
11
+ style={
12
+ Object {
13
+ "--iconsAfter": 0,
14
+ "--iconsBefore": 1,
15
+ }
16
+ }
17
+ >
18
+ <span
19
+ className="input"
20
+ >
21
+ <input
22
+ className="input"
23
+ id="search_query"
24
+ name="search_query"
25
+ onBlur={[Function]}
26
+ onChange={[Function]}
27
+ onFocus={[MockFunction]}
28
+ value=""
29
+ />
30
+ </span>
31
+ <span
32
+ className="before"
33
+ >
34
+ <span
35
+ className="root"
36
+ >
37
+ <svg
38
+ className="icon"
39
+ fill="none"
40
+ height={24}
41
+ stroke="currentColor"
42
+ strokeLinecap="round"
43
+ strokeLinejoin="round"
44
+ strokeWidth="2"
45
+ viewBox="0 0 24 24"
46
+ width={24}
47
+ xmlns="http://www.w3.org/2000/svg"
48
+ >
49
+ <circle
50
+ cx="11"
51
+ cy="11"
52
+ r="8"
53
+ />
54
+ <line
55
+ x1="21"
56
+ x2="16.65"
57
+ y1="21"
58
+ y2="16.65"
59
+ />
60
+ </svg>
61
+ </span>
62
+ </span>
63
+ <span
64
+ aria-hidden="false"
65
+ className="after"
66
+ />
67
+ </span>
68
+ <p
69
+ className="root"
70
+ />
71
+ </form>
72
+ `;
@@ -1,30 +1,30 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`renders correctly 1`] = `
4
- <ul>
5
- <li>
6
- <SuggestedCategory
7
- label="A"
8
- value="foo"
9
- />
10
- </li>
11
- <li>
12
- <SuggestedCategory
13
- label="B"
14
- value="foo"
15
- />
16
- </li>
17
- <li>
18
- <SuggestedCategory
19
- label="C"
20
- value="foo"
21
- />
22
- </li>
23
- <li>
24
- <SuggestedCategory
25
- label="D"
26
- value="foo"
27
- />
28
- </li>
29
- </ul>
30
- `;
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders correctly 1`] = `
4
+ <ul>
5
+ <li>
6
+ <SuggestedCategory
7
+ label="A"
8
+ value="foo"
9
+ />
10
+ </li>
11
+ <li>
12
+ <SuggestedCategory
13
+ label="B"
14
+ value="foo"
15
+ />
16
+ </li>
17
+ <li>
18
+ <SuggestedCategory
19
+ label="C"
20
+ value="foo"
21
+ />
22
+ </li>
23
+ <li>
24
+ <SuggestedCategory
25
+ label="D"
26
+ value="foo"
27
+ />
28
+ </li>
29
+ </ul>
30
+ `;
@@ -1,69 +1,69 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`renders a suggestedProduct component 1`] = `
4
- Array [
5
- <div
6
- className="root container"
7
- >
8
- <img
9
- alt="Product Name"
10
- aria-hidden="true"
11
- className="image placeholder"
12
- loading="eager"
13
- src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0JyBoZWlnaHQ9JzUnPjxyZWN0IHdpZHRoPSc0JyBoZWlnaHQ9JzUnIHN0eWxlPSdmaWxsOiBub25lJyAvPjwvc3ZnPg=="
14
- style={
15
- Object {
16
- "--width": "60px",
17
- }
18
- }
19
- width={60}
20
- />
21
- <img
22
- alt="Product Name"
23
- className="image notLoaded"
24
- loading="lazy"
25
- onError={[Function]}
26
- onLoad={[Function]}
27
- sizes="60px"
28
- src="/media/catalog/category/minimalist.jpg"
29
- srcSet="/media/catalog/category/minimalist.jpg 40w,
30
- /media/catalog/category/minimalist.jpg 80w,
31
- /media/catalog/category/minimalist.jpg 160w,
32
- /media/catalog/category/minimalist.jpg 320w,
33
- /media/catalog/category/minimalist.jpg 640w,
34
- /media/catalog/category/minimalist.jpg 960w,
35
- /media/catalog/category/minimalist.jpg 1280w,
36
- /media/catalog/category/minimalist.jpg 1600w,
37
- /media/catalog/category/minimalist.jpg 2560w"
38
- style={
39
- Object {
40
- "--height": "75px",
41
- "--width": "60px",
42
- }
43
- }
44
- width={60}
45
- />
46
- </div>,
47
- <span
48
- className="name"
49
- >
50
- Product Name
51
- </span>,
52
- <span
53
- className="price"
54
- >
55
- <span>
56
- $
57
- </span>
58
- <span>
59
- 3
60
- </span>
61
- <span>
62
- .
63
- </span>
64
- <span>
65
- 50
66
- </span>
67
- </span>,
68
- ]
69
- `;
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders a suggestedProduct component 1`] = `
4
+ Array [
5
+ <div
6
+ className="root container"
7
+ >
8
+ <img
9
+ alt="Product Name"
10
+ aria-hidden="true"
11
+ className="image placeholder"
12
+ loading="eager"
13
+ src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0JyBoZWlnaHQ9JzUnPjxyZWN0IHdpZHRoPSc0JyBoZWlnaHQ9JzUnIHN0eWxlPSdmaWxsOiBub25lJyAvPjwvc3ZnPg=="
14
+ style={
15
+ Object {
16
+ "--width": "60px",
17
+ }
18
+ }
19
+ width={60}
20
+ />
21
+ <img
22
+ alt="Product Name"
23
+ className="image notLoaded"
24
+ loading="lazy"
25
+ onError={[Function]}
26
+ onLoad={[Function]}
27
+ sizes="60px"
28
+ src="/media/catalog/category/minimalist.jpg"
29
+ srcSet="/media/catalog/category/minimalist.jpg 40w,
30
+ /media/catalog/category/minimalist.jpg 80w,
31
+ /media/catalog/category/minimalist.jpg 160w,
32
+ /media/catalog/category/minimalist.jpg 320w,
33
+ /media/catalog/category/minimalist.jpg 640w,
34
+ /media/catalog/category/minimalist.jpg 960w,
35
+ /media/catalog/category/minimalist.jpg 1280w,
36
+ /media/catalog/category/minimalist.jpg 1600w,
37
+ /media/catalog/category/minimalist.jpg 2560w"
38
+ style={
39
+ Object {
40
+ "--height": "75px",
41
+ "--width": "60px",
42
+ }
43
+ }
44
+ width={60}
45
+ />
46
+ </div>,
47
+ <span
48
+ className="name"
49
+ >
50
+ Product Name
51
+ </span>,
52
+ <span
53
+ className="price"
54
+ >
55
+ <span>
56
+ $
57
+ </span>
58
+ <span>
59
+ 3
60
+ </span>
61
+ <span>
62
+ .
63
+ </span>
64
+ <span>
65
+ 50
66
+ </span>
67
+ </span>,
68
+ ]
69
+ `;
@@ -1,7 +1,7 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`renders correctly 1`] = `
4
- <ul>
5
- <li />
6
- </ul>
7
- `;
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders correctly 1`] = `
4
+ <ul>
5
+ <li />
6
+ </ul>
7
+ `;
@@ -1,12 +1,12 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`renders correctly 1`] = `
4
- <h2>
5
- <span>
6
- <mock-FormattedMessage
7
- defaultMessage="Product Suggestions"
8
- id="searchBar.heading"
9
- />
10
- </span>
11
- </h2>
12
- `;
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders correctly 1`] = `
4
+ <h2>
5
+ <span>
6
+ <mock-FormattedMessage
7
+ defaultMessage="Product Suggestions"
8
+ id="searchBar.heading"
9
+ />
10
+ </span>
11
+ </h2>
12
+ `;
@@ -1,52 +1,52 @@
1
- import React from 'react';
2
- import { InMemoryCache } from '@apollo/client';
3
- import { MockedProvider } from '@apollo/client/testing';
4
- import { Form } from 'informed';
5
- import { createTestInstance } from '@magento/peregrine';
6
- import typePolicies from '@magento/peregrine/lib/Apollo/policies';
7
-
8
- import Autocomplete from '../autocomplete';
9
- import { IntlProvider } from 'react-intl';
10
-
11
- jest.mock('../../../classify');
12
- jest.mock('../suggestions', () => () => null);
13
-
14
- jest.mock('@magento/peregrine/lib/context/eventing', () => ({
15
- useEventingContext: jest.fn().mockReturnValue([{}, { dispatch: jest.fn() }])
16
- }));
17
-
18
- const cache = new InMemoryCache({
19
- typePolicies
20
- });
21
-
22
- test('renders correctly', () => {
23
- const { root } = createTestInstance(
24
- <MockedProvider addTypename={true} cache={cache}>
25
- <IntlProvider locale="en-US">
26
- <Form>
27
- <Autocomplete visible={false} />
28
- </Form>
29
- </IntlProvider>
30
- </MockedProvider>
31
- );
32
-
33
- expect(root.findByProps({ className: 'root_hidden' })).toBeTruthy();
34
- expect(root.findByProps({ className: 'message' })).toBeTruthy();
35
- expect(root.findByProps({ className: 'suggestions' })).toBeTruthy();
36
- });
37
-
38
- test('renders correctly when visible', () => {
39
- const { root } = createTestInstance(
40
- <MockedProvider addTypename={true} cache={cache}>
41
- <IntlProvider locale="en-US">
42
- <Form>
43
- <Autocomplete visible={true} />
44
- </Form>
45
- </IntlProvider>
46
- </MockedProvider>
47
- );
48
-
49
- expect(root.findByProps({ className: 'root_visible' })).toBeTruthy();
50
- expect(root.findByProps({ className: 'message' })).toBeTruthy();
51
- expect(root.findByProps({ className: 'suggestions' })).toBeTruthy();
52
- });
1
+ import React from 'react';
2
+ import { InMemoryCache } from '@apollo/client';
3
+ import { MockedProvider } from '@apollo/client/testing';
4
+ import { Form } from 'informed';
5
+ import { createTestInstance } from '@magento/peregrine';
6
+ import typePolicies from '@magento/peregrine/lib/Apollo/policies';
7
+
8
+ import Autocomplete from '../autocomplete';
9
+ import { IntlProvider } from 'react-intl';
10
+
11
+ jest.mock('../../../classify');
12
+ jest.mock('../suggestions', () => () => null);
13
+
14
+ jest.mock('@magento/peregrine/lib/context/eventing', () => ({
15
+ useEventingContext: jest.fn().mockReturnValue([{}, { dispatch: jest.fn() }])
16
+ }));
17
+
18
+ const cache = new InMemoryCache({
19
+ typePolicies
20
+ });
21
+
22
+ test('renders correctly', () => {
23
+ const { root } = createTestInstance(
24
+ <MockedProvider addTypename={true} cache={cache}>
25
+ <IntlProvider locale="en-US">
26
+ <Form>
27
+ <Autocomplete visible={false} />
28
+ </Form>
29
+ </IntlProvider>
30
+ </MockedProvider>
31
+ );
32
+
33
+ expect(root.findByProps({ className: 'root_hidden' })).toBeTruthy();
34
+ expect(root.findByProps({ className: 'message' })).toBeTruthy();
35
+ expect(root.findByProps({ className: 'suggestions' })).toBeTruthy();
36
+ });
37
+
38
+ test('renders correctly when visible', () => {
39
+ const { root } = createTestInstance(
40
+ <MockedProvider addTypename={true} cache={cache}>
41
+ <IntlProvider locale="en-US">
42
+ <Form>
43
+ <Autocomplete visible={true} />
44
+ </Form>
45
+ </IntlProvider>
46
+ </MockedProvider>
47
+ );
48
+
49
+ expect(root.findByProps({ className: 'root_visible' })).toBeTruthy();
50
+ expect(root.findByProps({ className: 'message' })).toBeTruthy();
51
+ expect(root.findByProps({ className: 'suggestions' })).toBeTruthy();
52
+ });
@@ -1,82 +1,82 @@
1
- import React from 'react';
2
- import { useHistory } from 'react-router-dom';
3
-
4
- import { Form } from 'informed';
5
- import { act } from 'react-test-renderer';
6
- import { createTestInstance } from '@magento/peregrine';
7
-
8
- import Autocomplete from '../autocomplete';
9
- import SearchBar from '../searchBar';
10
- import SearchField from '../searchField';
11
-
12
- jest.mock('../../../classify');
13
- jest.mock('../autocomplete', () => () => null);
14
- jest.mock('../searchField', () => () => null);
15
- jest.mock('react-router-dom', () => ({
16
- useHistory: jest.fn(() => ({})),
17
- useLocation: jest.fn(() => ({}))
18
- }));
19
-
20
- const push = jest.fn();
21
- useHistory.mockImplementation(() => ({ push }));
22
-
23
- test('renders correctly', () => {
24
- const { root } = createTestInstance(<SearchBar isOpen={false} />);
25
-
26
- expect(root.findByProps({ className: 'root' })).toBeTruthy();
27
- expect(root.findByProps({ className: 'container' })).toBeTruthy();
28
- expect(root.findByProps({ className: 'form' })).toBeTruthy();
29
- expect(root.findByProps({ className: 'search' })).toBeTruthy();
30
- expect(root.findByProps({ className: 'autocomplete' })).toBeTruthy();
31
- });
32
-
33
- test('sets different classnames when open', () => {
34
- const { root } = createTestInstance(<SearchBar isOpen={true} />);
35
-
36
- expect(root.findAllByProps({ className: 'root' })).toHaveLength(0);
37
- expect(root.findByProps({ className: 'root_open' })).toBeTruthy();
38
- });
39
-
40
- test('expands or collapses on change, depending on the value', () => {
41
- const { root } = createTestInstance(<SearchBar isOpen={false} />);
42
-
43
- expect(root.findByType(Autocomplete).props.visible).toBe(false);
44
-
45
- act(() => {
46
- root.findByType(SearchField).props.onChange('foo');
47
- });
48
-
49
- expect(root.findByType(Autocomplete).props.visible).toBe(true);
50
-
51
- act(() => {
52
- root.findByType(SearchField).props.onChange('');
53
- });
54
-
55
- expect(root.findByType(Autocomplete).props.visible).toBe(false);
56
- });
57
-
58
- test('expands on focus', () => {
59
- const { root } = createTestInstance(<SearchBar isOpen={false} />);
60
-
61
- expect(root.findByType(Autocomplete).props.visible).toBe(false);
62
-
63
- act(() => {
64
- root.findByType(SearchField).props.onFocus();
65
- });
66
-
67
- expect(root.findByType(Autocomplete).props.visible).toBe(true);
68
- });
69
-
70
- test('navigates on submit', () => {
71
- const { root } = createTestInstance(<SearchBar isOpen={false} />);
72
-
73
- const inputString = 'foo';
74
-
75
- act(() => {
76
- root.findByType(Form).props.onSubmit({
77
- search_query: inputString
78
- });
79
- });
80
-
81
- expect(push).toHaveBeenLastCalledWith(`/search.html?query=${inputString}`);
82
- });
1
+ import React from 'react';
2
+ import { useHistory } from 'react-router-dom';
3
+
4
+ import { Form } from 'informed';
5
+ import { act } from 'react-test-renderer';
6
+ import { createTestInstance } from '@magento/peregrine';
7
+
8
+ import Autocomplete from '../autocomplete';
9
+ import SearchBar from '../searchBar';
10
+ import SearchField from '../searchField';
11
+
12
+ jest.mock('../../../classify');
13
+ jest.mock('../autocomplete', () => () => null);
14
+ jest.mock('../searchField', () => () => null);
15
+ jest.mock('react-router-dom', () => ({
16
+ useHistory: jest.fn(() => ({})),
17
+ useLocation: jest.fn(() => ({}))
18
+ }));
19
+
20
+ const push = jest.fn();
21
+ useHistory.mockImplementation(() => ({ push }));
22
+
23
+ test('renders correctly', () => {
24
+ const { root } = createTestInstance(<SearchBar isOpen={false} />);
25
+
26
+ expect(root.findByProps({ className: 'root' })).toBeTruthy();
27
+ expect(root.findByProps({ className: 'container' })).toBeTruthy();
28
+ expect(root.findByProps({ className: 'form' })).toBeTruthy();
29
+ expect(root.findByProps({ className: 'search' })).toBeTruthy();
30
+ expect(root.findByProps({ className: 'autocomplete' })).toBeTruthy();
31
+ });
32
+
33
+ test('sets different classnames when open', () => {
34
+ const { root } = createTestInstance(<SearchBar isOpen={true} />);
35
+
36
+ expect(root.findAllByProps({ className: 'root' })).toHaveLength(0);
37
+ expect(root.findByProps({ className: 'root_open' })).toBeTruthy();
38
+ });
39
+
40
+ test('expands or collapses on change, depending on the value', () => {
41
+ const { root } = createTestInstance(<SearchBar isOpen={false} />);
42
+
43
+ expect(root.findByType(Autocomplete).props.visible).toBe(false);
44
+
45
+ act(() => {
46
+ root.findByType(SearchField).props.onChange('foo');
47
+ });
48
+
49
+ expect(root.findByType(Autocomplete).props.visible).toBe(true);
50
+
51
+ act(() => {
52
+ root.findByType(SearchField).props.onChange('');
53
+ });
54
+
55
+ expect(root.findByType(Autocomplete).props.visible).toBe(false);
56
+ });
57
+
58
+ test('expands on focus', () => {
59
+ const { root } = createTestInstance(<SearchBar isOpen={false} />);
60
+
61
+ expect(root.findByType(Autocomplete).props.visible).toBe(false);
62
+
63
+ act(() => {
64
+ root.findByType(SearchField).props.onFocus();
65
+ });
66
+
67
+ expect(root.findByType(Autocomplete).props.visible).toBe(true);
68
+ });
69
+
70
+ test('navigates on submit', () => {
71
+ const { root } = createTestInstance(<SearchBar isOpen={false} />);
72
+
73
+ const inputString = 'foo';
74
+
75
+ act(() => {
76
+ root.findByType(Form).props.onSubmit({
77
+ search_query: inputString
78
+ });
79
+ });
80
+
81
+ expect(push).toHaveBeenLastCalledWith(`/search.html?query=${inputString}`);
82
+ });