Skip to content

Commit 5c5ebc0

Browse files
committed
MAGETWO-98522: Adding out of stock items to comparison shows success message but fails
- Updated automated test script.
1 parent 99d0496 commit 5c5ebc0

File tree

4 files changed

+104
-22
lines changed

4 files changed

+104
-22
lines changed

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

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,83 @@
77
-->
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1111
<test name="AddOutOfStockProductToCompareListTest">
1212
<annotations>
1313
<features value="Catalog"/>
14-
<title value="Adding to compare list if a product is out of stock"/>
15-
<description value="Adding to compare list if a product is out of stock"/>
14+
<title value="Add out of stock product to compare list"/>
15+
<description value="Add out of stock product to compare list"/>
1616
<severity value="MAJOR"/>
1717
<testCaseId value="MAGETWO-98644"/>
1818
<useCaseId value="MAGETWO-98522"/>
1919
<group value="Catalog"/>
2020
</annotations>
2121
<before>
2222
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23-
<createData entity="ApiCategory" stepKey="category"/>
24-
<createData entity="SimpleOutOfStockProduct" stepKey="product">
23+
<createData entity="DisableDisplayOutOfStock" stepKey="displayOutOfStockNo"/>
24+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
25+
<createData entity="SimpleSubCategory" stepKey="category"/>
26+
<createData entity="SimpleProduct4" stepKey="product">
2527
<requiredEntity createDataKey="category"/>
2628
</createData>
2729
</before>
2830
<after>
31+
<actionGroup ref="setAsDefaultOutOfStockProduct" stepKey="setAsDefaultOutOfStockProduct"/>
32+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
2933
<deleteData createDataKey="product" stepKey="deleteProduct"/>
3034
<deleteData createDataKey="category" stepKey="deleteCategory"/>
31-
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
32-
</after>
33-
34-
<!--Check 'out of stock' is turned off by default-->
35-
<actionGroup ref="noDisplayOutOfStockProduct" stepKey="noDisplayOutOfStockProduct"/>
35+
<actionGroup ref="logout" stepKey="logout"/>
3636

37+
</after>
3738
<!--Open product page-->
38-
<amOnPage url="$$product.name$$.html" stepKey="goToSimpleProductPage"/>
39+
<comment userInput="Open product page" stepKey="openProdPage"/>
40+
<amOnPage url="{{StorefrontProductPage.url($$product.name$$)}}" stepKey="goToSimpleProductPage"/>
3941
<waitForPageLoad stepKey="waitForSimpleProductPage"/>
40-
4142
<!--'Add to compare' link is not available-->
43+
<comment userInput="'Add to compare' link is not available" stepKey="addToCompareLinkAvailability"/>
4244
<dontSeeElement selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="dontSeeAddToCompareLink"/>
43-
44-
<!--Turn on 'out of stock' config-->
45-
<actionGroup ref="displayOutOfStockProduct" stepKey="displayOutOfStockProduct"/>
46-
47-
<!--Clear cache-->
48-
<actionGroup ref="ClearCacheActionGroup" stepKey="clearCache" />
49-
45+
<!--Turn on 'out on stock' config-->
46+
<comment userInput="Turn on 'out of stock' config" stepKey="onOutOfStockConfig"/>
47+
<createData entity="EnableDisplayOutOfStock" stepKey="displayOutOfStockYes"/>
48+
<!--Clear cache and reindex-->
49+
<comment userInput="Clear cache and reindex" stepKey="cleanCache"/>
50+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
51+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
5052
<!--Open product page-->
51-
<amOnPage url="$$product.name$$.html" stepKey="goToSimpleProductPage2"/>
53+
<comment userInput="Open product page" stepKey="openProductPage"/>
54+
<amOnPage url="{{StorefrontProductPage.url($$product.name$$)}}" stepKey="goToSimpleProductPage2"/>
5255
<waitForPageLoad stepKey="waitForSimpleProductPage2"/>
53-
5456
<!--Click on 'Add to Compare' link-->
57+
<comment userInput="Click on 'Add to Compare' link" stepKey="clickOnAddToCompareLink"/>
5558
<click selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="clickOnAddToCompare"/>
56-
59+
<waitForPageLoad stepKey="waitForProdAddToCmpList"/>
60+
<!--Assert success message-->
61+
<comment userInput="Assert success message" stepKey="assertSuccessMsg"/>
62+
<grabTextFrom selector="{{AdminProductMessagesSection.successMessage}}" stepKey="grabTextFromSuccessMessage"/>
63+
<assertEquals expected='You added product $$product.name$$ to the comparison list.' expectedType="string" actual="($grabTextFromSuccessMessage)" stepKey="assertSuccessMessage"/>
5764
<!--See product in the comparison list-->
65+
<comment userInput="See product in the comparison list" stepKey="seeProductInComparisonList"/>
5866
<amOnPage url="{{StorefrontProductComparePage.url}}" stepKey="navigateToComparePage"/>
67+
<waitForPageLoad stepKey="waitForStorefrontProductComparePageLoad"/>
5968
<seeElement selector="{{StorefrontProductCompareMainSection.ProductLinkByName($product.name$)}}" stepKey="seeProductInCompareList"/>
69+
<!--Add product to compare list fom Category page-->
70+
<comment userInput="Add product to compare list fom Category page" stepKey="addToCmpFromCategPage"/>
71+
<amOnPage url="{{StorefrontCategoryPage.url($$category.name$$)}}" stepKey="onCategoryPage"/>
72+
<waitForPageLoad time="30" stepKey="waitForPageLoad1"/>
73+
<moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverOverProduct"/>
74+
<click selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="clickAddToCompare"/>
75+
<waitForPageLoad stepKey="waitProdAddingToCmpList"/>
76+
<!--Assert success message-->
77+
<comment userInput="Assert success message" stepKey="assertSuccessMsg2"/>
78+
<grabTextFrom selector="{{AdminProductMessagesSection.successMessage}}" stepKey="grabTextFromSuccessMessage2"/>
79+
<assertEquals expected='You added product $$product.name$$ to the comparison list.' expectedType="string" actual="($grabTextFromSuccessMessage)" stepKey="assertSuccessMessage2"/>
80+
<!--Check that product displays on add to compare widget-->
81+
<comment userInput="Check that product displays on add to compare widget" stepKey="checkProdNameOnWidget"/>
82+
<seeElement selector="{{StorefrontComparisonSidebarSection.ProductTitleByName($$product.name$$)}}" stepKey="seeProdNameOnCmpWidget"/>
83+
<!--See product in the compare page-->
84+
<comment userInput="See product in the compare page" stepKey="seeProductInComparePage"/>
85+
<amOnPage url="{{StorefrontProductComparePage.url}}" stepKey="navigateToComparePage2"/>
86+
<waitForPageLoad stepKey="waitForStorefrontProductComparePageLoad2"/>
87+
<seeElement selector="{{StorefrontProductCompareMainSection.ProductLinkByName($product.name$)}}" stepKey="seeProductInCompareList2"/>
6088
</test>
6189
</tests>

