Skip to content

Commit e1db3f8

Browse files
committed
Merge branch 'MC-39626' into 2.4-develop-sidecar-pr14
2 parents 4fe2d06 + 8f0908d commit e1db3f8

File tree

17 files changed

+488
-156
lines changed

17 files changed

+488
-156
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="FilterProductGridByCustomDateRangeActionGroup">
12+
<annotations>
13+
<description>Filters the Admin Products grid by the provided Date Filter.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="code" type="string"/>
17+
<argument name="date" type="string"/>
18+
</arguments>
19+
20+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/>
21+
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
22+
<fillField selector="{{AdminProductGridFilterSection.inputByCodeRangeFrom(code)}}" userInput="{{date}}" stepKey="fillProductDatetimeFromFilter"/>
23+
<fillField selector="{{AdminProductGridFilterSection.inputByCodeRangeTo(code)}}" userInput="{{date}}" stepKey="fillProductDatetimeToFilter"/>
24+
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/>
25+
<waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad" time="30"/>
26+
</actionGroup>
27+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
<element name="selectMultipleCategories" type="input" selector="//*[@data-index='container_category_ids']//*[contains(@class, '_selected')]"/>
7676
<element name="countryOfManufacture" type="select" selector="select[name='product[country_of_manufacture]']"/>
7777
<element name="newAddedAttribute" type="text" selector="//fieldset[@class='admin__fieldset']//div[contains(@data-index,'{{attributeCode}}')]" parameterized="true"/>
78+
<element name="newAddedAttributeInput" type="text" selector="//fieldset[@class='admin__fieldset']//div[contains(@data-index,'{{attributeCode}}')]//input" parameterized="true"/>
7879
<element name="newCategoryButton" type="button" selector="button[data-index='create_category_button']" timeout="30"/>
7980
<element name="footerBlock" type="block" selector="//footer"/>
8081
<element name="categories" type="text" selector="//*[@class='admin__action-multiselect-crumb']/span[contains(text(), '{{categoryName}}')]" parameterized="true"/>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminProductGridFilteringByDateWithCustomLocaleTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Filter products"/>
14+
<title value="Product grid date filters does not work for en_GB locale"/>
15+
<description value="Product grid date filters does not work for en_GB locale"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-40644"/>
18+
<useCaseId value="MC-40240"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
22+
<before>
23+
<!-- Deploy static content with United Kingdom locale-->
24+
<magentoCLI command="setup:static-content:deploy en_GB" stepKey="deployStaticContentWithUnitedKingdomLocale"/>
25+
<createData entity="_defaultCategory" stepKey="createCategory"/>
26+
<createData entity="SimpleProduct" stepKey="createProduct">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
30+
<!-- Create new User -->
31+
<actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/>
32+
<actionGroup ref="AdminCreateUserWithRoleAndLocaleActionGroup" stepKey="createAdminUser">
33+
<argument name="user" value="activeAdmin"/>
34+
<argument name="role" value="roleDefaultAdministrator"/>
35+
<argument name="interfaceLocale" value="en_GB"/>
36+
</actionGroup>
37+
</before>
38+
<after>
39+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
40+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
41+
<actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteAttribute">
42+
<argument name="ProductAttribute" value="dateProductAttribute"/>
43+
</actionGroup>
44+
<actionGroup ref="AdminGridFilterResetActionGroup" stepKey="resetGridFilter"/>
45+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
46+
</after>
47+
48+
<!-- Generate date for use as default value, needs to be MM/d/YYYY and mm/d/yy -->
49+
<generateDate date="now" format="m/j/Y" stepKey="generateDefaultDate"/>
50+
<generateDate date="now" format="j/m/Y" stepKey="generateDefaultDateGB"/>
51+
52+
<!-- Navigate to Stores > Attributes > Product. -->
53+
<actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="goToProductAttributes"/>
54+
55+
<!-- Create new Product Attribute as TextField, with code and default value. -->
56+
<actionGroup ref="CreateProductAttributeWithDateFieldActionGroup" stepKey="createAttribute">
57+
<argument name="attribute" value="dateProductAttribute"/>
58+
<argument name="date" value="{$generateDefaultDate}"/>
59+
</actionGroup>
60+
61+
<!-- Go to default attribute set edit page -->
62+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/>
63+
<!-- Assert created attribute in unassigned section -->
64+
<see userInput="{{dateProductAttribute.attribute_code}}" selector="{{AdminProductAttributeSetEditSection.unassignedAttributesTree}}" stepKey="seeAttributeInUnassigned"/>
65+
<!-- Assign attribute to a group -->
66+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
67+
<argument name="group" value="Product Details"/>
68+
<argument name="attribute" value="{{dateProductAttribute.attribute_code}}"/>
69+
</actionGroup>
70+
<!-- Assert attribute in a group -->
71+
<see userInput="{{dateProductAttribute.attribute_code}}" selector="{{AdminProductAttributeSetEditSection.groupTree}}" stepKey="seeAttributeInGroup"/>
72+
<!-- Save attribute set -->
73+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="SaveAttributeSet"/>
74+
75+
<!-- Open Product Edit Page and set custom attribute value -->
76+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForProduct">
77+
<argument name="product" value="$createProduct$"/>
78+
</actionGroup>
79+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct">
80+
<argument name="product" value="$createProduct$"/>
81+
</actionGroup>
82+
<fillField selector="{{AdminProductFormSection.newAddedAttributeInput(dateProductAttribute.attribute_code)}}" userInput="{$generateDefaultDate}" stepKey="fillCustomDateValue"/>
83+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
84+
85+
<!-- Logout master admin and Login as new User -->
86+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutMasterAdmin"/>
87+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToNewAdmin">
88+
<argument name="username" value="{{activeAdmin.username}}"/>
89+
<argument name="password" value="{{activeAdmin.password}}"/>
90+
</actionGroup>
91+
92+
<!-- Open Product Index Page and filter the product -->
93+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex2"/>
94+
<actionGroup ref="FilterProductGridByCustomDateRangeActionGroup" stepKey="filterProductGridByCustomDateRange">
95+
<argument name="code" value="{{dateProductAttribute.attribute_code}}"/>
96+
<argument name="date" value="{$generateDefaultDateGB}"/>
97+
</actionGroup>
98+
<!-- Check products filtering -->
99+
<see selector="{{AdminProductGridSection.productGridNameProduct($createProduct.name$)}}" userInput="$createProduct.name$" stepKey="seeProductName"/>
100+
</test>
101+
</tests>

