@magento/venia-ui 9.4.0-alpha.1 → 9.5.0-alpha.1

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 (66) hide show
  1. package/i18n/en_US.json +2 -0
  2. package/lib/RootComponents/CMS/__tests__/cms.spec.js +4 -0
  3. package/lib/RootComponents/Category/__tests__/__snapshots__/categoryContent.spec.js.snap +9 -0
  4. package/lib/RootComponents/Category/category.js +19 -1
  5. package/lib/RootComponents/Category/categoryContent.js +1 -1
  6. package/lib/components/AccountInformationPage/__tests__/__snapshots__/accountInformationPage.spec.js.snap +1 -0
  7. package/lib/components/AccountInformationPage/accountInformationPage.js +1 -0
  8. package/lib/components/AddressBookPage/__tests__/__snapshots__/addressBookPage.spec.js.snap +3 -0
  9. package/lib/components/AddressBookPage/addressBookPage.js +5 -1
  10. package/lib/components/AddressBookPage/addressBookPage.module.css +3 -0
  11. package/lib/components/CartPage/__tests__/__snapshots__/cartPage.spec.js.snap +2 -0
  12. package/lib/components/CartPage/cartPage.js +5 -1
  13. package/lib/components/CheckoutPage/AddressBook/__tests__/__snapshots__/addressBook.spec.js.snap +2 -0
  14. package/lib/components/CheckoutPage/AddressBook/addressBook.js +1 -1
  15. package/lib/components/CheckoutPage/GuestSignIn/__tests__/__snapshots__/guestSignIn.spec.js.snap +3 -0
  16. package/lib/components/CheckoutPage/GuestSignIn/guestSignIn.js +1 -1
  17. package/lib/components/CheckoutPage/ItemsReview/itemsReview.js +1 -1
  18. package/lib/components/CheckoutPage/OrderSummary/__tests__/__snapshots__/orderSummary.spec.js.snap +1 -0
  19. package/lib/components/CheckoutPage/OrderSummary/orderSummary.js +1 -1
  20. package/lib/components/CheckoutPage/PaymentInformation/brainTreeDropIn.js +7 -2
  21. package/lib/components/CheckoutPage/__tests__/__snapshots__/checkoutPage.spec.js.snap +1 -0
  22. package/lib/components/CheckoutPage/checkoutPage.js +1 -0
  23. package/lib/components/CreateAccount/__tests__/createAccount.spec.js +4 -0
  24. package/lib/components/Footer/__tests__/__snapshots__/footer.spec.js.snap +1 -0
  25. package/lib/components/Footer/footer.js +8 -2
  26. package/lib/components/Gallery/__tests__/gallery.spec.js +3 -0
  27. package/lib/components/Gallery/__tests__/item.spec.js +3 -0
  28. package/lib/components/Gallery/item.js +16 -4
  29. package/lib/components/Header/__tests__/__snapshots__/cartTrigger.spec.js.snap +6 -0
  30. package/lib/components/Header/__tests__/__snapshots__/currencySwitcher.spec.js.snap +16 -2
  31. package/lib/components/Header/__tests__/__snapshots__/storeSwitcher.spec.js.snap +17 -0
  32. package/lib/components/Header/cartTrigger.js +2 -0
  33. package/lib/components/Header/currencySwitcher.js +8 -2
  34. package/lib/components/Header/header.js +5 -0
  35. package/lib/components/Header/storeSwitcher.js +9 -4
  36. package/lib/components/Logo/logo.js +0 -1
  37. package/lib/components/MiniCart/miniCart.js +1 -0
  38. package/lib/components/MyAccount/ResetPassword/__tests__/__snapshots__/resetPassword.spec.js.snap +12 -4
  39. package/lib/components/MyAccount/ResetPassword/resetPassword.js +1 -1
  40. package/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderHistoryPage.spec.js.snap +5 -0
  41. package/lib/components/OrderHistoryPage/orderHistoryPage.js +3 -1
  42. package/lib/components/PageLoadingIndicator/__tests__/__snapshots__/pageLoadingIndicator.spec.js.snap +21 -0
  43. package/lib/components/PageLoadingIndicator/__tests__/pageLoadingIndicator.spec.js +4 -4
  44. package/lib/components/PageLoadingIndicator/pageLoadingIndicator.js +6 -2
  45. package/lib/components/PageLoadingIndicator/pageLoadingIndicator.module.css +6 -1
  46. package/lib/components/ProductFullDetail/__tests__/__snapshots__/productFullDetail.spec.js.snap +104 -91
  47. package/lib/components/ProductFullDetail/productFullDetail.js +4 -3
  48. package/lib/components/ProductFullDetail/productFullDetail.module.css +8 -5
  49. package/lib/components/SavedPaymentsPage/__tests__/__snapshots__/savedPaymentsPage.spec.js.snap +2 -0
  50. package/lib/components/SavedPaymentsPage/savedPaymentsPage.js +3 -1
  51. package/lib/components/SearchBar/__tests__/autocomplete.spec.js +25 -10
  52. package/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +3 -0
  53. package/lib/components/SearchBar/autocomplete.js +4 -0
  54. package/lib/components/SearchBar/suggestedProduct.js +29 -16
  55. package/lib/components/SearchPage/__tests__/__snapshots__/searchPage.spec.js.snap +22 -0
  56. package/lib/components/SearchPage/searchPage.js +11 -3
  57. package/lib/components/SignIn/__tests__/signIn.spec.js +4 -0
  58. package/lib/components/SortedByContainer/sortedByContainer.module.css +0 -2
  59. package/lib/components/StoreCodeRoute/__tests__/storeCodeRoute.spec.js +2 -2
  60. package/lib/components/StoreCodeRoute/storeCodeRoute.js +3 -3
  61. package/lib/components/WishlistPage/__tests__/__snapshots__/wishlistPage.spec.js.snap +5 -0
  62. package/lib/components/WishlistPage/wishlistPage.js +5 -1
  63. package/lib/index.module.css +14 -0
  64. package/lib/targets/__tests__/venia-ui-targets.spec.js +2 -2
  65. package/lib/tokens.module.css +1 -1
  66. package/package.json +6 -6
