@magento/venia-ui 9.2.0-beta.1 → 9.3.0-beta.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 (167) hide show
  1. package/i18n/en_US.json +17 -3
  2. package/lib/RootComponents/CMS/__tests__/__snapshots__/cms.spec.js.snap +19 -0
  3. package/lib/RootComponents/CMS/__tests__/cms.spec.js +4 -9
  4. package/lib/RootComponents/CMS/cms.js +5 -4
  5. package/lib/RootComponents/CMS/cms.shimmer.js +18 -0
  6. package/lib/RootComponents/Category/__tests__/__snapshots__/categoryContent.shimmer.spec.js.snap +12 -0
  7. package/lib/RootComponents/Category/categoryContent.js +4 -1
  8. package/lib/components/AccountChip/accountChip.js +3 -1
  9. package/lib/components/AccountInformationPage/accountInformationPage.js +3 -1
  10. package/lib/components/AccountInformationPage/editModal.js +9 -2
  11. package/lib/components/AccountMenu/accountMenuItems.js +8 -3
  12. package/lib/components/CartPage/GiftCards/giftCards.js +1 -1
  13. package/lib/components/CartPage/PriceAdjustments/CouponCode/couponCode.js +5 -1
  14. package/lib/components/CartPage/PriceAdjustments/GiftOptions/__tests__/__snapshots__/giftOptions.spec.js.snap +1018 -78
  15. package/lib/components/CartPage/PriceAdjustments/GiftOptions/__tests__/giftOptions.spec.js +221 -35
  16. package/lib/components/CartPage/PriceAdjustments/GiftOptions/giftOptions.js +287 -40
  17. package/lib/components/CartPage/PriceAdjustments/GiftOptions/giftOptions.module.css +56 -1
  18. package/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/giftCardSection.ee.spec.js.snap +12 -0
  19. package/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/giftOptionsSection.ce.spec.js.snap +3 -0
  20. package/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/giftOptionsSection.ee.spec.js.snap +16 -0
  21. package/lib/components/CartPage/PriceAdjustments/__tests__/__snapshots__/priceAdjustments.spec.js.snap +1 -32
  22. package/lib/components/CartPage/PriceAdjustments/__tests__/giftCardSection.ce.spec.js +17 -0
  23. package/lib/components/CartPage/PriceAdjustments/__tests__/giftCardSection.ee.spec.js +36 -0
  24. package/lib/components/CartPage/PriceAdjustments/__tests__/giftOptionsSection.ce.spec.js +17 -0
  25. package/lib/components/CartPage/PriceAdjustments/__tests__/giftOptionsSection.ee.spec.js +54 -0
  26. package/lib/components/CartPage/PriceAdjustments/__tests__/priceAdjustments.spec.js +1 -1
  27. package/lib/components/CartPage/PriceAdjustments/{giftCardSection.js → giftCardSection.ce.js} +0 -0
  28. package/lib/components/CartPage/PriceAdjustments/giftOptionsSection.ce.js +7 -0
  29. package/lib/components/CartPage/PriceAdjustments/giftOptionsSection.ee.js +38 -0
  30. package/lib/components/CartPage/PriceAdjustments/priceAdjustments.js +2 -14
  31. package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/discountSummary.spec.js.snap +496 -42
  32. package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/giftCardSummary.ce.spec.js.snap +3 -0
  33. package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/{giftCardSummary.spec.js.snap → giftCardSummary.ee.spec.js.snap} +4 -4
  34. package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/giftOptionsSummary.ce.spec.js.snap +3 -0
  35. package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/giftOptionsSummary.ee.spec.js.snap +63 -0
  36. package/lib/components/CartPage/PriceSummary/__tests__/__snapshots__/priceSummary.spec.js.snap +201 -141
  37. package/lib/components/CartPage/PriceSummary/__tests__/discountSummary.spec.js +41 -1
  38. package/lib/components/CartPage/PriceSummary/__tests__/giftCardSummary.ce.spec.js +17 -0
  39. package/lib/components/CartPage/PriceSummary/__tests__/giftCardSummary.ee.spec.js +84 -0
  40. package/lib/components/CartPage/PriceSummary/__tests__/giftOptionsSummary.ce.spec.js +17 -0
  41. package/lib/components/CartPage/PriceSummary/__tests__/giftOptionsSummary.ee.spec.js +69 -0
  42. package/lib/components/CartPage/PriceSummary/__tests__/priceSummary.spec.js +2 -0
  43. package/lib/components/CartPage/PriceSummary/discountSummary.js +99 -49
  44. package/lib/components/CartPage/PriceSummary/discountSummary.module.css +40 -0
  45. package/lib/components/CartPage/PriceSummary/giftOptionsSummary.ce.js +5 -0
  46. package/lib/components/CartPage/PriceSummary/giftOptionsSummary.ee.js +40 -0
  47. package/lib/components/CartPage/PriceSummary/priceSummary.js +95 -53
  48. package/lib/components/CartPage/PriceSummary/priceSummary.module.css +2 -0
  49. package/lib/components/CartPage/ProductListing/EditModal/__tests__/__snapshots__/productDetail.spec.js.snap +57 -0
  50. package/lib/components/CartPage/ProductListing/EditModal/__tests__/__snapshots__/productForm.spec.js.snap +22 -0
  51. package/lib/components/CartPage/ProductListing/EditModal/__tests__/productDetail.spec.js +42 -3
  52. package/lib/components/CartPage/ProductListing/EditModal/productDetail.js +13 -10
  53. package/lib/components/CartPage/ProductListing/EditModal/productForm.js +7 -2
  54. package/lib/components/CartPage/ProductListing/product.js +1 -0
  55. package/lib/components/CartPage/ProductListing/productListing.js +1 -1
  56. package/lib/components/CartPage/cartPage.js +1 -1
  57. package/lib/components/Checkbox/checkbox.js +6 -1
  58. package/lib/components/Checkbox/checkbox.module.css +1 -0
  59. package/lib/components/CheckoutPage/ItemsReview/__tests__/__snapshots__/item.spec.js.snap +2 -2
  60. package/lib/components/CheckoutPage/ItemsReview/__tests__/__snapshots__/itemsReview.spec.js.snap +33 -0
  61. package/lib/components/CheckoutPage/ItemsReview/__tests__/item.spec.js +2 -2
  62. package/lib/components/CheckoutPage/ItemsReview/itemsReview.js +4 -1
  63. package/lib/components/CheckoutPage/OrderConfirmationPage/__tests__/createAccount.spec.js +4 -0
  64. package/lib/components/CheckoutPage/OrderConfirmationPage/createAccount.js +9 -1
  65. package/lib/components/CheckoutPage/OrderConfirmationPage/orderConfirmationPage.js +12 -3
  66. package/lib/components/CheckoutPage/PaymentInformation/__tests__/__snapshots__/creditCard.spec.js.snap +1 -0
  67. package/lib/components/CheckoutPage/PaymentInformation/__tests__/creditCard.spec.js +2 -1
  68. package/lib/components/CheckoutPage/PaymentInformation/brainTreeDropIn.js +2 -18
  69. package/lib/components/CheckoutPage/PaymentInformation/creditCard.js +13 -3
  70. package/lib/components/CheckoutPage/PriceAdjustments/__tests__/__snapshots__/priceAdjustments.spec.js.snap +1 -6
  71. package/lib/components/CheckoutPage/PriceAdjustments/__tests__/priceAdjustments.spec.js +2 -2
  72. package/lib/components/CheckoutPage/PriceAdjustments/priceAdjustments.js +8 -12
  73. package/lib/components/CheckoutPage/ShippingInformation/AddressForm/customerForm.js +1 -1
  74. package/lib/components/CheckoutPage/ShippingInformation/shippingInformation.js +4 -1
  75. package/lib/components/CheckoutPage/ShippingMethod/shippingMethod.js +5 -2
  76. package/lib/components/CheckoutPage/__tests__/__snapshots__/checkoutPage.spec.js.snap +3 -3
  77. package/lib/components/CheckoutPage/__tests__/checkoutPage.spec.js +5 -0
  78. package/lib/components/CheckoutPage/checkoutPage.js +25 -4
  79. package/lib/components/CheckoutPage/checkoutPage.module.css +8 -1
  80. package/lib/components/CmsDynamicBlock/__tests__/__snapshots__/cmsDynamicBlock.ce.spec.js.snap +3 -0
  81. package/lib/components/CmsDynamicBlock/__tests__/__snapshots__/cmsDynamicBlock.ee.spec.js.snap +61 -0
  82. package/lib/components/CmsDynamicBlock/__tests__/__snapshots__/dynamicBlock.spec.js.snap +7 -0
  83. package/lib/components/CmsDynamicBlock/__tests__/cmsDynamicBlock.ce.spec.js +17 -0
  84. package/lib/components/CmsDynamicBlock/__tests__/cmsDynamicBlock.ee.spec.js +211 -0
  85. package/lib/components/CmsDynamicBlock/__tests__/constants.spec.js +37 -0
  86. package/lib/components/CmsDynamicBlock/__tests__/dynamicBlock.spec.js +33 -0
  87. package/lib/components/CmsDynamicBlock/cmsDynamicBlock.ce.js +5 -0
  88. package/lib/components/CmsDynamicBlock/cmsDynamicBlock.ee.js +73 -0
  89. package/lib/components/CmsDynamicBlock/constants.js +6 -0
  90. package/lib/components/CmsDynamicBlock/dynamicBlock.js +32 -0
  91. package/lib/components/CmsDynamicBlock/index.js +2 -0
  92. package/lib/components/CreateAccount/__tests__/createAccount.spec.js +6 -1
  93. package/lib/components/CreateAccount/createAccount.js +7 -2
  94. package/lib/components/Field/field.module.css +6 -0
  95. package/lib/components/FilterSidebar/filterSidebar.js +4 -1
  96. package/lib/components/Footer/__tests__/__snapshots__/footer.spec.js.snap +8 -2
  97. package/lib/components/Footer/footer.js +16 -9
  98. package/lib/components/Footer/footer.module.css +7 -2
  99. package/lib/components/ForgotPassword/ForgotPasswordForm/__tests__/__snapshots__/forgotPasswordForm.spec.js.snap +109 -1
  100. package/lib/components/ForgotPassword/ForgotPasswordForm/__tests__/forgotPasswordForm.spec.js +22 -3
  101. package/lib/components/ForgotPassword/ForgotPasswordForm/forgotPasswordForm.js +13 -3
  102. package/lib/components/ForgotPassword/ForgotPasswordForm/forgotPasswordForm.module.css +1 -1
  103. package/lib/components/ForgotPassword/__tests__/__snapshots__/forgotPassword.spec.js.snap +5 -6
  104. package/lib/components/ForgotPassword/__tests__/forgotPassword.spec.js +41 -28
  105. package/lib/components/ForgotPassword/forgotPassword.js +10 -3
  106. package/lib/components/ForgotPassword/forgotPassword.module.css +2 -2
  107. package/lib/components/Gallery/__tests__/__snapshots__/gallery.spec.js.snap +22 -0
  108. package/lib/components/Gallery/__tests__/__snapshots__/item.spec.js.snap +17 -0
  109. package/lib/components/Gallery/addToCartButton.js +2 -0
  110. package/lib/components/Gallery/gallery.js +6 -1
  111. package/lib/components/Gallery/item.js +7 -2
  112. package/lib/components/GoogleReCaptcha/googleReCaptcha.js +49 -0
  113. package/lib/components/GoogleReCaptcha/googleReCaptcha.module.css +3 -0
  114. package/lib/components/GoogleReCaptcha/index.js +1 -0
  115. package/lib/components/Header/currencySwitcher.js +2 -1
  116. package/lib/components/Header/header.js +1 -1
  117. package/lib/components/Header/header.module.css +2 -2
  118. package/lib/components/Header/searchTrigger.js +3 -1
  119. package/lib/components/Header/storeSwitcher.js +18 -4
  120. package/lib/components/Header/switcherItem.js +4 -1
  121. package/lib/components/HomePage/homePage.module.css +12 -0
  122. package/lib/components/Image/resourceImage.js +8 -1
  123. package/lib/components/Image/simpleImage.js +8 -1
  124. package/lib/components/Link/link.js +15 -13
  125. package/lib/components/LoadingIndicator/spinner.js +5 -7
  126. package/lib/components/LoadingIndicator/spinner.module.css +4 -17
  127. package/lib/components/MiniCart/ProductList/__tests__/__snapshots__/item.spec.js.snap +44 -0
  128. package/lib/components/MiniCart/ProductList/__tests__/item.spec.js +2 -2
  129. package/lib/components/MiniCart/ProductList/item.js +3 -2
  130. package/lib/components/MiniCart/miniCart.js +6 -3
  131. package/lib/components/MyAccount/ResetPassword/__tests__/__snapshots__/resetPassword.spec.js.snap +274 -254
  132. package/lib/components/MyAccount/ResetPassword/__tests__/resetPassword.spec.js +10 -5
  133. package/lib/components/MyAccount/ResetPassword/resetPassword.js +55 -55
  134. package/lib/components/MyAccount/ResetPassword/resetPassword.module.css +27 -79
  135. package/lib/components/Newsletter/newsletter.js +6 -2
  136. package/lib/components/OrderHistoryPage/OrderDetails/__tests__/__snapshots__/item.spec.js.snap +11 -0
  137. package/lib/components/ProductFullDetail/productFullDetail.js +12 -3
  138. package/lib/components/ProductImageCarousel/__tests__/__snapshots__/carousel.spec.js.snap +61 -0
  139. package/lib/components/ProductImageCarousel/__tests__/__snapshots__/thumbnail.spec.js.snap +26 -0
  140. package/lib/components/ProductOptions/__tests__/options.spec.js +1 -1
  141. package/lib/components/ProductOptions/__tests__/swatch.spec.js +1 -1
  142. package/lib/components/ProductOptions/__tests__/swatchList.spec.js +1 -1
  143. package/lib/components/ProductOptions/__tests__/tile.spec.js +1 -1
  144. package/lib/components/ProductOptions/__tests__/tileList.spec.js +1 -1
  145. package/lib/components/ProductOptions/option.js +4 -1
  146. package/lib/components/ProductSort/productSort.js +22 -14
  147. package/lib/components/Rating/rating.js +1 -1
  148. package/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +11 -0
  149. package/lib/components/SearchBar/autocomplete.js +4 -2
  150. package/lib/components/SearchBar/suggestedProduct.js +1 -1
  151. package/lib/components/SearchBar/suggestions.js +1 -1
  152. package/lib/components/SignIn/__tests__/signIn.spec.js +11 -20
  153. package/lib/components/SignIn/signIn.js +6 -16
  154. package/lib/components/TextInput/textInput.module.css +0 -4
  155. package/lib/components/Wishlist/WishlistDialog/WishlistLineItem/__tests__/__snapshots__/wishlistLineItem.spec.js.snap +5 -1
  156. package/lib/components/Wishlist/WishlistDialog/WishlistLineItem/wishlistLineItem.js +7 -1
  157. package/lib/components/Wishlist/WishlistDialog/WishlistLineItem/wishlistLineItem.module.css +7 -0
  158. package/lib/components/Wishlist/WishlistDialog/__tests__/__snapshots__/wishlistDialog.spec.js.snap +6 -1
  159. package/lib/components/WishlistPage/__tests__/__snapshots__/wishlist.spec.js.snap +4 -0
  160. package/lib/components/WishlistPage/__tests__/__snapshots__/wishlistItem.spec.js.snap +22 -0
  161. package/lib/components/WishlistPage/__tests__/__snapshots__/wishlistPage.spec.js.snap +9 -3
  162. package/lib/components/WishlistPage/createWishlist.ee.js +3 -1
  163. package/lib/components/WishlistPage/wishlist.js +1 -1
  164. package/lib/components/WishlistPage/wishlist.module.css +3 -0
  165. package/lib/components/WishlistPage/wishlistPage.js +1 -1
  166. package/package.json +5 -4
  167. package/lib/components/CartPage/PriceSummary/__tests__/giftCardSummary.spec.js +0 -84
