Skip to content

Commit a32d27b

Browse files
committed
Fix static and functional tests.
1 parent a6f266d commit a32d27b

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/AdminSortingByWebsitesTest.xml

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,71 +15,64 @@
1515
<description value="Sorting products by websites in Admin"/>
1616
</annotations>
1717
<before>
18+
<createData entity="_defaultCategory" stepKey="createCategory"/>
19+
<createData entity="_defaultProduct" stepKey="productAssignedToCustomWebsite">
20+
<requiredEntity createDataKey="createCategory"/>
21+
</createData>
22+
<createData entity="SimpleProduct" stepKey="productAssignedToMainWebsite">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
1826
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
1927
<!--Create new website -->
2028
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createAdditionalWebsite">
2129
<argument name="newWebsiteName" value="{{customWebsite.name}}"/>
2230
<argument name="websiteCode" value="{{customWebsite.code}}"/>
2331
</actionGroup>
32+
<actionGroup ref="EnableWebUrlOptions" stepKey="addStoreCodeToUrls"/>
33+
<magentoCLI command="cache:flush" stepKey="flushCacheAfterEnableWebUrlOptions"/>
2434
</before>
2535
<after>
36+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
37+
<deleteData createDataKey="productAssignedToCustomWebsite" stepKey="deleteProductAssignedToCustomWebsite"/>
38+
<deleteData createDataKey="productAssignedToMainWebsite" stepKey="deleteProductAssignedToMainWebsite"/>
2639
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteTestWebsite">
2740
<argument name="websiteName" value="{{customWebsite.name}}"/>
2841
</actionGroup>
42+
<actionGroup ref="ResetWebUrlOptions" stepKey="resetUrlOption"/>
43+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
44+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
2945
<actionGroup ref="logout" stepKey="logout"/>
3046
</after>
3147

32-
<actionGroup ref="EnableWebUrlOptions" stepKey="addStoreCodeToUrls"/>
33-
<!--Create a Simple Product -->
48+
<!--Assign Custom Website to Simple Product -->
3449
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGrid"/>
3550
<waitForPageLoad stepKey="waitForCatalogProductGrid"/>
36-
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/>
37-
<click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickAddSimpleProduct"/>
38-
<fillField userInput="{{_defaultProduct.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillName"/>
39-
<fillField userInput="{{_defaultProduct.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillSKU"/>
40-
<fillField userInput="{{_defaultProduct.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillPrice"/>
41-
<fillField userInput="{{_defaultProduct.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillQuantity"/>
4251

43-
<!--Save the product -->
44-
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveButton"/>
45-
<waitForLoadingMaskToDisappear stepKey="waitProductPageSave"/>
46-
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeProductSavedMessage"/>
52+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/>
53+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="assignCustomWebsiteToProduct">
54+
<argument name="product" value="$$productAssignedToCustomWebsite$$"/>
55+
</actionGroup>
56+
<scrollTo selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="scrollToWebsites"/>
57+
<conditionalClick selector="{{ProductInWebsitesSection.sectionHeader}}" dependentSelector="{{AdminProductContentSection.sectionHeaderShow}}" visible="false" stepKey="expandSection"/>
58+
<waitForPageLoad stepKey="waitForPageOpened"/>
59+
<uncheckOption selector="{{ProductInWebsitesSection.website(_defaultWebsite.name)}}" stepKey="deselectMainWebsite"/>
60+
<checkOption selector="{{ProductInWebsitesSection.website(customWebsite.name)}}" stepKey="selectWebsite"/>
4761

48-
<!-- Add this product to second website -->
49-
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openProductInWebsitesSection1"/>
50-
<click selector="{{ProductInWebsitesSection.website('{{customWebsite.name}}')}}" stepKey="selectSecondWebsite"/>
5162
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSave"/>
52-
<waitForLoadingMaskToDisappear stepKey="waitForProductPagetoSaveAgain"/>
63+
<waitForLoadingMaskToDisappear stepKey="waitForProductPageToSaveAgain"/>
5364
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessageAgain"/>
5465

55-
<!--Create a Simple Product 2 -->
56-
<amOnPage url="{{ProductCatalogPage.url}}" stepKey="openProductCatalogPage"/>
57-
<waitForPageLoad stepKey="waitForProductCatalogPage"/>
58-
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductToggle"/>
59-
<waitForPageLoad stepKey="waitForProductToggleToSelectSimpleProduct"/>
60-
<click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickSimpleProductFromDropDownList"/>
61-
62-
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{nameAndAttributeSkuMaskSimpleProduct.name}}" stepKey="fillSimpleProductName"/>
63-
<fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{nameAndAttributeSkuMaskSimpleProduct.price}}" stepKey="fillSimpleProductPrice"/>
64-
<fillField selector="{{AdminProductFormSection.productWeight}}" userInput="{{nameAndAttributeSkuMaskSimpleProduct.weight}}" stepKey="fillSimpleProductWeight"/>
65-
<fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{nameAndAttributeSkuMaskSimpleProduct.quantity}}" stepKey="fillSimpleProductQuantity"/>
66-
<click selector="{{AdminProductFormSection.save}}" stepKey="clickSaveButton2"/>
67-
<waitForPageLoad stepKey="waitForSimpleProductToSave"/>
68-
<!-- Verify customer see success message -->
69-
<see selector="{{AdminProductFormSection.successMessage}}" userInput="You saved the product." stepKey="seeAssertSimpleProductSaveSuccessMessage"/>
70-
71-
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGrid2"/>
72-
<waitForPageLoad stepKey="waitForCatalogProductGrid2"/>
66+
<!--Navigate To Product Grid To Check Website Sorting-->
67+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGridToSortByWebsite"/>
68+
<waitForPageLoad stepKey="waitForCatalogProductGridLoaded"/>
7369

