Skip to content

Commit 543e1ee

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-96406' into EPAM-PR-36
2 parents 9e07431 + 45df4a7 commit 543e1ee

File tree

12 files changed

+289
-18
lines changed

12 files changed

+289
-18
lines changed

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,20 @@
4747
<seeElement selector="{{AdminProductMessagesSection.successMessage}}"
4848
stepKey="waitForSuccessMessage"/>
4949
</actionGroup>
50+
<actionGroup name="deleteProductAttributeByLabel">
51+
<arguments>
52+
<argument name="ProductAttribute"/>
53+
</arguments>
54+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/>
55+
<fillField selector="{{AdminProductAttributeGridSection.FilterByAttributeCode}}"
56+
userInput="{{ProductAttribute.default_label}}" stepKey="setAttributeCode"/>
57+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="searchForAttributeFromTheGrid"/>
58+
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnAttributeRow"/>
59+
<waitForPageLoad stepKey="waitForPageLoad"/>
60+
<click selector="{{AttributePropertiesSection.DeleteAttribute}}" stepKey="deleteAttribute"/>
61+
<click selector="{{ModalConfirmationSection.OkButton}}" stepKey="ClickOnDeleteButton"/>
62+
<waitForPageLoad stepKey="waitForPageLoad1"/>
63+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}"
64+
stepKey="waitForSuccessMessage"/>
65+
</actionGroup>
5066
</actionGroups>

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
namespace Magento\CatalogWidget\Block\Product;
88

9+
use Magento\Catalog\Model\Product;
910
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\App\ActionInterface;
1012
use Magento\Framework\DataObject\IdentityInterface;
1113
use Magento\Framework\Pricing\PriceCurrencyInterface;
1214
use Magento\Framework\Serialize\Serializer\Json;
15+
use Magento\Framework\View\LayoutFactory;
1316
use Magento\Widget\Block\BlockInterface;
1417
use Magento\Framework\Url\EncoderInterface;
1518

@@ -96,11 +99,21 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem
9699
*/
97100
private $json;
98101

102+
/**
103+
* @var LayoutFactory
104+
*/
105+
private $layoutFactory;
106+
99107
/**
100108
* @var \Magento\Framework\Url\EncoderInterface|null
101109
*/
102110
private $urlEncoder;
103111