app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,30 +86,6 @@ public function beforeSavePaymentInformationAndPlaceOrder(
8686
}
8787
}
8888

89-
/**
90-
* Check validation before saving the payment information
91-
*
92-
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject
93-
* @param int $cartId
94-
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
95-
* @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress
96-
* @return void
97-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
98-
* @throws \Magento\Framework\Exception\NoSuchEntityException
99-
* @throws \Magento\Framework\Exception\CouldNotSaveException
100-
*/
101-
public function beforeSavePaymentInformation(
102-
\Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
103-
$cartId,
104-
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
105-
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
106-
) {
107-
$quote = $this->quoteRepository->getActive($cartId);
108-
if ($this->isAgreementEnabled() && !$quote->getIsMultiShipping()) {
109-
$this->validateAgreements($paymentMethod);
110-
}
111-
}
112-
11389
/**
11490
* Validate agreements base on the payment method
11591
*

app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,9 @@ public function testBeforeSavePaymentInformationAndPlaceOrder()
126126
->willReturn(true);
127127
$searchCriteriaMock = $this->createMock(SearchCriteria::class);
128128
$this->quoteMock
129-
->expects($this->once())
130129
->method('getIsMultiShipping')
131130
->willReturn(false);
132131
$this->quoteRepositoryMock
133-
->expects($this->once())
134132
->method('getActive')
135133
->with($cartId)
136134
->willReturn($this->quoteMock);
@@ -146,7 +144,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrder()
146144
$this->paymentMock->expects(static::atLeastOnce())
147145
->method('getExtensionAttributes')
148146
->willReturn($this->extensionAttributesMock);
149-
$this->model->beforeSavePaymentInformation(
147+
$this->model->beforeSavePaymentInformationAndPlaceOrder(
150148
$this->subjectMock,
151149
$cartId,
152150
$this->paymentMock,
@@ -166,11 +164,9 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
166164
->willReturn(true);
167165
$searchCriteriaMock = $this->createMock(SearchCriteria::class);
168166
$this->quoteMock
169-
->expects($this->once())
170167
->method('getIsMultiShipping')
171168
->willReturn(false);
172169
$this->quoteRepositoryMock
173-
->expects($this->once())
174170
->method('getActive')
175171
->with($cartId)
176172
->willReturn($this->quoteMock);
@@ -186,7 +182,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
186182
$this->paymentMock->expects(static::atLeastOnce())
187183
->method('getExtensionAttributes')
188184
->willReturn($this->extensionAttributesMock);
189-
$this->model->beforeSavePaymentInformation(
185+
$this->model->beforeSavePaymentInformationAndPlaceOrder(
190186
$this->subjectMock,
191187
$cartId,
192188
$this->paymentMock,
@@ -198,40 +194,6 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
198194
);
199195
}
200196

201-
public function testBeforeSavePaymentInformation()
202-
{
203-
$cartId = 100;
204-
$agreements = [1, 2, 3];
205-
$this->scopeConfigMock
206-
->expects($this->once())
207-
->method('isSetFlag')
208-
->with(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE)
209-
->willReturn(true);
210-
$this->quoteMock
211-
->expects($this->once())
212-
->method('getIsMultiShipping')
213-
->willReturn(false);
214-
$this->quoteRepositoryMock
215-
->expects($this->once())
216-
->method('getActive')
217-
->with($cartId)
218-
->willReturn($this->quoteMock);
219-
$searchCriteriaMock = $this->createMock(SearchCriteria::class);
220-
$this->agreementsFilterMock->expects($this->once())
221-
->method('buildSearchCriteria')
222-
->willReturn($searchCriteriaMock);
223-
$this->checkoutAgreementsListMock->expects($this->once())
224-
->method('getList')
225-
->with($searchCriteriaMock)
226-
->willReturn([1]);
227-
$this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements);
228-
$this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true);
229-
$this->paymentMock->expects(static::atLeastOnce())
230-
->method('getExtensionAttributes')
231-
->willReturn($this->extensionAttributesMock);
232-
$this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock);
233-
}
234-
235197
/**
236198
* Build payment extension mock.
237199
*

app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
use Magento\Customer\Model\ResourceModel\Customer;
99
use Magento\Customer\Ui\Component\DataProvider\Document;
10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
1112
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
1213
use Magento\Framework\Event\ManagerInterface as EventManager;
1314
use Magento\Framework\Locale\ResolverInterface;
15+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1416
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
1517
use Psr\Log\LoggerInterface as Logger;
1618

@@ -24,6 +26,11 @@ class Collection extends SearchResult
2426
*/
2527
private $localeResolver;
2628