@@ -27,6 +27,7 @@ import ShippingMethod from './ShippingMethod';
27
27
  import ShippingInformation from './ShippingInformation';
28
28
  import OrderConfirmationPage from './OrderConfirmationPage';
29
29
  import ItemsReview from './ItemsReview';
30
+ import GoogleReCaptcha from '../GoogleReCaptcha';
30
31
 
31
32
  import defaultClasses from './checkoutPage.module.css';
32
33
  import ScrollAnchor from '../ScrollAnchor/scrollAnchor';
@@ -60,6 +61,7 @@ const CheckoutPage = props => {
60
61
  orderDetailsLoading,
61
62
  orderNumber,
62
63
  placeOrderLoading,
64
+ placeOrderButtonClicked,
63
65
  setCheckoutStep,
64
66
  setGuestSignInUsername,
65
67
  setIsUpdating,
@@ -73,6 +75,7 @@ const CheckoutPage = props => {
73
75
  resetReviewOrderButtonClicked,
74
76
  handleReviewOrder,
75
77
  reviewOrderButtonClicked,
78
+ recaptchaWidgetProps,
76
79
  toggleAddressBookContent,
77
80
  toggleSignInContent
78
81
  } = talonProps;
@@ -149,7 +152,9 @@ const CheckoutPage = props => {
149
152
  </div>
150
153
  );
151
154
  } else {
152
- const signInContainerElement = isGuestCheckout ? (
155
+ const signInContainerVisible =
156
+ isGuestCheckout && checkoutStep !== CHECKOUT_STEP.REVIEW;
157
+ const signInContainerElement = signInContainerVisible ? (
153
158
  <div className={classes.signInContainer}>
154
159
  <span className={classes.signInLabel}>
155
160
  <FormattedMessage
@@ -268,7 +273,10 @@ const CheckoutPage = props => {
268
273
  className={classes.place_order_button}
269
274
  data-cy="CheckoutPage-placeOrderButton"
270
275
  disabled={
271
- isUpdating || placeOrderLoading || orderDetailsLoading
276
+ isUpdating ||
277
+ placeOrderLoading ||
278
+ orderDetailsLoading ||
279
+ placeOrderButtonClicked
272
280
  }
273
281
  >
274
282
  <FormattedMessage
@@ -284,7 +292,17 @@ const CheckoutPage = props => {
284
292
  );
285
293
 
286
294
  const orderSummary = shouldRenderPriceSummary ? (
287
- <div className={classes.summaryContainer}>
295
+ <div
296
+ className={
297
+ classes.summaryContainer +
298
+ (signInContainerVisible
299
+ ? ' ' + classes.signInContainerVisible
300
+ : '') +
301
+ (recaptchaWidgetProps.shouldRender
302
+ ? ' ' + classes.reCaptchaMargin
303
+ : '')
304
+ }
305
+ >
288
306
  <OrderSummary isUpdating={isUpdating} />
289
307
  </div>
290
308
  ) : null;
@@ -377,6 +395,7 @@ const CheckoutPage = props => {
377
395
  {itemsReview}
378
396
  {orderSummary}
379
397
  {placeOrderButton}
398
+ <GoogleReCaptcha {...recaptchaWidgetProps} />
380
399
  </div>
381
400
  );
382
401
  }
@@ -438,6 +457,8 @@ CheckoutPage.propTypes = {
438
457
  summaryContainer: string,
439
458
  formErrors: string,
440
459
  review_order_button: string,
441
- place_order_button: string
460
+ place_order_button: string,
461
+ signInContainerVisible: string,
462
+ reCaptchaMargin: string
442
463
  })
443
464
  };
@@ -18,6 +18,7 @@
18
18
  .heading_container {
19
19
  display: grid;
20
20
  row-gap: 1rem;
21
+ grid-column: 1 / span 1;
21
22
  }
22
23
 
23
24
  .heading {
@@ -46,6 +47,7 @@
46
47
  }
47
48
 
48
49
  .signInContainer {
50
+ grid-row-start: 1;
49
51
  align-items: center;
50
52
  border: 2px solid rgb(var(--venia-global-color-gray-400));
51
53
  border-radius: 0.375rem;
@@ -113,6 +115,12 @@
113
115
  top: 5.5rem;
114
116
  height: min-content;
115
117
  }
118
+ .reCaptchaMargin {
119
+ margin-bottom: 5.5rem;
120
+ }
121
+ .signInContainerVisible {
122
+ grid-row: 1 / span 3;
123
+ }
116
124
  }