112+
/**
113+
* @var \Magento\Framework\View\Element\RendererList
114+
*/
115+
private $rendererListBlock;
116+
104117
/**
105118
* @param \Magento\Catalog\Block\Product\Context $context
106119
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
@@ -111,7 +124,10 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem
111124
* @param \Magento\Widget\Helper\Conditions $conditionsHelper
112125
* @param array $data
113126
* @param Json|null $json
127+
* @param LayoutFactory|null $layoutFactory
114128
* @param \Magento\Framework\Url\EncoderInterface|null $urlEncoder
129+
*
130+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
115131
*/
116132
public function __construct(
117133
\Magento\Catalog\Block\Product\Context $context,
@@ -123,6 +139,7 @@ public function __construct(
123139
\Magento\Widget\Helper\Conditions $conditionsHelper,
124140
array $data = [],
125141
Json $json = null,
142+
LayoutFactory $layoutFactory = null,
126143
EncoderInterface $urlEncoder = null
127144
) {
128145
$this->productCollectionFactory = $productCollectionFactory;
@@ -132,6 +149,7 @@ public function __construct(
132149
$this->rule = $rule;
133150
$this->conditionsHelper = $conditionsHelper;
134151
$this->json = $json ?: ObjectManager::getInstance()->get(Json::class);
152+
$this->layoutFactory = $layoutFactory ?: ObjectManager::getInstance()->get(LayoutFactory::class);
135153
$this->urlEncoder = $urlEncoder ?: ObjectManager::getInstance()->get(EncoderInterface::class);
136154
parent::__construct(
137155
$context,
@@ -228,6 +246,41 @@ public function getProductPriceHtml(
228246
return $price;
229247
}
230248

249+
/**
250+
* @inheritdoc
251+
*/
252+
protected function getDetailsRendererList()
253+
{
254+
if (empty($this->rendererListBlock)) {
255+
/** @var $layout \Magento\Framework\View\LayoutInterface */
256+
$layout = $this->layoutFactory->create(['cacheable' => false]);
257+
$layout->getUpdate()->addHandle('catalog_widget_product_list')->load();
258+
$layout->generateXml();
259+
$layout->generateElements();
260+
261+
$this->rendererListBlock = $layout->getBlock('category.product.type.widget.details.renderers');
262+
}
263+
return $this->rendererListBlock;
264+
}
265+
266+
/**
267+
* Get post parameters.
268+
*
269+
* @param Product $product
270+
* @return array
271+
*/
272+
public function getAddToCartPostParams(Product $product)
273+
{
274+
$url = $this->getAddToCartUrl($product);
275+
return [
276+
'action' => $url,
277+
'data' => [
278+
'product' => $product->getEntityId(),
279+
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlEncoder->encode($url),
280+
]
281+
];
282+
}
283+
231284
/**
232285
* @inheritdoc
233286
*/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!--
2+
~ Copyright © Magento, Inc. All rights reserved.
3+
~ See COPYING.txt for license details.
4+
-->
5+
6+
<!--
7+
~ Copyright © Magento, Inc. All rights reserved.
8+
~ See COPYING.txt for license details.
9+
-->
10+
11+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
12+
<body>
13+
<block class="Magento\Framework\View\Element\RendererList" name="category.product.type.widget.details.renderers">
14+
<block class="Magento\Framework\View\Element\Template" name="category.product.type.details.renderers.default" as="default"/>
15+
</block>
16+
</body>
17+
</page>

app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
use Magento\Framework\App\Action\Action;
67

78
// @codingStandardsIgnoreFile
89

910
/** @var \Magento\CatalogWidget\Block\Product\ProductsList $block */
1011
?>
1112
<?php if ($exist = ($block->getProductCollection() && $block->getProductCollection()->getSize())): ?>
12-
<?php
13+
<?php
1314
$type = 'widget-product-grid';
1415

1516
$mode = 'grid';
@@ -22,12 +23,12 @@
2223
$showCart = true;
2324
$templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
2425
$description = false;
25-
?>
26+
?>
2627
<div class="block widget block-products-list <?= /* @noEscape */ $mode ?>">
2728
<?php if ($block->getTitle()): ?>
28-
<div class="block-title">
29-
<strong><?= $block->escapeHtml(__($block->getTitle())) ?></strong>
30-
</div>
29+
<div class="block-title">
30+
<strong><?= $block->escapeHtml(__($block->getTitle())) ?></strong>
31+
</div>
3132
<?php endif ?>
3233
<div class="block-content">
3334
<?= /* @noEscape */ '<!-- ' . $image . '-->' ?>
@@ -51,26 +52,28 @@
5152
<?php if ($templateType): ?>
5253
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
5354
<?php endif; ?>
54-
<?php echo $block->getProductPriceHtml($_item, $type); ?>
55+
56+
<?= $block->getProductPriceHtml($_item, $type) ?>
57+
58+
<?= $block->getProductDetailsHtml($_item) ?>
59+
5560
<?php if ($showWishlist || $showCompare || $showCart): ?>
5661
<div class="product-item-inner">
5762
<div class="product-item-actions">
5863
<?php if ($showCart): ?>
5964
<div class="actions-primary">
6065
<?php if ($_item->isSaleable()): ?>
61-
<?php if (!$_item->getTypeInstance()->isPossibleBuyFromList($_item)): ?>
62-
<button class="action tocart primary" data-mage-init='{"redirectUrl":{"url":"<?= $block->escapeUrl($block->getAddToCartUrl($_item)) ?>"}}' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>">
63-
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
66+
<?php $postParams = $block->getAddToCartPostParams($_item); ?>
67+
<form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_item->getSku()) ?>" action="<?= /* @NoEscape */ $postParams['action'] ?>" method="post">
68+
<input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $postParams['data']['product'] ?>">
69+
<input type="hidden" name="<?= /* @escapeNotVerified */ Action::PARAM_NAME_URL_ENCODED ?>" value="<?= /* @escapeNotVerified */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
70+
<?= $block->getBlockHtml('formkey') ?>
71+
<button type="submit"
72+
title="<?= $block->escapeHtml(__('Add to Cart')) ?>"
73+
class="action tocart primary">
74+
<span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
6475
</button>
65-
<?php else: ?>
66-
<?php
67-
$postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper');
68-
$postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()])
69-
?>
70-
<button class="action tocart primary" data-post='<?= /* @noEscape */ $postData ?>' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>">
71-
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
72-
</button>
73-
<?php endif; ?>
76+
</form>
7477
<?php else: ?>
7578
<?php if ($_item->getIsSalable()): ?>
7679
<div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="CreateNewPageWithWidget">
11+
<arguments>
12+
<argument name="pageTitle" type="string" defaultValue="{{defaultCmsPage.title}}"/>
13+
<argument name="category" type="string"/>
14+
<argument name="condition" type="string"/>
15+
<argument name="widgetType" type="string"/>
16+
</arguments>
17+
<amOnPage url="{{CmsNewPagePage.url}}" stepKey="amOnCMSNewPage"/>
18+
<waitForPageLoad stepKey="waitForPageLoad"/>
19+
<fillField selector="{{CmsNewPagePageBasicFieldsSection.pageTitle}}" userInput="{{pageTitle}}" stepKey="fillFieldTitle"/>
20+
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickExpandContent"/>
21+
<click selector="{{CmsNewPagePageActionsSection.insertWidget}}" stepKey="clickToInsertWidget"/>
22+
<waitForPageLoad stepKey="waitForPageLoad1"/>
23+
<waitForElementVisible stepKey="waitForInsertWidgetTitle" selector="{{WidgetSection.InsertWidgetTitle}}"/>
24+
<selectOption selector="{{WidgetSection.WidgetType}}" userInput="{{widgetType}}" stepKey="selectCatalogProductsList"/>
25+
<waitForElementVisible selector="{{WidgetSection.AddParam}}" stepKey="waitForAddParam"/>
26+
<scrollTo selector="{{WidgetSection.AddParam}}" stepKey="scrollToAddParamElement"/>
27+
<click selector="{{WidgetSection.AddParam}}" stepKey="addParam"/>
28+
<selectOption selector="{{WidgetSection.ConditionsDropdown}}" userInput="{{condition}}" stepKey="selectCategory"/>
29+
<waitForElementVisible selector="{{WidgetSection.RuleParam}}" stepKey="waitForRuleParam"/>
30+
<click selector="{{WidgetSection.RuleParam}}" stepKey="clickToAddRuleParam"/>
31+
<click selector="{{WidgetSection.Chooser}}" stepKey="clickToSelectFromList"/>
32+
<waitForPageLoad stepKey="waitForPageLoad2"/>
33+
<click selector="{{WidgetSection.PreCreateCategory(category)}}" stepKey="selectPreCategory" />
34+
<click selector="{{WidgetSection.InsertWidget}}" stepKey="clickToSaveInsertedWidget"/>
35+
<waitForPageLoad stepKey="waitForPageLoad3"/>
36+
<click selector="{{CmsNewBlockBlockActionsSection.savePage}}" stepKey="saveCMSPage"/>
37+
<waitForElementVisible selector="{{CmsPagesPageActionsSection.savePageSuccessMessage}}" stepKey="waitForSuccessMessageLoggedOut" time="5"/>
38+
<see userInput="You saved the page." stepKey="seeSuccessMessage"/>
39+
</actionGroup>
40+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="defaultCmsPage" type="block">
12+
<data key="title" unique="suffix">CMSpage</data>
13+
</entity>
14+
</entities>

app/code/Magento/Cms/Test/Mftf/Section/CmsNewPagePageActionsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
<element name="content" type="input" selector="//textarea[@name='content']"/>
2323
<element name="spinner" type="input" selector='//div[@data-component="cms_page_form.cms_page_form"]' />
2424
<element name="saveAndClose" type="button" selector="#save_and_close" timeout="10"/>
25+
<element name="insertWidget" type="button" selector="//span[contains(text(),'Insert Widget...')]"/>
2526
</section>
2627
</sections>

app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminNewAttributePanel">
12+
<element name="useInSearch" type="select" selector="#is_searchable"/>
13+
<element name="visibleInAdvancedSearch" type="select" selector="#is_visible_in_advanced_search"/>
14+
<element name="comparableOnStorefront" type="select" selector="#is_comparable"/>
15+
<element name="useInLayeredNavigation" type="select" selector="#is_filterable"/>
16+
<element name="visibleOnCatalogPagesOnStorefront" type="select" selector="#is_visible_on_front"/>
17+
<element name="useInProductListing" type="select" selector="#used_in_product_listing"/>
18+
<element name="usedForStoringInProductListing" type="select" selector="#used_for_sort_by"/>
19+
<element name="storefrontPropertiesTab" selector="#front_fieldset-wrapper"/>
20+
<element name="storefrontPropertiesTitle" selector="//span[text()='Storefront Properties']"/>
1221
<element name="container" type="text" selector="#create_new_attribute"/>
1322
<element name="saveAttribute" type="button" selector="#save"/>
1423
<element name="newAttributeIFrame" type="iframe" selector="create_new_attribute_container"/>

app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,21 @@
6262
<seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSaveProductMessage"/>
6363
</actionGroup>
6464

65+
<actionGroup name="AddVisualSwatchToProductWithStorefrontConfigActionGroup" extends="AddVisualSwatchToProductActionGroup">
66+
<arguments>
67+
<argument name="attribute" defaultValue="visualSwatchAttribute"/>
68+
<argument name="option1" defaultValue="visualSwatchOption1"/>
69+
<argument name="option2" defaultValue="visualSwatchOption2"/>
70+
</arguments>
71+
72+
<!-- Go to Storefront Properties tab -->
73+
<click selector="{{AdminNewAttributePanel.storefrontPropertiesTab}}" stepKey="goToStorefrontPropertiesTab" after="fillDefaultStoreLabel2"/>
74+
<waitForElementVisible selector="{{AdminNewAttributePanel.storefrontPropertiesTitle}}" stepKey="waitTabLoad" after="goToStorefrontPropertiesTab"/>
75+
<selectOption selector="{{AdminNewAttributePanel.useInSearch}}" stepKey="switchOnUsInSearch" userInput="Yes" after="waitTabLoad"/>
76+
<selectOption selector="{{AdminNewAttributePanel.visibleInAdvancedSearch}}" stepKey="switchOnVisibleInAdvancedSearch" userInput="Yes" after="switchOnUsInSearch"/>
77+
<selectOption selector="{{AdminNewAttributePanel.comparableOnStorefront}}" stepKey="switchOnComparableOnStorefront" userInput="Yes" after="switchOnVisibleInAdvancedSearch"/>
78+
<selectOption selector="{{AdminNewAttributePanel.useInLayeredNavigation}}" stepKey="selectUseInLayer" userInput="Filterable (with results)" after="switchOnComparableOnStorefront"/>
79+
<selectOption selector="{{AdminNewAttributePanel.visibleOnCatalogPagesOnStorefront}}" stepKey="switchOnVisibleOnCatalogPagesOnStorefront" userInput="Yes" after="selectUseInLayer"/>
80+
<selectOption selector="{{AdminNewAttributePanel.useInProductListing}}" stepKey="switchOnUsedInProductListing" userInput="Yes" after="switchOnVisibleOnCatalogPagesOnStorefront"/>
81+
</actionGroup>
6582
</actionGroups>

app/code/Magento/Swatches/Test/Mftf/Section/StorefrontProductInfoMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="selectedSwatchValue" type="text" selector="//div[contains(@class, 'swatch-attribute') and contains(., '{{attr}}')]//span[contains(@class, 'swatch-attribute-selected-option')]" parameterized="true"/>
1515
<element name="swatchAttributeOptions" type="text" selector="div.swatch-attribute-options"/>
1616
<element name="nthSwatchOptionText" type="button" selector="div.swatch-option.text:nth-of-type({{n}})" parameterized="true"/>
17+
<element name="productSwatch" type="button" selector="//div[@class='swatch-option'][@aria-label='{{var1}}']" parameterized="true"/>
1718
</section>
1819
</sections>

0 commit comments

Comments
 (0)