29+
/**
30+
* @var TimezoneInterface
31+
*/
32+
private $timeZone;
33+
2734
/**
2835
* @inheritdoc
2936
*/
@@ -42,6 +49,7 @@ class Collection extends SearchResult
4249
* @param ResolverInterface $localeResolver
4350
* @param string $mainTable
4451
* @param string $resourceModel
52+
* @param TimezoneInterface|null $timeZone
4553
*/
4654
public function __construct(
4755
EntityFactory $entityFactory,
@@ -50,10 +58,13 @@ public function __construct(
5058
EventManager $eventManager,
5159
ResolverInterface $localeResolver,
5260
$mainTable = 'customer_grid_flat',
53-
$resourceModel = Customer::class
61+
$resourceModel = Customer::class,
62+
TimezoneInterface $timeZone = null
5463
) {
5564
$this->localeResolver = $localeResolver;
5665
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
66+
$this->timeZone = $timeZone ?: ObjectManager::getInstance()
67+
->get(TimezoneInterface::class);
5768
}
5869

5970
/**
@@ -81,6 +92,14 @@ public function addFieldToFilter($field, $condition = null)
8192
return $this;
8293
}
8394

95+
if ($field === 'created_at') {
96+
if (is_array($condition)) {
97+
foreach ($condition as $key => $value) {
98+
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
99+
}
100+
}
101+
}
102+
84103
if (is_string($field) && count(explode('.', $field)) === 1) {
85104
$field = 'main_table.' . $field;
86105
}

0 commit comments

Comments
 (0)