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 6
6
7
7
use Magento \Framework \App \Action \Action ;
8
8
9
- /** @var \Magento\CatalogWidget\Block\Product\ProductsList $block */
9
+ /**
10
+ * @var \Magento\CatalogWidget\Block\Product\ProductsList $block
11
+ * @var \Magento\Framework\Escaper $escaper
12
+ */
10
13
11
14
// phpcs:disable Generic.Files.LineLength.TooLong
12
15
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
16
+ // phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
13
17
?>
14
18
<?php if ($ exist = ($ block ->getProductCollection () && $ block ->getProductCollection ()->getSize ())): ?>
15
19
<?php
@@ -76,6 +80,17 @@ use Magento\Framework\App\Action\Action;
76
80
<span><?= $ block ->escapeHtml (__ ('Add to Cart ' )) ?> </span>
77
81
</button>
78
82
</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 ;?>
79
94
<?php else : ?>
80
95
<?php if ($ _item ->isAvailable ()): ?>
81
96
<div class="stock available"><span><?= $ block ->escapeHtml (__ ('In stock ' )) ?> </span></div>
@@ -113,13 +128,4 @@ use Magento\Framework\App\Action\Action;
113
128
<?= $ block ->getPagerHtml () ?>
114
129
</div>
115
130
</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 ;?>
125
131
<?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