Skip to content

Commit 1767459

Browse files
author
Hwashiang Yu
committed
MAGETWO-94807: Shop By button is not working in a mobile theme
- Added unit and mftf test coverage
1 parent 4a4bce2 commit 1767459

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<element name="setProductAsNewFrom" type="input" selector="input[name='product[news_from_date]']"/>
4848
<element name="setProductAsNewTo" type="input" selector="input[name='product[news_to_date]']"/>
4949
<element name="attributeLabelByText" type="text" selector="//*[@class='admin__field']//span[text()='{{attributeLabel}}']" parameterized="true"/>
50+
<element name="customSelectField" type="select" selector="//select[@name='product[{{var}}]']" parameterized="true"/>
5051
</section>
5152
<section name="ProductInWebsitesSection">
5253
<element name="sectionHeader" type="button" selector="div[data-index='websites']" timeout="30"/>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@
1313
<element name="filterOption" type="text" selector=".filter-options-content .item"/>
1414
<element name="optionQty" type="text" selector=".filter-options-content .item .count"/>
1515
</section>
16+
<section name="StorefrontCategorySidebarMobileSection">
17+
<element name="shopByButton" type="button" selector="//div[contains(@class, 'filter-title')]/strong[contains(text(), 'Shop By')]"/>
18+
</section>
1619
</sections>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="ShopByButtonInMobile">
12+
<annotations>
13+
<features value="Layered Navigation"/>
14+
<stories value="Shop By button is not working in a mobile theme"/>
15+
<title value="Layered Navigation"/>
16+
<description value="Storefront Shop By collapsible button works in a mobile theme"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MAGETWO-94873"/>
19+
<group value="LayeredNavigation"/>
20+
</annotations>
21+
<before>
22+
<createData entity="productDropDownAttribute" stepKey="attribute"/>
23+
<createData entity="productAttributeOption1" stepKey="option1">
24+
<requiredEntity createDataKey="attribute"/>
25+
</createData>
26+
<createData entity="AddToDefaultSet" stepKey="attributeSet">
27+
<requiredEntity createDataKey="attribute"/>
28+
</createData>
29+
<createData entity="SimpleProduct2" stepKey="simpleProduct1"/>
30+
<createData entity="SimpleProduct2" stepKey="simpleProduct2"/>
31+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
32+
</before>
33+
<after>
34+
<deleteData createDataKey="attribute" stepKey="deleteAttribute"/>
35+
<deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/>
36+
<deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/>
37+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
38+
</after>
39+
<!-- Go to default attribute set edit page and add the product attribute to the set -->
40+
<comment userInput="Go to default attribute set edit page and add the product attribute to the set" stepKey="commentAttributeSetEdit" />
41+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/>
42+
<dragAndDrop selector1="{{AdminProductAttributeSetSection.attribute($$attribute.attribute[attribute_code]$$)}}" selector2="{{AdminProductAttributeSetSection.attribute('Product Details')}}" stepKey="assignTestAttributes"/>
43+
<click selector="{{AdminProductAttributeSetSection.saveBtn}}" stepKey="clickAttributeSetSave"/>
44+
<!-- Go to simple product edit page and set the product attribute to a value -->
45+
<comment userInput="Go to simple product edit page and set the product attribute to a value" stepKey="commentProductAttributeEdit" />
46+
<amOnPage url="{{AdminProductEditPage.url($$simpleProduct1.id$$)}}" stepKey="goToEditPage"/>
47+
<selectOption selector="{{AdminProductFormSection.customSelectField($$attribute.attribute[attribute_code]$$)}}" userInput="option1" stepKey="selectAttribute"/>
48+
<actionGroup ref="saveProductForm" stepKey="saveSimpleProduct"/>
49+
<!-- Check storefront mobile view for shop by button is functioning as expected -->
50+
<comment userInput="Check storefront mobile view for shop by button is functioning as expected" stepKey="commentCheckShopByButton" />
51+
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToHomePage"/>
52+
<waitForPageLoad stepKey="waitForHomePageToLoad"/>
53+
<fillField userInput="Test Simple Product" selector="{{StorefrontQuickSearchSection.searchPhrase}}" stepKey="fillSearchBar"/>
54+
<click selector="{{StorefrontQuickSearchSection.searchButton}}" stepKey="clickSearchButton"/>
55+
<resizeWindow width="600" height="800" stepKey="resizeWindow"/>
56+
<waitForPageLoad stepKey="waitForHomePageToLoad2"/>
57+
<seeElement selector="{{StorefrontCategorySidebarMobileSection.shopByButton}}" stepKey="seeShopByButton"/>
58+
<click selector="{{StorefrontCategorySidebarMobileSection.shopByButton}}" stepKey="clickShopByButton"/>
59+
<seeElement selector="{{StorefrontCategorySidebarSection.filterOptionsTitle('$$attribute.attribute[default_label]$$')}}" stepKey="seeShopByOption"/>
60+
</test>
61+
</tests>

dev/tests/js/jasmine/tests/lib/mage/collapsible.test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ define([
2626

2727
describe('Test enable, disable, activate and deactivate methods', function () {
2828
var group = $('<div id="2"></div>'),
29-
content = $('<div data-role="content"></div>').appendTo(group);
29+
content = $('<div data-role="content"></div>').appendTo(group),
30+
emptyGroup = $('<div></div>');
3031

3132
$('<div data-role="title"></div>').prependTo(group);
3233

@@ -65,6 +66,15 @@ define([
6566
group.collapsible('destroy');
6667
expect(group.is(':mage-collapsible')).toBeFalsy();
6768
});
69+
70+
it('check activate method on empty group', function () {
71+
emptyGroup.collapsible();
72+
expect(emptyGroup.is(':mage-collapsible')).toBeTruthy();
73+
74+
expect(function () {
75+
emptyGroup.collapsible('activate');
76+
}).not.toThrow();
77+
});
6878
});
6979

7080
it('check if the widget gets expanded/collapsed when the title is clicked', function () {

0 commit comments

Comments
 (0)