Skip to content

Commit 2739c8f

Browse files
ENGCOM-6047: Resolved Issue #24785 #24800
- Merge Pull Request #24800 from drpayyne/magento2:issue-24785 - Merged commits: 1. a289dc4 2. 68b7c4a 3. c1ddc0f
2 parents 0714971 + c1ddc0f commit 2739c8f

File tree

3 files changed

+155
-2
lines changed

3 files changed

+155
-2
lines changed

app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontDownloadableProductSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
<element name="downloadableLinkSampleByTitle" type="text" selector="//label[contains(., '{{title}}')]/a[contains(@class, 'sample link')]" parameterized="true"/>
1616
<element name="downloadableSampleLabel" type="text" selector="//a[contains(.,normalize-space('{{title}}'))]" parameterized="true" timeout="30"/>
1717
<element name="downloadableLinkSelectAllCheckbox" type="checkbox" selector="#links_all" />
18+
<element name="downloadableLinkSelectAllLabel" type="text" selector="label[for='links_all']" />
1819
</section>
1920
</sections>
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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="ManualSelectAllDownloadableLinksDownloadableProductTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Create Downloadable Product"/>
15+
<title value="Manual select all downloadable links downloadable product test"/>
16+
<description value="Manually selecting all downloadable links must change 'Select/Unselect all' button label to 'Unselect all', and 'Select all' otherwise"/>
17+
<severity value="MAJOR"/>
18+
<group value="Downloadable"/>
19+
</annotations>
20+
<before>
21+
<!-- Create category -->
22+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
23+
24+
<!-- Login as admin -->
25+
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
26+
27+
<!-- Create downloadable product -->
28+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="amOnProductGridPage"/>
29+
<waitForPageLoad stepKey="waitForProductGridPageLoad"/>
30+
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="createProduct">
31+
<argument name="productType" value="downloadable"/>
32+
</actionGroup>
33+
34+
<!-- Fill downloadable product values -->
35+
<actionGroup ref="fillMainProductFormNoWeight" stepKey="fillDownloadableProductForm">
36+
<argument name="product" value="DownloadableProduct"/>
37+
</actionGroup>
38+
39+
<!-- Add downloadable product to category -->
40+
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}"
41+
parameterArray="[$$createCategory.name$$]" stepKey="fillCategory"/>
42+
43+
<!-- Fill downloadable link information before the creation link -->
44+
<actionGroup ref="AdminAddDownloadableLinkInformationActionGroup" stepKey="addDownloadableLinkInformation"/>
45+
46+
<!-- Links can be purchased separately -->
47+
<checkOption selector="{{AdminProductDownloadableSection.isLinksPurchasedSeparately}}"
48+
stepKey="checkOptionPurchaseSeparately"/>
49+
50+
<!-- Add first downloadable link -->
51+
<actionGroup ref="addDownloadableProductLinkWithMaxDownloads" stepKey="addFirstDownloadableProductLink">
52+
<argument name="link" value="downloadableLinkWithMaxDownloads"/>
53+
</actionGroup>
54+
55+
<!-- Add second downloadable link -->
56+
<actionGroup ref="addDownloadableProductLink" stepKey="addSecondDownloadableProductLink">
57+
<argument name="link" value="downloadableLink"/>
58+
</actionGroup>
59+
60+
<!-- Save product -->
61+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
62+
</before>
63+
<after>
64+
<!-- Delete category -->
65+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
66+
67+
<!-- Delete created downloadable product -->
68+
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct">
69+
<argument name="product" value="DownloadableProduct"/>
70+
</actionGroup>
71+
72+
<!-- Log out -->
73+
<actionGroup ref="logout" stepKey="logout"/>
74+
</after>
75+
76+
<!-- Step 1: Navigate to store front Product page as guest -->
77+
<amOnPage url="/{{DownloadableProduct.sku}}.html"
78+
stepKey="amOnStorefrontProductPage"/>
79+
80+
<!-- Step 2: Check first downloadable link checkbox -->
81+
<click
82+
selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLinkWithMaxDownloads.title)}}"
83+
stepKey="selectFirstCheckbox"/>
84+
85+
<!-- Step 3: Check second downloadable link checkbox -->
86+
<click
87+
selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}"
88+
stepKey="selectSecondCheckbox"/>
89+
90+
<!-- Step 4: Grab "Select/Unselect All" button label text -->
91+
<grabTextFrom
92+
selector="{{StorefrontDownloadableProductSection.downloadableLinkSelectAllLabel}}"
93+
stepKey="grabUnselectAllButtonText"/>
94+
95+
<!-- Step 5: Assert that 'Select/Unselect all' button text is 'Unselect all' after manually checking all checkboxes -->
96+
<assertEquals
97+
message="Assert that 'Select/Unselect all' button text is 'Unselect all' after manually checking all checkboxes"
98+
stepKey="assertButtonTextOne">
99+
<expectedResult type="string">Unselect all</expectedResult>
100+
<actualResult type="string">{$grabUnselectAllButtonText}</actualResult>
101+
</assertEquals>
102+
103+
<!-- Step 6: Uncheck second downloadable link checkbox -->
104+
<click
105+
selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}"
106+
stepKey="unselectSecondCheckbox"/>
107+
108+
<!-- Step 7: Grab "Select/Unselect All" button label text -->
109+
<grabTextFrom
110+
selector="{{StorefrontDownloadableProductSection.downloadableLinkSelectAllLabel}}"
111+
stepKey="grabSelectAllButtonText"/>
112+
113+
<!-- Step 8: Assert that 'Select/Unselect all' button text is 'Select all' after manually unchecking one checkbox -->
114+
<assertEquals
115+
message="Assert that 'Select/Unselect all' button text is 'Select all' after manually unchecking one checkbox"
116+
stepKey="assertButtonTextTwo">
117+
<expectedResult type="string">Select all</expectedResult>
118+
<actualResult type="string">{$grabSelectAllButtonText}</actualResult>
119+
</assertEquals>
120+
121+
</test>
122+
</tests>

app/code/Magento/Downloadable/view/frontend/web/js/downloadable.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ define([
1010
'jquery-ui-modules/widget',
1111
'Magento_Catalog/js/price-box'
1212
], function ($) {
13-
'use strict';
1413

14+
/**
15+
* Downloadable widget
16+
*/
1517
$.widget('mage.downloadable', {
1618
options: {
1719
priceHolderSelector: '.price-box'
1820
},
1921

20-
/** @inheritdoc */
22+
/**
23+
* @inheritdoc
24+
*/
2125
_create: function () {
2226
var self = this;
2327

@@ -65,6 +69,32 @@ define([
6569
}
6670
}
6771
});
72+
73+
this.reloadAllCheckText();
74+
},
75+
76+
/**
77+
* Reload all-elements-checkbox's label
78+
* @private
79+
*/
80+
reloadAllCheckText: function () {
81+
let allChecked = true,
82+
allElementsCheck = $(this.options.allElements),
83+
allElementsLabel = $('label[for="' + allElementsCheck.attr('id') + '"] > span');
84+
85+
$(this.options.linkElement).each(function () {
86+
if (!this.checked) {
87+
allChecked = false;
88+
}
89+
});
90+
91+
if (allChecked) {
92+
allElementsLabel.text(allElementsCheck.attr('data-checked'));
93+
allElementsCheck.prop('checked', true);
94+
} else {
95+
allElementsLabel.text(allElementsCheck.attr('data-notchecked'));
96+
allElementsCheck.prop('checked', false);
97+
}
6898
}
6999
});
70100

0 commit comments

Comments
 (0)