Skip to content

fixed validation for bundle checkbox options #27854

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

Merged
merged 21 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bdeb934
fixed validation for bundle checkbox options
ProkopovVitaliy Apr 14, 2020
e224442
fixed code style
ProkopovVitaliy Apr 20, 2020
6c7a5d4
added functional test for bundle product validation
ProkopovVitaliy Apr 28, 2020
8056d0e
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy Apr 28, 2020
999fb8f
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy Apr 29, 2020
bf1722a
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy May 1, 2020
628beb0
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy May 4, 2020
698ec67
Update app/code/Magento/Bundle/Test/Mftf/ActionGroup/AssertStorefront…
ProkopovVitaliy May 12, 2020
90ee413
Update app/code/Magento/Bundle/Test/Mftf/ActionGroup/AssertStorefront…
ProkopovVitaliy May 12, 2020
1046d8f
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy May 12, 2020
5a8eb63
fixed functional test for bundle product validation
ProkopovVitaliy May 14, 2020
f46bed1
replaced indexer to corresponding cron command
ProkopovVitaliy May 18, 2020
f048e3a
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy May 18, 2020
9a0e4df
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy May 19, 2020
6b9bf69
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy May 23, 2020
2fe9174
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy May 28, 2020
382cac4
fix line size issue
ProkopovVitaliy May 28, 2020
00f3514
Merge branch 'fix-27489' of github.com:ProkopovVitaliy/magento2 into …
ProkopovVitaliy May 28, 2020
497fce2
refactored template
ProkopovVitaliy May 29, 2020
9b11cbc
Merge branch '2.4-develop' into fix-27489
ProkopovVitaliy May 29, 2020
82dd19e
add TestCaseId to MFTF
engcom-Echo Jun 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontBundleValidationMessageActionGroup">
<annotations>
<description>Check error message in validation message box</description>
</annotations>
<arguments>
<argument name="message" type="string"/>
</arguments>

<waitForPageLoad stepKey="waitForPageLoad"/>
<see selector="{{StorefrontBundledSection.validationMessageBox}}" userInput="{{message}}" stepKey="seeErrorHoldMessage"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontBundleValidationMessagesCountActionGroup">
<annotations>
<description>Check if there's a validation message box on page and asserts the validation messages number</description>
</annotations>

<waitForPageLoad stepKey="waitForPageLoad"/>
<seeElement selector="{{StorefrontBundledSection.validationMessageBox}}" stepKey="seeErrorBox"/>
<seeNumberOfElements selector="{{StorefrontBundledSection.validationMessageBox}}" userInput="1" stepKey="seeOneErrorBox"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="StorefrontAddToTheCartButtonActionGroup">
<annotations>
<description>Clicks 'Add to Cart' on a Storefront Bundled Product page.</description>
</annotations>

<waitForPageLoad stepKey="waitForPageLoad"/>
<waitForElementVisible selector="{{StorefrontBundleProductActionSection.addToCartButton}}" stepKey="waitForAddToCartButton"/>
<click selector="{{StorefrontBundleProductActionSection.addToCartButton}}" stepKey="clickOnAddToCartButton"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
<element name="currencyTrigger" type="select" selector="#switcher-currency-trigger" timeout="30"/>
<element name="currency" type="select" selector="//a[text()='{{arg}}']" parameterized="true"/>
<element name="multiSelectOption" type="select" selector="//div[@class='field option required']//select"/>
<element name="validationMessageBox" type="block" selector="#validation-message-box"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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="StorefrontBundleCheckBoxOptionValidationTest">
<annotations>
<features value="Bundle"/>
<stories value="Bundle product validation before add to cart"/>
<title value="Customer should be able to see only one validation message for checkbox option group"/>
<description value="Customer should be able to see only one validation message for checkbox option group"/>
<testCaseId value="MC-35133"/>
<severity value="MINOR"/>
<group value="Bundle"/>
</annotations>
<before>
<createData entity="ApiProductWithDescription" stepKey="simpleProduct1" before="bundleProduct"/>
<createData entity="ApiProductWithDescription" stepKey="simpleProduct2" after="simpleProduct1"/>
<createData entity="ApiBundleProduct" stepKey="bundleProduct"/>
<createData entity="CheckboxOption" stepKey="checkboxBundleOption">
<requiredEntity createDataKey="bundleProduct"/>
</createData>
<createData entity="ApiBundleLink" stepKey="createBundleLink1">
<requiredEntity createDataKey="bundleProduct"/>
<requiredEntity createDataKey="checkboxBundleOption"/>
<requiredEntity createDataKey="simpleProduct1"/>
<field key="qty">2</field>
</createData>
<createData entity="ApiBundleLink" stepKey="createBundleLink2">
<requiredEntity createDataKey="bundleProduct"/>
<requiredEntity createDataKey="checkboxBundleOption"/>
<requiredEntity createDataKey="simpleProduct2"/>
<field key="qty">4</field>
</createData>
<magentoCron stepKey="runCronIndex" groups="index"/>
</before>
<after>
<deleteData createDataKey="bundleProduct" stepKey="deleteBundleProduct"/>
<deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/>
<deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/>
</after>
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductStorefront">
<argument name="productUrl" value="$$bundleProduct.custom_attributes[url_key]$$"/>
</actionGroup>
<actionGroup ref="StorefrontSelectCustomizeAndAddToTheCartButtonActionGroup" stepKey="customizeBundleProduct"/>
<actionGroup ref="StorefrontAddToTheCartButtonActionGroup" stepKey="addToCartBundleProduct"/>
<actionGroup ref="AssertStorefrontBundleValidationMessagesCountActionGroup" stepKey="assertBundleValidationCount"/>
<actionGroup ref="AssertStorefrontBundleValidationMessageActionGroup" stepKey="assertBundleValidationMessage">
<argument name="message" value="Please select one of the options."/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,55 @@
<?php /* @var $block \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Checkbox */ ?>
<?php $_option = $block->getOption() ?>
<?php $_selections = $_option->getSelections() ?>
<?php $inputClass = 'checkbox product bundle option bundle-option-' . $block->escapeHtmlAttr($_option->getId()) ?>
<?php $inputId = 'bundle-option-' . $block->escapeHtmlAttr($_option->getId()) ?>
<?php $inputName = 'bundle_option[' . $block->escapeHtmlAttr($_option->getId()) . ']' ?>
<?php $dataValidation = 'data-validate="{\'validate-one-required-by-name\':\'input[name^=&quot;bundle_option[' .
$block->escapeHtmlAttr($_option->getId()) . ']&quot;]:checked\'}"' ?>

