Skip to content

Commit

Permalink
Merge branch '2.4-develop' into Refactoring-AdminCreateSimpleProductZ…
Browse files Browse the repository at this point in the history
…eroPriceTest
  • Loading branch information
Gabriel da Gama authored Apr 12, 2021
2 parents 99cc467 + c46d9bf commit f6c11b3
Show file tree
Hide file tree
Showing 217 changed files with 6,668 additions and 46,254 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@
- [ ] Pull request has a meaningful description of its purpose
- [ ] All commits are accompanied by meaningful commit messages
- [ ] All new or changed code is covered with unit/integration tests (if applicable)
- [ ] README.md files for modified modules are updated and included in the pull request if any [README.md predefined sections](https://github.com/magento/devdocs/wiki/Magento-module-README.md) require an update
- [ ] All automated tests passed successfully (all builds are green)
4 changes: 3 additions & 1 deletion app/code/Magento/Backend/Block/Store/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backend\Block\Store;

Expand Down Expand Up @@ -114,7 +115,8 @@ protected function _construct()
{
parent::_construct();

$this->setUseConfirm(true);
$this->setUseConfirm($this->hasData('use_confirm') ? (bool)$this->getData('use_confirm') : true);

$this->setUseAjax(true);

$this->setShowManageStoresLink(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* See COPYING.txt for license details.
*/

// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound
/** @var $block \Magento\Backend\Block\Media\Uploader */
?>

Expand Down
324 changes: 117 additions & 207 deletions app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
* See COPYING.txt for license details.
*/

/** @var $block \Magento\Backend\Block\GlobalSearch */
// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound

use Magento\Backend\Block\GlobalSearch;
use Magento\Framework\Json\Helper\Data;

/** @var $block GlobalSearch */
/** @var Data $helper */
$helper = $this->helper(Data::class);

?>
<div class="search-global" data-mage-init='{"globalSearch": {}}'>
<form action="#" id="form-search">
Expand All @@ -15,9 +23,7 @@
class="search-global-input"
id="search-global"
name="query"
<?php //phpcs:disable ?>
data-mage-init='<?= /* @noEscape */ $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($block->getWidgetInitOptions()) ?>'>
<?php //phpcs:enable ?>
data-mage-init='<?= /* @noEscape */ $helper->jsonEncode($block->getWidgetInitOptions()) ?>'>
<button
type="submit"
class="search-global-action"
Expand Down
127 changes: 127 additions & 0 deletions app/code/Magento/Backend/view/adminhtml/web/js/store-switcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'jquery'
], function ($) {
'use strict';

/**
* @param {Object} storeSwitchConfig
*/
return function (storeSwitchConfig) {
var scopeSwitcherHandler;

(function () {
var storesList = $('[data-role=stores-list]');

storesList.on('click', '[data-value]', function (event) {
var val = $(event.target).data('value'),
role = $(event.target).data('role'),
switcher = $('[data-role=' + role + ']');

event.preventDefault();

if (!switcher.val() || val !== switcher.val()) {

/* Set the value & trigger event */
switcher.val(val).trigger('change');
}
});
})($);

/**
* Switch store scope
*
* @param {Object} obj
* @return void
*/
function switchScope(obj) {
var switcher = $(obj),
scopeId = switcher.val(),
scopeParams = '',
switcherParams = {};

if (scopeId) {
scopeParams = switcher.data('param') + '/' + scopeId + '/';
}

if (obj.switchParams) {
scopeParams += obj.switchParams;
}

/**
* Reload function for switcher
*/
function reload() {
var url;

if (!storeSwitchConfig.isUsingIframe) {

if (storeSwitchConfig.switchUrl && storeSwitchConfig.switchUrl.length > 0) {
url = storeSwitchConfig.switchUrl + scopeParams;

/* eslint-disable no-undef */
setLocation(url);
}

} else {
$('#preview_selected_store').val(scopeId);
$('#preview_form').submit();

$('.store-switcher .dropdown-menu li a').each(function () {
var $this = $(this);

if ($this.data('role') === 'store-view-id' && $this.data('value') === scopeId) {
$('#store-change-button').html($this.text());
}
});

$('#store-change-button').click();
}
}

if (typeof scopeSwitcherHandler !== 'undefined') {
switcherParams = {
scopeId: scopeId,
scopeParams: scopeParams,
useConfirm: storeSwitchConfig.useConfirm
};

scopeSwitcherHandler(switcherParams);
} else if (storeSwitchConfig.useConfirm) {
require([
'Magento_Ui/js/modal/confirm',
'mage/translate'
], function (confirm, $t) {
confirm({
content: $t('Please confirm scope switching. All data that hasn\'t been saved will be lost.'),
actions: {

/**
* Confirm action
*/
confirm: function () {
reload();
},

/**
* Cancel action
*/
cancel: function () {
obj.value = storeSwitchConfig.storeId ? storeSwitchConfig.storeId : '';
}
}
});
});
} else {
reload();
}
}

window.scopeSwitcherHandler = scopeSwitcherHandler;
window.switchScope = switchScope;
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound
/** @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle\Option */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* See COPYING.txt for license details.
*/

// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound
/** @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle\Option\Selection */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>

<?php
$_product = $block->getProduct();
// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound
$_product = $block->getProduct();
?>
<?php if ($_product->isSaleable() && $block->hasOptions()) : ?>
<div id="bundleSummary"
Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Captcha/Test/Mftf/Data/CaptchaConfigData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
<data key="label">Change password</data>
<data key="value">user_edit</data>
</entity>
<entity name="StorefrontCaptchaOnOnepageCheckoutConfigData">
<data key="path">customer/captcha/forms</data>
<data key="scope_id">0</data>
<data key="label">Checkout/Placing Order</data>
<data key="value">payment_processing_request</data>
</entity>
<entity name="StorefrontCaptchaOnCustomerForgotPasswordConfigData">
<!-- Magento default value -->
<data key="path">customer/captcha/forms</data>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="StorefrontCaptchaOnOnepageCheckoutPyamentSection">
<element name="captchaField" type="input" selector="#captcha_payment_processing_request"/>
<element name="captchaImg" type="block" selector=".captcha-img"/>
<element name="captchaReload" type="block" selector=".captcha-reload"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="StorefrontCheckoutPaymentMethodsSection">
<element name="purchaseOrder" type="radio" selector="#purchaseorder" timeout="30"/>
<element name="purchaseOrderNumber" type="input" selector="#po_number" timeout="30"/>
<element name="bankTransfer" type="radio" selector="#banktransfer" timeout="30"/>
<element name="cashOnDelivery" type="radio" selector="#cashondelivery" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?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="StorefrontCaptchaOnOnepageCheckoutPyamentTest">
<annotations>
<features value="Captcha"/>
<stories value="Place order on checkout page + Captcha"/>
<title value="Captcha on checkout page test"/>
<description value="Test creation of order on storefront checkout page with captcha."/>
<severity value="AVERAGE"/>
<testCaseId value="MC-41461"/>
<useCaseId value="MC-41281"/>
<group value="captcha"/>
</annotations>
<before>
<!-- Create Simple Product -->
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
<field key="price">20</field>
</createData>

<!-- Create customer -->
<createData entity="Simple_Customer_Without_Address" stepKey="createCustomer"/>

<!-- Enable payment method -->
<magentoCLI command="config:set {{BankTransferEnableConfigData.path}} {{BankTransferEnableConfigData.value}}" stepKey="enableBankTransfer"/>

<!-- Enable captcha for Checkout/Placing Order -->
<magentoCLI command="config:set {{StorefrontCaptchaOnOnepageCheckoutConfigData.path}} {{StorefrontCaptchaOnOnepageCheckoutConfigData.value}}" stepKey="enableOnOpageCheckoutCaptcha" />
<magentoCLI command="config:set {{StorefrontCustomerCaptchaModeAlwaysConfigData.path}} {{StorefrontCustomerCaptchaModeAlwaysConfigData.value}}" stepKey="alwaysEnableCaptcha" />
<magentoCLI command="config:set {{StorefrontCustomerCaptchaLength3ConfigData.path}} {{StorefrontCustomerCaptchaLength3ConfigData.value}}" stepKey="setCaptchaLength" />
<magentoCLI command="config:set {{StorefrontCustomerCaptchaSymbols1ConfigData.path}} {{StorefrontCustomerCaptchaSymbols1ConfigData.value}}" stepKey="setCaptchaSymbols" />
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
<argument name="tags" value="config full_page"/>
</actionGroup>
</before>
<after>
<!-- Disabled payment method -->
<magentoCLI command="config:set {{BankTransferDisabledConfigData.path}} {{BankTransferDisabledConfigData.value}}" stepKey="disabledBankTransfer"/>

<!-- Set default configuration for captcha -->
<magentoCLI command="config:set {{StorefrontCaptchaOnOnepageCheckoutConfigData.path}} {{StorefrontCaptchaOnOnepageCheckoutConfigData.value}},{{StorefrontCaptchaOnCustomerForgotPasswordConfigData.value}}" stepKey="enableCaptchaOnDefaultForms" />
<magentoCLI command="config:set {{StorefrontCustomerCaptchaModeAfterFailConfigData.path}} {{StorefrontCustomerCaptchaModeAfterFailConfigData.value}}" stepKey="defaultCaptchaMode" />
<magentoCLI command="config:set {{StorefrontCustomerCaptchaDefaultLengthConfigData.path}} {{StorefrontCustomerCaptchaDefaultLengthConfigData.value}}" stepKey="setDefaultCaptchaLength" />
<magentoCLI command="config:set {{StorefrontCustomerCaptchaDefaultSymbolsConfigData.path}} {{StorefrontCustomerCaptchaDefaultSymbolsConfigData.value}}" stepKey="setDefaultCaptchaSymbols" />
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
<argument name="tags" value="config full_page"/>
</actionGroup>

<!-- Customer logout -->
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/>

<!-- Delete created products -->
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>

<!-- Delete customer -->
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
</after>

<!-- Reindex and flush cache -->
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
<argument name="indices" value=""/>
</actionGroup>
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache">
<argument name="tags" value=""/>
</actionGroup>

<!-- Add Simple Product to cart -->
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.custom_attributes[url_key]$$)}}" stepKey="navigateToSimpleProductPage"/>
<waitForPageLoad stepKey="waitForSimpleProductPageLoad"/>
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addToCartSimpleProductFromStorefrontProductPage">
<argument name="productName" value="$$createSimpleProduct.name$$"/>
</actionGroup>

<!-- Go to shopping cart -->
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="goToShoppingCartFromMinicart"/>
<actionGroup ref="FillShippingZipForm" stepKey="fillShippingZipForm">
<argument name="address" value="US_Address_CA"/>
</actionGroup>
<actionGroup ref="StorefrontClickProceedToCheckoutActionGroup" stepKey="goToCheckout"/>

<!-- Login as customer on checkout page -->
<actionGroup ref="LoginAsCustomerOnCheckoutPageActionGroup" stepKey="customerLogin">
<argument name="customer" value="$$createCustomer$$"/>
</actionGroup>

<!-- Fill customer new shipping address -->
<actionGroup ref="CustomerCheckoutFillNewShippingAddressActionGroup" stepKey="fillShippingAddress">
<argument name="address" value="US_Address_TX"/>
</actionGroup>

<!-- Click next button to open payment section -->
<actionGroup ref="StorefrontGuestCheckoutProceedToPaymentStepActionGroup" stepKey="clickNext"/>

<!-- Select payment method -->
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" stepKey="waitForPaymentSectionLoaded"/>
<click selector="{{StorefrontCheckoutPaymentMethodsSection.bankTransfer}}" stepKey="selectBankTransferMethod"/>

<!-- Enter captcha value -->
<fillField userInput="{{PreconfiguredCaptcha.value}}" selector="{{StorefrontCaptchaOnOnepageCheckoutPyamentSection.captchaField}}" stepKey="fillCaptchaField" />

<!-- Place Order -->
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="customerPlaceOrder">
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/>
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage"/>
</actionGroup>

<!-- Assert order grand total -->
<amOnPage url="{{StorefrontCustomerDashboardPage.url}}" stepKey="navigateToCustomerDashboardPage"/>
<waitForPageLoad stepKey="waitForCustomerDashboardPageLoad"/>
<see selector="{{StorefrontCustomerRecentOrdersSection.orderTotal}}" userInput="$25.00" stepKey="checkOrderTotalInStorefront"/>
</test>
</tests>
4 changes: 2 additions & 2 deletions app/code/Magento/Captcha/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"magento/module-customer": "*",
"magento/module-store": "*",
"magento/module-authorization": "*",
"laminas/laminas-captcha": "^2.7.1",
"laminas/laminas-captcha": "^2.10",
"laminas/laminas-db": "^2.8.2",
"laminas/laminas-session": "^2.7.3"
"laminas/laminas-session": "^2.10"
},
"type": "magento2-module",
"license": [
Expand Down
Loading

0 comments on commit f6c11b3

Please sign in to comment.