@@ -7,10 +7,18 @@ exports[`it disables the add to cart button when the talon indicates 1`] = `
7
7
  onReset={[Function]}
8
8
  onSubmit={[Function]}
9
9
  >
10
+ <section
11
+ className="imageCarousel"
12
+ >
13
+ <ProductImageCarousel
14
+ images={Array []}
15
+ />
16
+ </section>
10
17
  <section
11
18
  className="title"
12
19
  >
13
20
  <h1
21
+ aria-live="polite"
14
22
  className="productName"
15
23
  >
16
24
  Flux Capacitor
@@ -32,13 +40,6 @@ exports[`it disables the add to cart button when the talon indicates 1`] = `
32
40
  </span>
33
41
  </p>
34
42
  </section>
35
- <section
36
- className="imageCarousel"
37
- >
38
- <ProductImageCarousel
39
- images={Array []}
40
- />
41
- </section>
42
43
  <FormError
43
44
  classes={
44
45
  Object {
@@ -182,10 +183,18 @@ exports[`it does not render options if the product is not a ConfigurableProduct
182
183
  onReset={[Function]}
183
184
  onSubmit={[Function]}
184
185
  >
186
+ <section
187
+ className="imageCarousel"
188
+ >
189
+ <ProductImageCarousel
190
+ images={Array []}
191
+ />
192
+ </section>
185
193
  <section
186
194
  className="title"
187
195
  >
188
196
  <h1
197
+ aria-live="polite"
189
198
  className="productName"
190
199
  >
191
200
  Flux Capacitor
@@ -207,13 +216,6 @@ exports[`it does not render options if the product is not a ConfigurableProduct
207
216
  </span>
208
217
  </p>
209
218
  </section>
210
- <section
211
- className="imageCarousel"
212
- >
213
- <ProductImageCarousel
214
- images={Array []}
215
- />
216
- </section>
217
219
  <FormError
218
220
  classes={
219
221
  Object {
@@ -327,10 +329,18 @@ exports[`it renders an error for an invalid cart 1`] = `
327
329
  onReset={[Function]}
328
330
  onSubmit={[Function]}
329
331
  >
332
+ <section
333
+ className="imageCarousel"
334
+ >
335
+ <ProductImageCarousel
336
+ images={Array []}
337
+ />
338
+ </section>
330
339
  <section
331
340
  className="title"
332
341
  >
333
342
  <h1
343
+ aria-live="polite"
334
344
  className="productName"
335
345
  >
336
346
  Flux Capacitor
@@ -352,13 +362,6 @@ exports[`it renders an error for an invalid cart 1`] = `
352
362
  </span>
353
363
  </p>
354
364
  </section>
355
- <section
356
- className="imageCarousel"
357
- >
358
- <ProductImageCarousel
359
- images={Array []}
360
- />
361
- </section>
362
365
  <FormError
363
366
  classes={
364
367
  Object {
@@ -506,10 +509,18 @@ exports[`it renders an error for an invalid user token when adding to cart 1`] =
506
509
  onReset={[Function]}
507
510
  onSubmit={[Function]}
508
511
  >
512
+ <section
513
+ className="imageCarousel"
514
+ >
515
+ <ProductImageCarousel
516
+ images={Array []}
517
+ />
518
+ </section>
509
519
  <section
510
520
  className="title"
511
521
  >
512
522
  <h1
523
+ aria-live="polite"
513
524
  className="productName"
514
525
  >
515
526
  Flux Capacitor
@@ -531,13 +542,6 @@ exports[`it renders an error for an invalid user token when adding to cart 1`] =
531
542
  </span>
532
543
  </p>
533
544
  </section>
534
- <section
535
- className="imageCarousel"
536
- >
537
- <ProductImageCarousel
538
- images={Array []}
539
- />
540
- </section>
541
545
  <FormError
542
546
  classes={
543
547
  Object {
@@ -690,10 +694,18 @@ Array [
690
694
  onReset={[Function]}
691
695
  onSubmit={[Function]}
692
696
  >
697
+ <section
698
+ className="imageCarousel"
699
+ >
700
+ <ProductImageCarousel
701
+ images={Array []}
702
+ />
703
+ </section>
693
704
  <section
694
705
  className="title"
695
706
  >
696
707
  <h1
708
+ aria-live="polite"
697
709
  className="productName"
698
710
  >
699
711
  Flux Capacitor
@@ -715,13 +727,6 @@ Array [
715
727
  </span>
716
728
  </p>
717
729
  </section>
718
- <section
719
- className="imageCarousel"
720
- >
721
- <ProductImageCarousel
722
- images={Array []}
723
- />
724
- </section>
725
730
  <FormError
726
731
  classes={
727
732
  Object {
@@ -866,10 +871,18 @@ exports[`it renders correctly 1`] = `
866
871
  onReset={[Function]}
867
872
  onSubmit={[Function]}
868
873
  >
874
+ <section
875
+ className="imageCarousel"
876
+ >
877
+ <ProductImageCarousel
878
+ images={Array []}
879
+ />
880
+ </section>
869
881
  <section
870
882
  className="title"
871
883
  >
872
884
  <h1
885
+ aria-live="polite"
873
886
  className="productName"
874
887
  >
875
888
  Flux Capacitor
@@ -891,13 +904,6 @@ exports[`it renders correctly 1`] = `
891
904
  </span>
892
905
  </p>
893
906
  </section>
894
- <section
895
- className="imageCarousel"
896
- >
897
- <ProductImageCarousel
898
- images={Array []}
899
- />
900
- </section>
901
907
  <FormError
902
908
  classes={
903
909
  Object {
@@ -1041,10 +1047,18 @@ exports[`it renders field level errors for quantity - message 1 1`] = `
1041
1047
  onReset={[Function]}
1042
1048
  onSubmit={[Function]}
1043
1049
  >
1050
+ <section
1051
+ className="imageCarousel"
1052
+ >
1053
+ <ProductImageCarousel
1054
+ images={Array []}
1055
+ />
1056
+ </section>
1044
1057
  <section
1045
1058
  className="title"
1046
1059
  >
1047
1060
  <h1
1061
+ aria-live="polite"
1048
1062
  className="productName"
1049
1063
  >
1050
1064
  Flux Capacitor
@@ -1066,13 +1080,6 @@ exports[`it renders field level errors for quantity - message 1 1`] = `
1066
1080
  </span>
1067
1081
  </p>
1068
1082
  </section>
1069
- <section
1070
- className="imageCarousel"
1071
- >
1072
- <ProductImageCarousel
1073
- images={Array []}
1074
- />
1075
- </section>
1076
1083
  <FormError
1077
1084
  classes={
1078
1085
  Object {
@@ -1216,10 +1223,18 @@ exports[`it renders field level errors for quantity - message 2 1`] = `
1216
1223
  onReset={[Function]}
1217
1224
  onSubmit={[Function]}
1218
1225
  >
1226
+ <section
1227
+ className="imageCarousel"
1228
+ >
1229
+ <ProductImageCarousel
1230
+ images={Array []}
1231
+ />
1232
+ </section>
1219
1233
  <section
1220
1234
  className="title"
1221
1235
  >
1222
1236
  <h1
1237
+ aria-live="polite"
1223
1238
  className="productName"
1224
1239
  >
1225
1240
  Flux Capacitor
@@ -1241,13 +1256,6 @@ exports[`it renders field level errors for quantity - message 2 1`] = `
1241
1256
  </span>
1242
1257
  </p>
1243
1258
  </section>
1244
- <section
1245
- className="imageCarousel"
1246
- >
1247
- <ProductImageCarousel
1248
- images={Array []}
1249
- />
1250
- </section>
1251
1259
  <FormError
1252
1260
  classes={
1253
1261
  Object {
@@ -1391,10 +1399,18 @@ exports[`it renders field level errors for quantity - message 3 1`] = `
1391
1399
  onReset={[Function]}
1392
1400
  onSubmit={[Function]}
1393
1401
  >
1402
+ <section
1403
+ className="imageCarousel"
1404
+ >
1405
+ <ProductImageCarousel
1406
+ images={Array []}
1407
+ />
1408
+ </section>
1394
1409
  <section
1395
1410
  className="title"
1396
1411
  >
1397
1412
  <h1
1413
+ aria-live="polite"
1398
1414
  className="productName"
1399
1415
  >
1400
1416
  Flux Capacitor
@@ -1416,13 +1432,6 @@ exports[`it renders field level errors for quantity - message 3 1`] = `
1416
1432
  </span>
1417
1433
  </p>
1418
1434
  </section>
1419
- <section
1420
- className="imageCarousel"
1421
- >
1422
- <ProductImageCarousel
1423
- images={Array []}
1424
- />
1425
- </section>
1426
1435
  <FormError
1427
1436
  classes={
1428
1437
  Object {
@@ -1566,10 +1575,18 @@ exports[`it renders form level errors 1`] = `
1566
1575
  onReset={[Function]}
1567
1576
  onSubmit={[Function]}
1568
1577
  >
1578
+ <section
1579
+ className="imageCarousel"
1580
+ >
1581
+ <ProductImageCarousel
1582
+ images={Array []}
1583
+ />
1584
+ </section>
1569
1585
  <section
1570
1586
  className="title"
1571
1587
  >
1572
1588
  <h1
1589
+ aria-live="polite"
1573
1590
  className="productName"
1574
1591
  >
1575
1592
  Flux Capacitor
@@ -1591,13 +1608,6 @@ exports[`it renders form level errors 1`] = `
1591
1608
  </span>
1592
1609
  </p>
1593
1610
  </section>
1594
- <section
1595
- className="imageCarousel"
1596
- >
1597
- <ProductImageCarousel
1598
- images={Array []}
1599
- />
1600
- </section>
1601
1611
  <FormError
1602
1612
  classes={
1603
1613
  Object {
@@ -1745,10 +1755,18 @@ exports[`it renders message with unsupported product type 1`] = `
1745
1755
  onReset={[Function]}
1746
1756
  onSubmit={[Function]}
1747
1757
  >
1758
+ <section
1759
+ className="imageCarousel"
1760
+ >
1761
+ <ProductImageCarousel
1762
+ images={Array []}
1763
+ />
1764
+ </section>
1748
1765
  <section
1749
1766
  className="title"
1750
1767
  >
1751
1768
  <h1
1769
+ aria-live="polite"
1752
1770
  className="productName"
1753
1771
  >
1754
1772
  Flux Capacitor
@@ -1770,13 +1788,6 @@ exports[`it renders message with unsupported product type 1`] = `
1770
1788
  </span>
1771
1789
  </p>
1772
1790
  </section>
1773
- <section
1774
- className="imageCarousel"
1775
- >
1776
- <ProductImageCarousel
1777
- images={Array []}
1778
- />
1779
- </section>
1780
1791
  <FormError
1781
1792
  classes={
1782
1793
  Object {
@@ -1933,10 +1944,18 @@ exports[`out of stock disabled CTA button is rendered if out of stock 1`] = `
1933
1944
  onReset={[Function]}
1934
1945
  onSubmit={[Function]}
1935
1946
  >
1947
+ <section
1948
+ className="imageCarousel"
1949
+ >
1950
+ <ProductImageCarousel
1951
+ images={Array []}
1952
+ />
1953
+ </section>
1936
1954
  <section
1937
1955
  className="title"
1938
1956
  >
1939
1957
  <h1
1958
+ aria-live="polite"
1940
1959
  className="productName"
1941
1960
  >
1942
1961
  Flux Capacitor
@@ -1958,13 +1977,6 @@ exports[`out of stock disabled CTA button is rendered if out of stock 1`] = `
1958
1977
  </span>
1959
1978
  </p>
1960
1979
  </section>
1961
- <section
1962
- className="imageCarousel"
1963
- >
1964
- <ProductImageCarousel
1965
- images={Array []}
1966
- />
1967
- </section>
1968
1980
  <FormError
1969
1981
  classes={
1970
1982
  Object {
@@ -2078,10 +2090,18 @@ exports[`renders a WishlistButton with props 1`] = `
2078
2090
  onReset={[Function]}
2079
2091
  onSubmit={[Function]}
2080
2092
  >
2093
+ <section
2094
+ className="imageCarousel"
2095
+ >
2096
+ <ProductImageCarousel
2097
+ images={Array []}
2098
+ />
2099
+ </section>
2081
2100
  <section
2082
2101
  className="title"
2083
2102
  >
2084
2103
  <h1
2104
+ aria-live="polite"
2085
2105
  className="productName"
2086
2106
  >
2087
2107
  Flux Capacitor
@@ -2103,13 +2123,6 @@ exports[`renders a WishlistButton with props 1`] = `
2103
2123
  </span>
2104
2124
  </p>
2105
2125
  </section>
2106
- <section
2107
- className="imageCarousel"
2108
- >
2109
- <ProductImageCarousel
2110
- images={Array []}
2111
- />
2112
- </section>
2113
2126
  <FormError
2114
2127
  classes={
2115
2128
  Object {
@@ -224,8 +224,12 @@ const ProductFullDetail = props => {
224
224
  data-cy="ProductFullDetail-root"
225
225
  onSubmit={handleAddToCart}
226
226
  >
227
+ <section className={classes.imageCarousel}>
228
+ <Carousel images={mediaGalleryEntries} />
229
+ </section>
227
230
  <section className={classes.title}>
228
231
  <h1
232
+ aria-live="polite"
229
233
  className={classes.productName}
230
234
  data-cy="ProductFullDetail-productName"
231
235
  >
@@ -242,9 +246,6 @@ const ProductFullDetail = props => {
242
246
  </p>
243
247
  {shortDescription}
244
248
  </section>
245
- <section className={classes.imageCarousel}>
246
- <Carousel images={mediaGalleryEntries} />
247
- </section>
248
249
  <FormError
249
250
  classes={{
250
251
  root: classes.formErrors
@@ -21,6 +21,10 @@
21
21
  grid-template-columns: minmax(0, 1.5625fr) minmax(0, 1fr);
22
22
  grid-template-rows: repeat(5, min-content) 1fr [fold];
23
23
  }
24
+
25
+ .title {
26
+ grid-template-columns: 1fr max-content;
27
+ }
24
28
  }
25
29
 
26
30
  .section {
@@ -33,7 +37,7 @@
33
37
  composes: my-0 from global;
34
38
  composes: mx-sm from global;
35
39
  composes: px-0 from global;
36
- composes: py-sm from global;
40
+ composes: py-xs from global;
37
41
  }
38
42
 
39
43
  .sectionTitle {
@@ -46,16 +50,14 @@
46
50
  }
47
51
 
48
52
  .title {
49
- composes: gap-xs from global;
53
+ composes: section;
54
+ composes: gap-2 from global;
50
55
  composes: grid from global;
51
56
  composes: items-center from global;
52
57
  composes: leading-normal from global;
53
58
  composes: px-sm from global;
54
59
  composes: py-xs from global;
55
60
  grid-area: title;
56
- grid-template-columns: 1fr max-content;
57
-
58
- composes: lg_p-sm from global;
59
61
  }
60
62
 
61
63
  .productName {
@@ -68,6 +70,7 @@
68
70
 
69
71
  .productPrice {
70
72
  composes: block from global;
73
+ composes: mb-2 from global;
71
74
  }
72
75
 
73
76
  .imageCarousel {
@@ -6,6 +6,7 @@ exports[`renders correctly when there are existing saved payments 1`] = `
6
6
  >
7
7
  Title
8
8
  <h1
9
+ aria-live="polite"
9
10
  className="heading"
10
11
  >
11
12
  Saved Payments
@@ -37,6 +38,7 @@ exports[`renders correctly when there are no existing saved payments 1`] = `
37
38
  >
38
39
  Title
39
40
  <h1
41
+ aria-live="polite"
40
42
  className="heading"
41
43
  >
42
44
  Saved Payments
@@ -55,7 +55,9 @@ const SavedPaymentsPage = props => {
55
55
  return (
56
56
  <div className={classes.root}>
57
57
  <StoreTitle>{title}</StoreTitle>
58
- <h1 className={classes.heading}>{title}</h1>
58
+ <h1 aria-live="polite" className={classes.heading}>
59
+ {title}
60
+ </h1>
59
61
  <div className={classes.content}>{savedPaymentElements}</div>
60
62
  <div className={classes.noPayments}>{noSavedPayments}</div>
61
63
  </div>
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
+ import { InMemoryCache } from '@apollo/client';
3
+ import { MockedProvider } from '@apollo/client/testing';
2
4
  import { Form } from 'informed';
3
5
  import { createTestInstance } from '@magento/peregrine';
6
+ import typePolicies from '@magento/peregrine/lib/Apollo/policies';
4
7
 
5
8
  import Autocomplete from '../autocomplete';
6
9
  import { IntlProvider } from 'react-intl';
@@ -8,13 +11,23 @@ import { IntlProvider } from 'react-intl';
8
11
  jest.mock('../../../classify');
9
12
  jest.mock('../suggestions', () => () => null);
10
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
+
11
22
  test('renders correctly', () => {
12
23
  const { root } = createTestInstance(
13
- <IntlProvider locale="en-US">
14
- <Form>
15
- <Autocomplete visible={false} />
16
- </Form>
17
- </IntlProvider>
24
+ <MockedProvider addTypename={true} cache={cache}>
25
+ <IntlProvider locale="en-US">
26
+ <Form>
27
+ <Autocomplete visible={false} />
28
+ </Form>
29
+ </IntlProvider>
30
+ </MockedProvider>
18
31
  );
19
32
 
20
33
  expect(root.findByProps({ className: 'root_hidden' })).toBeTruthy();
@@ -24,11 +37,13 @@ test('renders correctly', () => {
24
37
 
25
38
  test('renders correctly when visible', () => {
26
39
  const { root } = createTestInstance(
27
- <IntlProvider locale="en-US">
28
- <Form>
29
- <Autocomplete visible={true} />
30
- </Form>
31
- </IntlProvider>
40
+ <MockedProvider addTypename={true} cache={cache}>
41
+ <IntlProvider locale="en-US">
42
+ <Form>
43
+ <Autocomplete visible={true} />
44
+ </Form>
45
+ </IntlProvider>
46
+ </MockedProvider>
32
47
  );
33
48
 
34
49
  expect(root.findByProps({ className: 'root_visible' })).toBeTruthy();
@@ -7,6 +7,9 @@ jest.mock('react-router-dom', () => ({
7
7
  Link: ({ children }) => children
8
8
  }));
9
9
  jest.mock('@magento/peregrine/lib/util/makeUrl');
10
+ jest.mock('@magento/peregrine/lib/context/eventing', () => ({
11
+ useEventingContext: jest.fn().mockReturnValue([{}, { dispatch: jest.fn() }])
12
+ }));
10
13
 
11
14
  const defaultProps = {
12
15
  handleOnProductOpen: jest.fn(),
@@ -26,6 +26,7 @@ const GET_AUTOCOMPLETE_RESULTS = gql`
26
26
  items {
27
27
  id
28
28
  uid
29
+ sku
29
30
  name
30
31
  small_image {
31
32
  url
@@ -46,6 +47,9 @@ const GET_AUTOCOMPLETE_RESULTS = gql`
46
47
  currency
47
48
  value
48
49
  }
50
+ discount {
51
+ amount_off
52
+ }
49
53
  }
50
54
  }
51
55
  }
@@ -1,12 +1,12 @@
1
- import React, { useCallback, useMemo } from 'react';
1
+ import React from 'react';
2
2
  import { func, number, shape, string } from 'prop-types';
3
3
  import { Link } from 'react-router-dom';
4
- import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
5
4
  import Price from '@magento/venia-ui/lib/components/Price';
6
5
  import { useStyle } from '../../classify';
7
6
 
8
7
  import Image from '../Image';
9
8
  import defaultClasses from './suggestedProduct.module.css';
9
+ import { useSuggestedProduct } from '@magento/peregrine/lib/talons/SearchBar';
10
10
 
11
11
  const IMAGE_WIDTH = 60;
12
12
 
@@ -17,25 +17,23 @@ const SuggestedProduct = props => {
17
17
  small_image,
18
18
  name,
19
19
  onNavigate,
20
+ price,
20
21
  price_range,
21
- url_suffix
22
+ url_suffix,
23
+ sku
22
24
  } = props;
23
25
 
24
- const handleClick = useCallback(() => {
25
- if (typeof onNavigate === 'function') {
26
- onNavigate();
27
- }
28
- }, [onNavigate]);
29
-
30
- const uri = useMemo(() => resourceUrl(`/${url_key}${url_suffix || ''}`), [
26
+ const talonProps = useSuggestedProduct({
27
+ name,
28
+ price,
29
+ price_range,
30
+ onNavigate,
31
31
  url_key,
32
- url_suffix
33
- ]);
32
+ url_suffix,
33
+ sku
34
+ });
34
35
 
35
- const priceProps = {
36
- currencyCode: price_range?.maximum_price?.final_price?.currency,
37
- value: price_range?.maximum_price?.final_price?.value
38
- };
36
+ const { priceProps, handleClick, uri } = talonProps;
39
37
 
40
38
  return (
41
39
  <Link
@@ -72,6 +70,21 @@ SuggestedProduct.propTypes = {
72
70
  })
73
71
  })
74
72
  }).isRequired,
73
+ price_range: shape({
74
+ maximum_price: shape({
75
+ final_price: shape({
76
+ currency: string,
77
+ value: number
78
+ }),
79
+ regular_price: shape({
80
+ currency: string,
81
+ value: number
82
+ }),
83
+ discount: shape({
84
+ amount_off: number
85
+ })
86
+ })
87
+ }),
75
88
  classes: shape({
76
89
  root: string,
77
90
  image: string,