Skip to content

Commit 750869f

Browse files
author
Joan He
committed
Merge remote-tracking branch 'owls/MAGETWO-94807-shop-by-button-is-not-working-in-a-mobile-theme' into BugFixPR
2 parents 79feac9 + 960a2d3 commit 750869f

File tree

5 files changed

+89
-7
lines changed

5 files changed

+89
-7
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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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="urn:magento:mftf: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+
<resizeWindow width="1280" height="1024" stepKey="resizeWindowToDesktop"/>
39+
</after>
40+
<!-- Go to default attribute set edit page and add the product attribute to the set -->
41+
<comment userInput="Go to default attribute set edit page and add the product attribute to the set" stepKey="commentAttributeSetEdit" />
42+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/>
43+
<dragAndDrop selector1="{{AdminProductAttributeSetSection.attribute($$attribute.attribute[attribute_code]$$)}}" selector2="{{AdminProductAttributeSetSection.attribute('Product Details')}}" stepKey="assignTestAttributes"/>
44+
<click selector="{{AdminProductAttributeSetSection.saveBtn}}" stepKey="clickAttributeSetSave"/>
45+
<!-- Go to simple product edit page and set the product attribute to a value -->
46+
<comment userInput="Go to simple product edit page and set the product attribute to a value" stepKey="commentProductAttributeEdit" />
47+
<amOnPage url="{{AdminProductEditPage.url($$simpleProduct1.id$$)}}" stepKey="goToEditPage"/>
48+
<selectOption selector="{{AdminProductFormSection.customSelectField($$attribute.attribute[attribute_code]$$)}}" userInput="option1" stepKey="selectAttribute"/>
49+
<actionGroup ref="saveProductForm" stepKey="saveSimpleProduct"/>
50+
<!-- Check storefront mobile view for shop by button is functioning as expected -->
51+
<comment userInput="Check storefront mobile view for shop by button is functioning as expected" stepKey="commentCheckShopByButton" />
52+
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToHomePage"/>
53+
<waitForPageLoad stepKey="waitForHomePageToLoad"/>
54+
<fillField userInput="Test Simple Product" selector="{{StorefrontQuickSearchSection.searchPhrase}}" stepKey="fillSearchBar"/>
55+
<click selector="{{StorefrontQuickSearchSection.searchButton}}" stepKey="clickSearchButton"/>
56+
<resizeWindow width="600" height="800" stepKey="resizeWindow"/>
57+
<waitForPageLoad stepKey="waitForHomePageToLoad2"/>
58+
<seeElement selector="{{StorefrontCategorySidebarMobileSection.shopByButton}}" stepKey="seeShopByButton"/>
59+
<click selector="{{StorefrontCategorySidebarMobileSection.shopByButton}}" stepKey="clickShopByButton"/>
60+
<seeElement selector="{{StorefrontCategorySidebarSection.filterOptionsTitle('$$attribute.attribute[default_label]$$')}}" stepKey="seeShopByOption"/>
61+
</test>
62+
</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 () {

lib/web/mage/collapsible.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,23 @@ define([
442442

443443
/**
444444
* Activate.
445+
*
446+
* @return void;
445447
*/
446448
activate: function () {
447-
if (!this.options.disabled) {
448-
if (this.options.animate) {
449-
this._animate(showProps);
450-
} else {
449+
if (this.options.disabled) {
450+
return;
451+
}
452+
453+
if (this.options.animate) {
454+
this._animate(showProps);
455+
} else {
456+
if (this.content.length) {
451457
this._scrollToTopIfVisible(this.content.get(0).parentElement);
452-
this.content.show();
453458
}
454-
this._open();
459+
this.content.show();
455460
}
461+
this._open();
456462
},
457463

458464
/**

0 commit comments

Comments
 (0)