117
125
 
118
126
  .review_order_button {
@@ -144,7 +152,6 @@
144
152
  }
145
153
 
146
154
  .signInContainer {
147
- grid-row-start: 1;
148
155
  grid-auto-flow: row;
149
156
  justify-items: center;
150
157
  margin-bottom: 1rem;
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`#CmsDynamicBlock CE renders 1`] = `null`;
@@ -0,0 +1,61 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`#CmsDynamicBlock EE renders DynamicBlock when data with type catalogrule 1`] = `
4
+ <mock-DynamicBlock
5
+ content={
6
+ Object {
7
+ "html": "<div>Item 1</div>",
8
+ }
9
+ }
10
+ index={0}
11
+ uid="itemUid1"
12
+ />
13
+ `;
14
+
15
+ exports[`#CmsDynamicBlock EE renders DynamicBlock when data with type fixed 1`] = `
16
+ <mock-DynamicBlock
17
+ content={
18
+ Object {
19
+ "html": "<div>Item 1</div>",
20
+ }
21
+ }
22
+ index={0}
23
+ uid="itemUid1"
24
+ />
25
+ `;
26
+
27
+ exports[`#CmsDynamicBlock EE renders DynamicBlock when data with type salesrule 1`] = `
28
+ <mock-DynamicBlock
29
+ content={
30
+ Object {
31
+ "html": "<div>Item 1</div>",
32
+ }
33
+ }
34
+ index={0}
35
+ uid="itemUid1"
36
+ />
37
+ `;
38
+
39
+ exports[`#CmsDynamicBlock EE renders DynamicBlock when data with unknown type 1`] = `
40
+ <mock-DynamicBlock
41
+ content={
42
+ Object {
43
+ "html": "<div>Item 1</div>",
44
+ }
45
+ }
46
+ index={0}
47
+ uid="itemUid1"
48
+ />
49
+ `;
50
+
51
+ exports[`#CmsDynamicBlock EE renders ErrorView when error 1`] = `
52
+ <mock-ErrorView
53
+ message="Error"
54
+ />
55
+ `;
56
+
57
+ exports[`#CmsDynamicBlock EE renders null when items are empty 1`] = `null`;
58
+
59
+ exports[`#CmsDynamicBlock EE renders null when loading 1`] = `null`;
60
+
61
+ exports[`#CmsDynamicBlock EE renders null when no data 1`] = `null`;
@@ -0,0 +1,7 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`#DynamicBlock renders 1`] = `
4
+ <mock-RichContent
5
+ html="Hello World"
6
+ />
7
+ `;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+
3
+ import { createTestInstance } from '@magento/peregrine';
4
+
5
+ import CmsDynamicBlock from '../cmsDynamicBlock.ce';
6
+
7
+ const Component = () => {
8
+ return <CmsDynamicBlock />;
9
+ };
10
+
11
+ describe('#CmsDynamicBlock CE', () => {
12
+ it('renders', () => {
13
+ const tree = createTestInstance(<Component />);
14
+
15
+ expect(tree.toJSON()).toMatchSnapshot();
16
+ });
17
+ });
@@ -0,0 +1,211 @@
1
+ import React from 'react';
2
+
3
+ import { createTestInstance } from '@magento/peregrine';
4
+ import { useCmsDynamicBlock } from '@magento/peregrine/lib/talons/CmsDynamicBlock/useCmsDynamicBlock';
5
+
6
+ import {
7
+ DISPLAY_MODE_FIXED_TYPE,
8
+ DISPLAY_MODE_SALES_RULE_TYPE,
9
+ DISPLAY_MODE_CATALOG_RULE_TYPE
10
+ } from '../constants';
11
+ import CmsDynamicBlock from '../cmsDynamicBlock.ee';
12
+
13
+ const mockUids = 'uids';
14
+
15
+ jest.mock('@magento/peregrine/lib/talons/CmsDynamicBlock/useCmsDynamicBlock');
16
+ jest.mock('@magento/venia-ui/lib/components/ErrorView', () => props => (
17
+ <mock-ErrorView {...props} />
18
+ ));
19
+ jest.mock('../dynamicBlock', () => props => <mock-DynamicBlock {...props} />);
20
+
21
+ let inputProps = {};
22
+
23
+ const Component = () => {
24
+ return <CmsDynamicBlock {...inputProps} />;
25
+ };
26
+
27
+ const givenDefaultValues = () => {
28
+ inputProps = {
29
+ displayMode: DISPLAY_MODE_FIXED_TYPE,
30
+ uids: mockUids
31
+ };
32
+ };
33
+
34
+ const givenCatalogRuleType = () => {
35
+ inputProps = {
36
+ displayMode: DISPLAY_MODE_CATALOG_RULE_TYPE,
37
+ uids: mockUids
38
+ };
39
+ };
40
+
41
+ const givenSalesRuleType = () => {
42
+ inputProps = {
43
+ displayMode: DISPLAY_MODE_SALES_RULE_TYPE,
44
+ uids: mockUids
45
+ };
46
+ };
47
+
48
+ const givenUnknownType = () => {
49
+ inputProps = {
50
+ displayMode: 'test',
51
+ uids: mockUids
52
+ };
53
+ };
54
+
55
+ describe('#CmsDynamicBlock EE', () => {
56
+ beforeEach(() => {
57
+ givenDefaultValues();
58
+ });
59
+
60
+ it('renders null when loading', () => {
61
+ useCmsDynamicBlock.mockReturnValueOnce({
62
+ data: null,
63
+ error: undefined,
64
+ loading: true
65
+ });
66
+
67
+ const component = createTestInstance(<Component />);
68
+
69
+ expect(component.toJSON()).toMatchSnapshot();
70
+ });
71
+
72
+ it('renders ErrorView when error', () => {
73
+ useCmsDynamicBlock.mockReturnValueOnce({
74
+ data: null,
75
+ error: {
76
+ message: 'Error'
77
+ },
78
+ loading: false
79
+ });
80
+
81
+ const component = createTestInstance(<Component />);
82
+
83
+ expect(component.toJSON()).toMatchSnapshot();
84
+ });
85
+
86
+ it('renders null when no data', () => {
87
+ useCmsDynamicBlock.mockReturnValueOnce({
88
+ data: null,
89
+ error: undefined,
90
+ loading: false
91
+ });
92
+
93
+ const component = createTestInstance(<Component />);
94
+
95
+ expect(component.toJSON()).toMatchSnapshot();
96
+ });
97
+
98
+ it('renders null when items are empty', () => {
99
+ useCmsDynamicBlock.mockReturnValue({
100
+ data: {
101
+ dynamicBlocks: {
102
+ items: []
103
+ }
104
+ },
105
+ error: undefined,
106
+ loading: false
107
+ });
108
+
109
+ const component = createTestInstance(<Component />);
110
+
111
+ expect(component.toJSON()).toMatchSnapshot();
112
+ });
113
+
114
+ it('renders DynamicBlock when data with type fixed', () => {
115
+ useCmsDynamicBlock.mockReturnValue({
116
+ data: {
117
+ dynamicBlocks: {
118
+ items: [
119
+ {
120
+ uid: 'itemUid1',
121
+ content: {
122
+ html: '<div>Item 1</div>'
123
+ }
124
+ }
125
+ ]
126
+ }
127
+ },
128
+ error: undefined,
129
+ loading: false
130
+ });
131
+
132
+ const component = createTestInstance(<Component />);
133
+
134
+ expect(component.toJSON()).toMatchSnapshot();
135
+ });
136
+
137
+ it('renders DynamicBlock when data with type catalogrule', () => {
138
+ givenCatalogRuleType();
139
+
140
+ useCmsDynamicBlock.mockReturnValue({
141
+ data: {
142
+ dynamicBlocks: {
143
+ items: [
144
+ {
145
+ uid: 'itemUid1',
146
+ content: {
147
+ html: '<div>Item 1</div>'
148
+ }
149
+ }
150
+ ]
151
+ }
152
+ },
153
+ error: undefined,
154
+ loading: false
155
+ });
156
+
157
+ const component = createTestInstance(<Component />);
158
+
159
+ expect(component.toJSON()).toMatchSnapshot();
160
+ });
161
+
162
+ it('renders DynamicBlock when data with type salesrule', () => {
163
+ givenSalesRuleType();
164
+
165
+ useCmsDynamicBlock.mockReturnValue({
166
+ data: {
167
+ dynamicBlocks: {
168
+ items: [
169
+ {
170
+ uid: 'itemUid1',
171
+ content: {
172
+ html: '<div>Item 1</div>'
173
+ }
174
+ }
175
+ ]
176
+ }
177
+ },
178
+ error: undefined,
179
+ loading: false
180
+ });
181
+
182
+ const component = createTestInstance(<Component />);
183
+
184
+ expect(component.toJSON()).toMatchSnapshot();
185
+ });
186
+
187
+ it('renders DynamicBlock when data with unknown type', () => {
188
+ givenUnknownType();
189
+
190
+ useCmsDynamicBlock.mockReturnValue({
191
+ data: {
192
+ dynamicBlocks: {
193
+ items: [
194
+ {
195
+ uid: 'itemUid1',
196
+ content: {
197
+ html: '<div>Item 1</div>'
198
+ }
199
+ }
200
+ ]
201
+ }
202
+ },
203
+ error: undefined,
204
+ loading: false
205
+ });
206
+
207
+ const component = createTestInstance(<Component />);
208
+
209
+ expect(component.toJSON()).toMatchSnapshot();
210
+ });
211
+ });
@@ -0,0 +1,37 @@
1
+ import {
2
+ DISPLAY_MODE_FIXED_TYPE,
3
+ DYNAMIC_BLOCK_FIXED_TYPE,
4
+ DISPLAY_MODE_SALES_RULE_TYPE,
5
+ DYNAMIC_BLOCK_SALES_RULE_TYPE,
6
+ DISPLAY_MODE_CATALOG_RULE_TYPE,
7
+ DYNAMIC_BLOCK_CATALOG_RULE_TYPE
8
+ } from '../constants';
9
+
10
+ describe('#CmsDynamicBlock Constants', () => {
11
+ it('returns DISPLAY_MODE_FIXED_TYPE value', () => {
12
+ expect(DISPLAY_MODE_FIXED_TYPE).toMatchInlineSnapshot(`"fixed"`);
13
+ });
14
+ it('returns DYNAMIC_BLOCK_FIXED_TYPE value', () => {
15
+ expect(DYNAMIC_BLOCK_FIXED_TYPE).toMatchInlineSnapshot(`"SPECIFIED"`);
16
+ });
17
+ it('returns DISPLAY_MODE_SALES_RULE_TYPE value', () => {
18
+ expect(DISPLAY_MODE_SALES_RULE_TYPE).toMatchInlineSnapshot(
19
+ `"salesrule"`
20
+ );
21
+ });
22
+ it('returns DYNAMIC_BLOCK_SALES_RULE_TYPE value', () => {
23
+ expect(DYNAMIC_BLOCK_SALES_RULE_TYPE).toMatchInlineSnapshot(
24
+ `"CART_PRICE_RULE_RELATED"`
25
+ );
26
+ });
27
+ it('returns DISPLAY_MODE_CATALOG_RULE_TYPE value', () => {
28
+ expect(DISPLAY_MODE_CATALOG_RULE_TYPE).toMatchInlineSnapshot(
29
+ `"catalogrule"`
30
+ );
31
+ });
32
+ it('returns DYNAMIC_BLOCK_CATALOG_RULE_TYPE value', () => {
33
+ expect(DYNAMIC_BLOCK_CATALOG_RULE_TYPE).toMatchInlineSnapshot(
34
+ `"CATALOG_PRICE_RULE_RELATED"`
35
+ );
36
+ });
37
+ });
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+
3
+ import { createTestInstance } from '@magento/peregrine';
4
+
5
+ import DynamicBlock from '../dynamicBlock';
6
+
7
+ jest.mock('../../RichContent', () => props => <mock-RichContent {...props} />);
8
+
9
+ let inputProps = {};
10
+
11
+ const Component = () => {
12
+ return <DynamicBlock {...inputProps} />;
13
+ };
14
+
15
+ const givenDefaultValues = () => {
16
+ inputProps = {
17
+ content: {
18
+ html: 'Hello World'
19
+ }
20
+ };
21
+ };
22
+
23
+ describe('#DynamicBlock', () => {
24
+ beforeEach(() => {
25
+ givenDefaultValues();
26
+ });
27
+
28
+ it('renders', () => {
29
+ const component = createTestInstance(<Component />);
30
+
31
+ expect(component.toJSON()).toMatchSnapshot();
32
+ });
33
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Dynamic Block is an EE-only feature for now.
3
+ * Here in CE, don't render the component at all.
4
+ */
5
+ export default () => null;
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import { array, oneOf, oneOfType, string } from 'prop-types';
3
+
4
+ import { useCmsDynamicBlock } from '@magento/peregrine/lib/talons/CmsDynamicBlock/useCmsDynamicBlock';
5
+ import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
6
+
7
+ import {
8
+ DISPLAY_MODE_FIXED_TYPE,
9
+ DYNAMIC_BLOCK_FIXED_TYPE,
10
+ DISPLAY_MODE_SALES_RULE_TYPE,
11
+ DYNAMIC_BLOCK_SALES_RULE_TYPE,
12
+ DISPLAY_MODE_CATALOG_RULE_TYPE,
13
+ DYNAMIC_BLOCK_CATALOG_RULE_TYPE
14
+ } from './constants';
15
+ import DynamicBlock from './dynamicBlock';
16
+
17
+ const getDynamicBlockType = displayMode => {
18
+ if (displayMode === DISPLAY_MODE_FIXED_TYPE) {
19
+ return DYNAMIC_BLOCK_FIXED_TYPE;
20
+ } else if (displayMode === DISPLAY_MODE_SALES_RULE_TYPE) {
21
+ return DYNAMIC_BLOCK_SALES_RULE_TYPE;
22
+ } else if (displayMode === DISPLAY_MODE_CATALOG_RULE_TYPE) {
23
+ return DYNAMIC_BLOCK_CATALOG_RULE_TYPE;
24
+ }
25
+
26
+ return DYNAMIC_BLOCK_FIXED_TYPE;
27
+ };
28
+
29
+ const CmsDynamicBlockGroup = props => {
30
+ const { displayMode } = props;
31
+ const type = getDynamicBlockType(displayMode);
32
+
33
+ const { loading, error, data } = useCmsDynamicBlock({
34
+ ...props,
35
+ type
36
+ });
37
+
38
+ if (!data) {
39
+ if (loading) {
40
+ return null;
41
+ }
42
+
43
+ if (error) {
44
+ return <ErrorView message={error.message} />;
45
+ }
46
+ }
47
+
48
+ const { items } = data?.dynamicBlocks || {};
49
+
50
+ if (!Array.isArray(items) || !items.length) {
51
+ return null;
52
+ }
53
+
54
+ return items.map((item, index) => (
55
+ <DynamicBlock key={item.uid} index={index} {...item} />
56
+ ));
57
+ };
58
+
59
+ CmsDynamicBlockGroup.defaultProps = {
60
+ displayMode: 'fixed'
61
+ };
62
+
63
+ CmsDynamicBlockGroup.propTypes = {
64
+ displayMode: oneOf([
65
+ DISPLAY_MODE_FIXED_TYPE,
66
+ DISPLAY_MODE_SALES_RULE_TYPE,
67
+ DISPLAY_MODE_CATALOG_RULE_TYPE
68
+ ]),
69
+ locations: array,
70
+ uids: oneOfType([string, array]).isRequired
71
+ };
72
+
73
+ export default CmsDynamicBlockGroup;
@@ -0,0 +1,6 @@
1
+ export const DISPLAY_MODE_FIXED_TYPE = `fixed`;
2
+ export const DYNAMIC_BLOCK_FIXED_TYPE = `SPECIFIED`;
3
+ export const DISPLAY_MODE_SALES_RULE_TYPE = `salesrule`;
4
+ export const DYNAMIC_BLOCK_SALES_RULE_TYPE = `CART_PRICE_RULE_RELATED`;
5
+ export const DISPLAY_MODE_CATALOG_RULE_TYPE = `catalogrule`;
6
+ export const DYNAMIC_BLOCK_CATALOG_RULE_TYPE = `CATALOG_PRICE_RULE_RELATED`;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { shape, string } from 'prop-types';
3
+
4
+ import RichContent from '../RichContent';
5
+
6
+ /**
7
+ * CMS Dynamic Block component.
8
+ *
9
+ * @typedef DynamicBlock
10
+ * @kind functional component
11
+ *
12
+ * @param {props} props React component props
13
+ *
14
+ * @returns {React.Element} A React component that displays a CMS Dynamic Block.
15
+ */
16
+ const DynamicBlock = ({ content }) => <RichContent html={content.html} />;
17
+
18
+ /**
19
+ * Props for {@link DynamicBlock}
20
+ *
21
+ * @typedef props
22
+ *
23
+ * @property {Object} content Content object of the Dynamic Block
24
+ * @property {String} content.html Rich content of the Dynamic Block
25
+ */
26
+ DynamicBlock.propTypes = {
27
+ content: shape({
28
+ html: string
29
+ })
30
+ };
31
+
32
+ export default DynamicBlock;
@@ -0,0 +1,2 @@
1
+ export { default } from './cmsDynamicBlock';
2
+ export * from './constants';
@@ -12,7 +12,12 @@ jest.mock('@apollo/client', () => ({
12
12
  {
13
13
  error: null
14
14
  }
15
- ])
15
+ ]),
16
+ useQuery: jest.fn().mockImplementation(() => ({
17
+ data: {},
18
+ loading: false,
19
+ error: null
20
+ }))
16
21
  }));