7470
<!--Sorting works (By Websites) ASC-->
75-
<actionGroup ref="resetProductGridToDefaultView" stepKey="setProductGridToDefaultSortingWebsites"/>
7671
<click selector="{{AdminProductGridSection.columnHeader('Websites')}}" stepKey="clickWebsitesHeaderToSortAsc"/>
7772
<see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="Main Website" stepKey="checkIfProduct1WebsitesAsc"/>
78-
<see selector="{{AdminProductGridSection.productGridContentsOnRow('2')}}" userInput="{{customWebsite.name}}" stepKey="checkIfProduct2WebsitesAsc"/>
7973

8074
<!--Sorting works (By Websites) DESC-->
8175
<click selector="{{AdminProductGridSection.columnHeader('Websites')}}" stepKey="clickWebsitesHeaderToSortDesc"/>
8276
<see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="{{customWebsite.name}}" stepKey="checkIfProduct1WebsitesDesc"/>
83-
<see selector="{{AdminProductGridSection.productGridContentsOnRow('2')}}" userInput="Main Website" stepKey="checkIfProduct2WebsitesDesc"/>
8477
</test>
8578
</tests>

app/code/Magento/Catalog/Ui/Component/Listing/Columns/Websites.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\Catalog\Ui\Component\Listing\Columns;
710

8-
use Magento\Framework\View\Element\UiComponentFactory;
11+
use Magento\Framework\DB\Helper;
912
use Magento\Framework\View\Element\UiComponent\ContextInterface;
13+
use Magento\Framework\View\Element\UiComponentFactory;
1014
use Magento\Store\Model\StoreManagerInterface;
11-
use Magento\Framework\DB\Helper;
1215

1316
/**
17+
* Websites listing column component.
18+
*
1419
* @api
1520
* @since 100.0.2
1621
*/
@@ -22,9 +27,9 @@ class Websites extends \Magento\Ui\Component\Listing\Columns\Column
2227
const NAME = 'websites';
2328

2429
/**
25-
* Data for concatenated website names value
30+
* Data for concatenated website names value.
2631
*/
27-
const WEBSITE_NAMES = 'website_names';
32+
private $websiteNames = 'website_names';
2833

2934
/**
3035
* Store manager
@@ -36,7 +41,7 @@ class Websites extends \Magento\Ui\Component\Listing\Columns\Column
3641
/**
3742
* @var \Magento\Framework\DB\Helper
3843
*/
39-
protected $_resourceHelper;
44+
private $resourceHelper;
4045

4146
/**
4247
* @param ContextInterface $context
@@ -57,11 +62,12 @@ public function __construct(
5762
parent::__construct($context, $uiComponentFactory, $components, $data);
5863
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
5964
$this->storeManager = $storeManager;
60-
$this->_resourceHelper = $resourceHelper ?: $objectManager->get(Helper::class);
65+
$this->resourceHelper = $resourceHelper ?: $objectManager->get(Helper::class);
6166
}
6267

6368
/**
64-
* {@inheritdoc}
69+
* @inheritdoc
70+
*
6571
* @deprecated 101.0.0
6672
*/
6773
public function prepareDataSource(array $dataSource)
@@ -86,9 +92,10 @@ public function prepareDataSource(array $dataSource)
8692

8793
return $dataSource;
8894
}
89-
95+
9096
/**
91-
* Prepare component configuration
97+
* Prepare component configuration.
98+
*
9299
* @return void
93100
*/
94101
public function prepare()
@@ -100,7 +107,7 @@ public function prepare()
100107
}
101108

102109
/**
103-
* Apply sorting
110+
* Apply sorting.
104111
*
105112
* @return void
106113
*/
@@ -131,13 +138,13 @@ protected function applySorting()
131138
'left'
132139
)
133140
->groupByAttribute('entity_id');
134-
$this->_resourceHelper->addGroupConcatColumn(
141+
$this->resourceHelper->addGroupConcatColumn(
135142
$collection->getSelect(),
136-
self::WEBSITE_NAMES,
143+
$this->websiteNames,
137144
'name'
138145
);
139146

140-
$collection->getSelect()->order(self::WEBSITE_NAMES . ' ' . $sorting['direction']);
147+
$collection->getSelect()->order($this->websiteNames . ' ' . $sorting['direction']);
141148
}
142149
}
143150
}

0 commit comments

Comments
 (0)