File tree Expand file tree Collapse file tree 2 files changed +43
-10
lines changed
CatalogWidget/view/frontend/templates/product/widget/content
Sales/Test/Mftf/ActionGroup Expand file tree Collapse file tree 2 files changed +43
-10
lines changed Original file line number Diff line number Diff line change 66
77use Magento \Framework \App \Action \Action ;
88
9- /** @var \Magento\CatalogWidget\Block\Product\ProductsList $block */
9+ /**
10+ * @var \Magento\CatalogWidget\Block\Product\ProductsList $block
11+ * @var \Magento\Framework\Escaper $escaper
12+ */
1013
1114// phpcs:disable Generic.Files.LineLength.TooLong
1215// phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
16+ // phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
1317?>
1418<?php if ($ exist = ($ block ->getProductCollection () && $ block ->getProductCollection ()->getSize ())): ?>
1519 <?php
@@ -76,6 +80,17 @@ use Magento\Framework\App\Action\Action;
7680 <span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
7781 </button>
7882 </form>
83+ <?php if ($ block ->getBlockHtml ('formkey ' )): ?>
84+ <script type="text/x-magento-init">
85+ {
86+ "[data-role=tocart-form], .form.map.checkout": {
87+ "catalogAddToCart": {
88+ "product_sku": "<?= $ escaper ->escapeJs ($ _item ->getSku ()); ?> "
89+ }
90+ }
91+ }
92+ </script>
93+ <?php endif ;?>
7994 <?php else : ?>
8095 <?php if ($ _item ->isAvailable ()): ?>
8196 <div class="stock available"><span><?= $ block ->escapeHtml (__ ('In stock ' )) ?> </span></div>
@@ -113,13 +128,4 @@ use Magento\Framework\App\Action\Action;
113128 <?= $ block ->getPagerHtml () ?>
114129 </div>
115130 </div>
116- <?php if ($ block ->getBlockHtml ('formkey ' )): ?>
117- <script type="text/x-magento-init">
118- {
119- ".block.widget [data-role=tocart-form]": {
120- "Magento_Catalog/js/validate-product": {}
121- }
122- }
123- </script>
124- <?php endif ;?>
125131<?php endif ;?>
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!--
3+ /**
4+ * Copyright © Magento, Inc. All rights reserved.
5+ * See COPYING.txt for license details.
6+ */
7+ -->
8+
9+ <actionGroups xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
10+ xsi : noNamespaceSchemaLocation =" urn:magento:mftf:Test/etc/actionGroupSchema.xsd" >
11+ <actionGroup name =" StorefrontAssertProductQtyInMinicartActionGroup" >
12+ <annotations >
13+ <description >Open the mini cart, locate the provided product and assert the quantity of it that was added to the cart</description >
14+ </annotations >
15+ <arguments >
16+ <argument name =" product" type =" entity" />
17+ <argument name =" qty" type =" string" defaultValue =" 1" />
18+ </arguments >
19+
20+ <click selector =" {{StorefrontMinicartSection.showCart}}" stepKey =" openMiniShoppingCart" />
21+ <grabValueFrom selector =" {{StorefrontMinicartSection.itemQuantityBySku(product.sku)}}" stepKey =" grabMiniCartQty" />
22+ <assertStringContainsString stepKey =" assertMiniCartQty" >
23+ <actualResult type =" variable" >$grabMiniCartQty</actualResult >
24+ <expectedResult type =" string" >{{qty}}</expectedResult >
25+ </assertStringContainsString >
26+ </actionGroup >
27+ </actionGroups >
You can’t perform that action at this time.
0 commit comments