Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved Issue #24785 #24800

Merged
merged 5 commits into from Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,5 +15,6 @@
<element name="downloadableLinkSampleByTitle" type="text" selector="//label[contains(., '{{title}}')]/a[contains(@class, 'sample link')]" parameterized="true"/>
<element name="downloadableSampleLabel" type="text" selector="//a[contains(.,normalize-space('{{title}}'))]" parameterized="true" timeout="30"/>
<element name="downloadableLinkSelectAllCheckbox" type="checkbox" selector="#links_all" />
<element name="downloadableLinkSelectAllLabel" type="text" selector="label[for='links_all']" />
</section>
</sections>
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="ManualSelectAllDownloadableLinksDownloadableProductTest">
<annotations>
<features value="Catalog"/>
<stories value="Create Downloadable Product"/>
<title value="Manual select all downloadable links downloadable product test"/>
<description value="Manually selecting all downloadable links must change 'Select/Unselect all' button label to 'Unselect all', and 'Select all' otherwise"/>
<severity value="MAJOR"/>
<group value="Downloadable"/>
</annotations>
<before>
<!-- Create category -->
<createData entity="SimpleSubCategory" stepKey="createCategory"/>

<!-- Login as admin -->
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>

<!-- Create downloadable product -->
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="amOnProductGridPage"/>
<waitForPageLoad stepKey="waitForProductGridPageLoad"/>
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="createProduct">
<argument name="productType" value="downloadable"/>
</actionGroup>

<!-- Fill downloadable product values -->
<actionGroup ref="fillMainProductFormNoWeight" stepKey="fillDownloadableProductForm">
<argument name="product" value="DownloadableProduct"/>
</actionGroup>

<!-- Add downloadable product to category -->
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}"
parameterArray="[$$createCategory.name$$]" stepKey="fillCategory"/>

<!-- Fill downloadable link information before the creation link -->
<actionGroup ref="AdminAddDownloadableLinkInformationActionGroup" stepKey="addDownloadableLinkInformation"/>

<!-- Links can be purchased separately -->
<checkOption selector="{{AdminProductDownloadableSection.isLinksPurchasedSeparately}}"
stepKey="checkOptionPurchaseSeparately"/>

<!-- Add first downloadable link -->
<actionGroup ref="addDownloadableProductLinkWithMaxDownloads" stepKey="addFirstDownloadableProductLink">
<argument name="link" value="downloadableLinkWithMaxDownloads"/>
</actionGroup>

<!-- Add second downloadable link -->
<actionGroup ref="addDownloadableProductLink" stepKey="addSecondDownloadableProductLink">
<argument name="link" value="downloadableLink"/>
</actionGroup>

<!-- Save product -->
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
</before>
<after>
<!-- Delete category -->
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>

<!-- Delete created downloadable product -->
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct">
<argument name="product" value="DownloadableProduct"/>
</actionGroup>

<!-- Log out -->
<actionGroup ref="logout" stepKey="logout"/>
</after>

<!-- Step 1: Navigate to store front Product page as guest -->
<amOnPage url="/{{DownloadableProduct.sku}}.html"
stepKey="amOnStorefrontProductPage"/>

<!-- Step 2: Check first downloadable link checkbox -->
<click
selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLinkWithMaxDownloads.title)}}"
stepKey="selectFirstCheckbox"/>

<!-- Step 3: Check second downloadable link checkbox -->
<click
selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}"
stepKey="selectSecondCheckbox"/>

<!-- Step 4: Grab "Select/Unselect All" button label text -->
<grabTextFrom
selector="{{StorefrontDownloadableProductSection.downloadableLinkSelectAllLabel}}"
stepKey="grabUnselectAllButtonText"/>

<!-- Step 5: Assert that 'Select/Unselect all' button text is 'Unselect all' after manually checking all checkboxes -->
<assertEquals
message="Assert that 'Select/Unselect all' button text is 'Unselect all' after manually checking all checkboxes"
stepKey="assertButtonTextOne">
<expectedResult type="string">Unselect all</expectedResult>
<actualResult type="string">{$grabUnselectAllButtonText}</actualResult>
</assertEquals>

<!-- Step 6: Uncheck second downloadable link checkbox -->
<click
selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}"
stepKey="unselectSecondCheckbox"/>

<!-- Step 7: Grab "Select/Unselect All" button label text -->
<grabTextFrom
selector="{{StorefrontDownloadableProductSection.downloadableLinkSelectAllLabel}}"
stepKey="grabSelectAllButtonText"/>

<!-- Step 8: Assert that 'Select/Unselect all' button text is 'Select all' after manually unchecking one checkbox -->
<assertEquals
message="Assert that 'Select/Unselect all' button text is 'Select all' after manually unchecking one checkbox"
stepKey="assertButtonTextTwo">
<expectedResult type="string">Select all</expectedResult>
<actualResult type="string">{$grabSelectAllButtonText}</actualResult>
</assertEquals>

</test>
</tests>
Expand Up @@ -12,12 +12,17 @@ define([
], function ($) {
'use strict';

/**
* Downloadable widget
*/
$.widget('mage.downloadable', {
options: {
priceHolderSelector: '.price-box'
},

/** @inheritdoc */
/**
* @inheritdoc
*/
_create: function () {
var self = this;

Expand Down Expand Up @@ -65,6 +70,32 @@ define([
}
}
});

this.reloadAllCheckText();
},

/**
* Reload all-elements-checkbox's label
* @private
*/
reloadAllCheckText: function () {
var allChecked = true,
allElementsCheck = $(this.options.allElements),
allElementsLabel = $('label[for="' + allElementsCheck.attr('id') + '"] > span');

$(this.options.linkElement).each(function () {
if (!this.checked) {
allChecked = false;
}
});

if (allChecked) {
allElementsLabel.text(allElementsCheck.attr('data-checked'));
allElementsCheck.prop('checked', true);
} else {
allElementsLabel.text(allElementsCheck.attr('data-notchecked'));
allElementsCheck.prop('checked', false);
}
}
});

Expand Down