Skip to content

Commit

Permalink
Merge branch '2.4-develop' of https://github.com/mage-os/mirror-magento2
Browse files Browse the repository at this point in the history
 into 2.4-develop
  • Loading branch information
mage-os-ci committed Sep 6, 2024
2 parents b2c69d9 + a321acd commit 535167b
Show file tree
Hide file tree
Showing 44 changed files with 540 additions and 336 deletions.
2 changes: 0 additions & 2 deletions app/code/Magento/Backend/view/adminhtml/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<meta name="viewport" content="width=1024"/>
<meta name="format-detection" content="telephone=no"/>
<link src="requirejs/require.js"/>
<css src="extjs/resources/css/ext-all.css"/>
<css src="extjs/resources/css/ytheme-magento.css"/>
</head>
<body>
<attribute name="id" value="html-body"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ public function getCalendarDateHtml()
$yearStart = $this->_catalogProductOptionTypeDate->getYearStart();
$yearEnd = $this->_catalogProductOptionTypeDate->getYearEnd();

$dateFormat = $this->_localeDate->getDateFormatWithLongYear();
$fieldsSeparator = '/';
$fieldsOrder = $this->_catalogProductOptionTypeDate->getConfigData('date_fields_order') ?? '';
$fieldsOrder = str_replace(",", $fieldsSeparator, $fieldsOrder);
$dateFormat = $fieldsOrder !== "m/d/y" ? $fieldsOrder : $this->_localeDate->getDateFormatWithLongYear();
/** Escape RTL characters which are present in some locales and corrupt formatting */
$escapedDateFormat = preg_replace('/[^MmDdYy\/\.\-]/', '', $dateFormat);
$value = null;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ private function getCollectionProcessor()
{
if (!$this->collectionProcessor) {
$this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get(
// phpstan:ignore "Class Magento\Catalog\Model\Api\SearchCriteria\ProductCollectionProcessor not found."
// @phpstan-ignore-next-line - this is a virtual type defined in di.xml
\Magento\Catalog\Model\Api\SearchCriteria\ProductCollectionProcessor::class
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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="AdminAddCustomizableOptionToSimpleProductActionGroup">
<annotations>
<description value="Add a custom option of type date to simple product." />
</annotations>

<click selector="{{AdminProductCustomizableOptionSection.customizableOptionsToggle}}" stepKey="expandCustomOptions"/>
<scrollTo selector="{{AdminProductCustomizableOptionSection.customizableOptionsToggle}}" stepKey="scrollToCustomizableOptions"/>

<click selector="{{AdminProductCustomizableOptionSection.addButtonOption}}" stepKey="clickAddButtonOption"/>
<waitForElementVisible selector="{{AdminProductCustomizableOptionSection.customOptionXTitle}}" stepKey="waitForOptions"/>
<fillField selector="{{AdminProductCustomizableOptionSection.customOptionXTitle}}" userInput="custom option 1" stepKey="fillOptionTitle"/>

<click selector="{{AdminProductCustomizableOptionSection.customOptionSelectType}}" stepKey="selectType"/>
<click selector="{{AdminProductCustomizableOptionSection.customOptionSelectField}}" stepKey="selectField"/>
<click selector="{{AdminProductCustomizableOptionSection.uncheckRequired}}" stepKey="uncheckRequired"/>
<fillField selector="{{AdminProductCustomizableOptionSection.customizableOptionPrice}}" userInput="0" stepKey="fillPrice"/>

<waitForElementVisible selector="{{AdminProductCustomizableOptionSection.save}}" stepKey="waitForSaveButton"/>
<click selector="{{AdminProductCustomizableOptionSection.save}}" stepKey="clickSaveButton"/>
<waitForPageLoad stepKey="waitForAttributeToSave"/>
<seeElement selector="{{AdminProductCustomizableOptionSection.successMessage}}" stepKey="seeSuccessMessage"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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="AdminConfigExpandDateAndTimeTabActionGroup">
<annotations>
<description>Expand date and time options tab.</description>
</annotations>

<scrollTo selector="{{CatalogSection.dateAndTimeCustomOptions}}" stepKey="scrollDownToDateAndTime"/>
<conditionalClick selector="{{CatalogSection.dateAndTimeCustomOptions}}" dependentSelector="{{CatalogSection.CheckIfTabExpandForDateAndTimeCustomOptions}}" visible="true" stepKey="expandDateAndTimeCustomOptionsTab"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?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="AssertProductDateFormatInStorefrontActionGroup">
<annotations>
<description value="Go to product page on the storefront and assert sku and custom option date format"/>
</annotations>

<arguments>
<argument name="product"/>
</arguments>

<!-- Go to storefront product page, assert product sku and date custom option -->
<amOnPage url="{{product.urlKey}}.html" stepKey="navigateToProductPage"/>
<waitForPageLoad stepKey="waitForPageLoad"/>

<see userInput="{{product.sku}}" selector="{{StorefrontProductInfoMainSection.productSku}}" stepKey="assertProductSku"/>

<click selector="{{StorefrontProductInfoMainSection.productCalenderButton}}" stepKey="clickCalenderButton"/>
<click selector="{{StorefrontProductInfoMainSection.productCalenderGoToday}}" stepKey="clickCalenderGoTodayButton"/>

<generateDate date="Now" format="j/n/Y" stepKey="currentDate"/>

<executeJS function="
var xpath = '{{StorefrontProductInfoMainSection.customDateField}}';
var result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
var element = result.singleNodeValue;
return element.value;
" stepKey="dateValue"/>

<assertEquals stepKey="assertDateFormat">
<actualResult type="variable">dateValue</actualResult>
<expectedResult type="variable">currentDate</expectedResult>
</assertEquals>

</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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="SelectDropdownDateAndTimeActionGroup">
<annotations>
<description>Select options for Use JavaScript Calendar and Date Fields Order dropdown</description>
</annotations>

<arguments>
<argument name="useJsCalender" type="string"/>
<argument name="firstFieldOfDateOrder" type="string"/>
<argument name="secondFieldOfDateOrder" type="string"/>
<argument name="thirdFieldOfDateOrder" type="string" defaultValue="Year"/>
</arguments>

<selectOption selector="{{AdminCustomizeDateAndTimeSection.dateAndTimeJsCalenderStatus}}"
userInput="{{useJsCalender}}" stepKey="selectJsCalender" />
<selectOption selector="{{AdminCustomizeDateAndTimeSection.dateAndTimeFirstFieldOrder}}"
userInput="{{firstFieldOfDateOrder}}" stepKey="selectFirstFieldOrder" />
<selectOption selector="{{AdminCustomizeDateAndTimeSection.dateAndTimeSecondFieldOrder}}"
userInput="{{secondFieldOfDateOrder}}" stepKey="selectSecondFieldOrder" />
<selectOption selector="{{AdminCustomizeDateAndTimeSection.dateAndTimeThirdFieldOrder}}"
userInput="{{thirdFieldOfDateOrder}}" stepKey="selectThirdFieldOrder" />
</actionGroup>
</actionGroups>
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="AdminCustomizeDateAndTimeSection">
<element name="dateAndTimeJsCalenderStatus" type="select" selector="//*[@id='catalog_custom_options_use_calendar']"/>
<element name="dateAndTimeFirstFieldOrder" type="select" selector="//*[@id='catalog_custom_options_date_fields_order'][1]"/>
<element name="dateAndTimeSecondFieldOrder" type="select" selector="//*[@id='catalog_custom_options_date_fields_order'][2]"/>
<element name="dateAndTimeThirdFieldOrder" type="select" selector="//*[@id='catalog_custom_options_date_fields_order'][3]"/>
</section>
</sections>
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.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminProductCustomizableOptionSection">
<element name="customizableOptionsToggle" type="button" selector="//span[text()='Customizable Options']"/>
<element name="addButtonOption" type="button" selector="button[data-index='button_add']"/>
<element name="customOptionXTitle" type="input" selector="[name='product[options][0][title]']"/>
<element name="customOptionSelectType" type="select" selector="[data-index='container_common'] .admin__action-multiselect-text"/>
<element name="customOptionSelectField" type="select" selector="//label[contains(text(),'Date')]" />
<element name="uncheckRequired" type="checkbox" selector="//span[contains(text(),'Required')]"/>
<element name="customizableOptionPrice" type="input" selector=".//*[@name='product[options][0][price]']" />
<element name="save" type="button" selector="//*[@id='save-button']" timeout="30"/>
<element name="successMessage" type="text" selector=".message.message-success.success"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@
<element name="swatchOptionDisabled" type="text" selector=".//*[@class='swatch-option color disabled']"/>
<element name="addToCartEnabled" type="button" selector="#product-addtocart-button:not([disabled])"/>
<element name="selectCustomOptionDropDown" type="select" selector="//select[contains(@class,' required product-custom-option admin__control-select')]"/>
<element name="productCalenderButton" type="button" selector="//*[@id='product-options-wrapper']/div/div/fieldset/div/button" />
<element name="productCalenderGoToday" type="button" selector="//*[@id='ui-datepicker-div']/div[2]/button[1]" />
<element name="customDateField" type="text" selector='//*[@class="product-custom-option datetime-picker input-text _has-datepicker"]' />
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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="AdminJsCalenderDateFormatTest">
<annotations>
<features value="Catalog"/>
<stories value="Storefront should reflect the js calender format configured in the backend" />
<title value="Check if js calender format configured in backend is reflected on storefront" />
<description value="Check if js calender format configured in backend is reflected on storefront" />
<severity value="AVERAGE"/>
<testCaseId value="AC-12164"/>
<group value="Catalog"/>
</annotations>

<before>
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
</before>

<after>
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
<actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteProduct">
<argument name="sku" value="{{_defaultProduct.sku}}"/>
</actionGroup>
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="clearFilter"/>

<actionGroup ref="AdminOpenStoreConfigCatalogPageActionGroup" stepKey="navigateToConfigurationPage2"/>
<actionGroup ref="AdminConfigExpandDateAndTimeTabActionGroup" stepKey="expandDateAndTimeCustomOptionsTab2"/>
<actionGroup ref="SelectDropdownDateAndTimeActionGroup" stepKey="RevertDateAndTimeFieldOrder">
<argument name="useJsCalender" value="No"/>
<argument name="firstFieldOfDateOrder" value="Month"/>
<argument name="secondFieldOfDateOrder" value="Day"/>
</actionGroup>
<actionGroup ref="AdminCheckUseSystemValueActionGroup" stepKey="checkUseSystemValueForDateFieldsOrder">
<argument name="rowId" value="row_catalog_custom_options_date_fields_order"/>
</actionGroup>
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveDateAndTimeConfig2"/>

<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
</after>

<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>

<!-- Open admin configuration, got to catalog, expand date and time tab -->
<actionGroup ref="AdminOpenStoreConfigCatalogPageActionGroup" stepKey="navigateToConfigurationPage"/>
<actionGroup ref="AdminConfigExpandDateAndTimeTabActionGroup" stepKey="expandDateAndTimeCustomOptionsTab"/>

<!-- Customize date and time configuration to D/M/Y -->
<actionGroup ref="AdminUncheckUseSystemValueActionGroup" stepKey="uncheckUseSystemValueForDateFieldsOrder">
<argument name="rowId" value="row_catalog_custom_options_date_fields_order"/>
</actionGroup>
<actionGroup ref="SelectDropdownDateAndTimeActionGroup" stepKey="CustomizeDateAndTimeFieldOrder">
<argument name="useJsCalender" value="Yes"/>
<argument name="firstFieldOfDateOrder" value="Day"/>
<argument name="secondFieldOfDateOrder" value="Month"/>
</actionGroup>
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveDateAndTimeConfig"/>

<!-- Create simple product on storefront -->
<actionGroup ref="FillAdminSimpleProductFormActionGroup" stepKey="fillProductFieldsInAdmin">
<argument name="category" value="$$createPreReqCategory$$"/>
<argument name="simpleProduct" value="_defaultProduct"/>
</actionGroup>

<!-- Add customizable date option -->
<actionGroup ref="AdminAddCustomizableOptionToSimpleProductActionGroup" stepKey="AddCustomizableDateOption"/>

<actionGroup ref="CliIndexerReindexActionGroup" stepKey="runCronIndex">
<argument name="indices" value=""/>
</actionGroup>

<!-- Assert date on storefront -->
<actionGroup ref="AssertProductDateFormatInStorefrontActionGroup" stepKey="assertDateFormat">
<argument name="product" value="_defaultProduct"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;

use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Magento\Authorization\Model\Role;
use Magento\Backend\Model\Auth\Session;
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\DB\Helper as DbHelper;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\Store;
use Magento\Backend\Model\Auth\Session;
use Magento\Authorization\Model\Role;
use Magento\User\Model\User;
use PHPUnit\Framework\MockObject\MockObject;

Expand Down Expand Up @@ -91,6 +91,9 @@ protected function setUp(): void
$this->categoryCollectionMock->expects($this->any())
->method('addAttributeToSelect')
->willReturnSelf();
$this->categoryCollectionMock->expects($this->any())
->method('addAttributeToSort')
->willReturnSelf();
$this->categoryCollectionMock->expects($this->any())
->method('addAttributeToFilter')
->willReturnSelf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@

namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier;

use Magento\Backend\Model\Auth\Session;
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Model\Category as CategoryModel;
use Magento\Catalog\Model\Locator\LocatorInterface;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Data\Collection;
use Magento\Framework\DB\Helper as DbHelper;
use Magento\Catalog\Model\Category as CategoryModel;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\UrlInterface;
use Magento\Framework\Stdlib\ArrayManager;
use Magento\Framework\AuthorizationInterface;
use Magento\Backend\Model\Auth\Session;
use Magento\Framework\UrlInterface;

/**
* Data provider for categories field of product page
Expand Down Expand Up @@ -51,6 +53,7 @@ class Categories extends AbstractModifier
/**
* @var array
* @deprecated 101.0.0
* @see Nothing
* @since 101.0.0
*/
protected $categoriesTrees = [];
Expand Down Expand Up @@ -128,6 +131,7 @@ public function __construct(
*
* @return CacheInterface
* @deprecated 101.0.3
* @see getCategoriesTree
*/
private function getCacheManager(): CacheInterface
{
Expand Down Expand Up @@ -442,6 +446,8 @@ private function retrieveCategoriesTree(int $storeId, array $shownCategoriesIds)

$collection->addAttributeToFilter('entity_id', ['in' => array_keys($shownCategoriesIds)])
->addAttributeToSelect(['name', 'is_active', 'parent_id'])
->addAttributeToSort(CategoryInterface::KEY_LEVEL, Collection::SORT_ORDER_ASC)
->addAttributeToSort(CategoryInterface::KEY_POSITION, Collection::SORT_ORDER_ASC)
->setStoreId($storeId);

$categoryById = [
Expand Down
Loading

0 comments on commit 535167b

Please sign in to comment.