17
22
 
18
23
  jest.mock('../../../util/formValidators');
@@ -18,6 +18,7 @@ import TextInput from '../TextInput';
18
18
  import defaultClasses from './createAccount.module.css';
19
19
  import FormError from '../FormError';
20
20
  import Password from '../Password';
21
+ import GoogleRecaptcha from '../GoogleReCaptcha';
21
22
 
22
23
  const CreateAccount = props => {
23
24
  const talonProps = useCreateAccount({
@@ -31,13 +32,15 @@ const CreateAccount = props => {
31
32
  handleCancel,
32
33
  handleSubmit,
33
34
  isDisabled,
34
- initialValues
35
+ initialValues,
36
+ recaptchaWidgetProps
35
37
  } = talonProps;
36
38
  const { formatMessage } = useIntl();
37
39
  const classes = useStyle(defaultClasses, props.classes);
38
40
 
39
41
  const cancelButton = props.isCancelButtonHidden ? null : (
40
42
  <Button
43
+ data-cy="CreateAccount-cancelButton"
41
44
  className={classes.cancelButton}
42
45
  disabled={isDisabled}
43
46
  type="button"
@@ -68,11 +71,12 @@ const CreateAccount = props => {
68
71
 
69
72
  return (
70
73
  <Form
74
+ data-cy="CreateAccount-form"
71
75
  className={classes.root}
72
76
  initialValues={initialValues}
73
77
  onSubmit={handleSubmit}
74
78
  >
75
- <h2 className={classes.title}>
79
+ <h2 data-cy="CreateAccount-title" className={classes.title}>
76
80
  <FormattedMessage
77
81
  id={'createAccount.createAccountText'}
78
82
  defaultMessage={'Create an Account'}
@@ -155,6 +159,7 @@ const CreateAccount = props => {
155
159
  })}
156
160
  />
157
161
  </div>
162
+ <GoogleRecaptcha {...recaptchaWidgetProps} />
158
163
  <div className={classes.actions}>
159
164
  {submitButton}
160
165
  {cancelButton}
@@ -35,6 +35,12 @@
35
35
  -webkit-appearance: none;
36
36
  }
37
37
 
38
+ .input:disabled {
39
+ background: rgb(var(--venia-global-color-gray-100));
40
+ border-color: rgb(var(--venia-global-color-gray-400));
41
+ color: rgb(var(--venia-global-color-gray-darker));
42
+ }
43
+
38
44
  .input:focus {
39
45
  box-shadow: -6px 6px rgb(var(--venia-brand-color-1-100));
40
46
  outline: none;