app/code/Magento/CatalogInventory/Test/Mftf/ActionGroup/DisplayOutOfStockProductActionGroup.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,13 @@
2626
<selectOption selector="{{InventoryConfigSection.DisplayOutOfStockDropdown}}" userInput="No" stepKey="switchToNo" />
2727
<click selector="{{ContentManagementSection.Save}}" stepKey="clickSaveConfig" />
2828
</actionGroup>
29+
<actionGroup name="setAsDefaultOutOfStockProduct">
30+
<amOnPage url="{{InventoryConfigurationPage.url}}" stepKey="navigateToInventoryConfigurationPage"/>
31+
<waitForPageLoad time="30" stepKey="waitForConfigPageToLoad"/>
32+
<conditionalClick selector="{{InventoryConfigSection.ProductStockOptionsTab}}" dependentSelector="{{InventoryConfigSection.DisplayOutOfStockSystemValue}}" visible="false" stepKey="expandStockOptions"/>
33+
<waitForElementVisible selector="{{InventoryConfigSection.DisplayOutOfStockSystemValue}}" time="30" stepKey="waitForCheckBoxVisible"/>
34+
<checkOption selector="{{InventoryConfigSection.DisplayOutOfStockSystemValue}}" stepKey="uncheckUseSystemValue"/>
35+
<click selector="{{ContentManagementSection.Save}}" stepKey="clickSaveConfig"/>
36+
<waitForPageLoad time="30" stepKey="waitForConfigPageToLoad2"/>
37+
</actionGroup>
2938
</actionGroups>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="AdminDisplayOutOfStockYes" type="enable">
12+
<data key="value">1</data>
13+
</entity>
14+
<entity name="AdminDisplayOutOfStockNo" type="enable">
15+
<data key="value">0</data>
16+
</entity>
17+
<entity name="EnableDisplayOutOfStock" type="admin_out_of_stock_products_config">
18+
<requiredEntity type="enable">AdminDisplayOutOfStockYes</requiredEntity>
19+
</entity>
20+
<entity name="DisableDisplayOutOfStock" type="admin_out_of_stock_products_config">
21+
<requiredEntity type="enable">AdminDisplayOutOfStockNo</requiredEntity>
22+
</entity>
23+
</entities>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
11+
<operation name="AdminOutOfStockProductsConfig" dataType="admin_out_of_stock_products_config" type="create" auth="adminFormKey" url="/admin/system_config/save/section/cataloginventory/" method="POST">
12+
<object key="groups" dataType="admin_out_of_stock_products_config">
13+
<object key="options" dataType="admin_out_of_stock_products_config">
14+
<object key="fields" dataType="admin_out_of_stock_products_config">
15+
<object key="show_out_of_stock" dataType="enable">
16+
<field key="value">string</field>
17+
</object>
18+
</object>
19+
</object>
20+
</object>
21+
</operation>
22+
</operations>

0 commit comments

Comments
 (0)