<div class="field option <?= ($_option->getRequired()) ? ' required': '' ?>">
<label class="label">
<span><?= $block->escapeHtml($_option->getTitle()) ?></span>
</label>
<div class="control">
<div class="nested options-list">
<?php if ($block->showSingle()) : ?>
<?php if ($block->showSingle()): ?>
<?= /* @noEscape */ $block->getSelectionQtyTitlePrice($_selections[0]) ?>
<?= /* @noEscape */ $block->getTierPriceRenderer()->renderTierPrice($_selections[0]) ?>
<input type="hidden"
class="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?> product bundle option"
name="bundle_option[<?= $block->escapeHtml($_option->getId()) ?>]"
value="<?= $block->escapeHtmlAttr($_selections[0]->getSelectionId()) ?>"/>
<?php else :?>
<?php foreach ($_selections as $_selection) : ?>
<?php else: ?>
<?php foreach ($_selections as $selection): ?>
<?php $sectionId = $selection->getSelectionId() ?>
<div class="field choice">
<input class="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?> checkbox product bundle option change-container-classname"
id="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>-<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>"
<input class="<?=/* @noEscape */ $inputClass ?> change-container-classname"
id="<?=/* @noEscape */ $inputId . '-' . $block->escapeHtmlAttr($sectionId)?>"
type="checkbox"
<?php if ($_option->getRequired()) { echo 'data-validate="{\'validate-one-required-by-name\':\'input[name^=&quot;bundle_option[' . $block->escapeHtmlAttr($_option->getId()) . ']&quot;]:checked\'}"'; } ?>
name="bundle_option[<?= $block->escapeHtmlAttr($_option->getId()) ?>][<?= $block->escapeHtmlAttr($_selection->getId()) ?>]"
data-selector="bundle_option[<?= $block->escapeHtmlAttr($_option->getId()) ?>][<?= $block->escapeHtmlAttr($_selection->getId()) ?>]"
<?php if ($block->isSelected($_selection)) { echo ' checked="checked"'; } ?>
<?php if (!$_selection->isSaleable()) { echo ' disabled="disabled"'; } ?>
value="<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>"/>
<?php if ($_option->getRequired()): ?>
<?= /* @noEscape */ $dataValidation ?>
<?php endif;?>
name="<?=/* @noEscape */ $inputName .'['. $block->escapeHtmlAttr($sectionId)?>]"
data-selector="<?= /* @noEscape */ $inputName.'['.$block->escapeHtmlAttr($sectionId)?>]"
<?php if ($block->isSelected($selection)): ?>
<?= ' checked="checked"' ?>
<?php endif; ?>
<?php if (!$selection->isSaleable()): ?>
<?= ' disabled="disabled"' ?>
<?php endif; ?>
value="<?= $block->escapeHtmlAttr($sectionId) ?>"
data-errors-message-box="#validation-message-box"/>
<label class="label"
for="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>-<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>">
<span><?= /* @noEscape */ $block->getSelectionQtyTitlePrice($_selection) ?></span>
for="<?= /* @noEscape */ $inputId . '-' . $block->escapeHtmlAttr($sectionId) ?>">
<span><?= /* @noEscape */ $block->getSelectionQtyTitlePrice($selection) ?></span>
<br/>
<?= /* @noEscape */ $block->getTierPriceRenderer()->renderTierPrice($_selection) ?>
<?= /* @noEscape */ $block->getTierPriceRenderer()->renderTierPrice($selection) ?>
</label>
</div>
<?php endforeach; ?>
<div id="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>-container"></div>
<div id="validation-message-box"></div>
<?php endif; ?>
</div>
</div>
Expand Down