Skip to content

Commit 7153b42

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop-expedited-prs
- merged with '2.4-develop-prs' branch
2 parents 15f9e34 + e63d415 commit 7153b42

File tree

15 files changed

+173
-6
lines changed

15 files changed

+173
-6
lines changed

app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ public function applyUpdate(PageLayout $layout, CustomLayoutSelectedInterface $l
147147
}
148148

149149
$layout->addPageLayoutHandles(
150-
['selectable' => $this->sanitizeIdentifier($page) .'_' .$layoutSelected->getLayoutFileId()]
150+
['selectable' => $this->sanitizeIdentifier($page) .'_' .$layoutSelected->getLayoutFileId()],
151+
'cms_page_view'
151152
);
152153
}
153154
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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="AssertAdminCustomerDateOfBirthValidationMessageActionGroup">
12+
<annotations>
13+
<description>Fills 'Date of Birth' input with provided 'dob' value, clicks 'save' button, checks
14+
there is no provided validation error message for the 'Date of Birth' input on the page.</description>
15+
</annotations>
16+
<arguments>
17+
<argument name="message" type="string" defaultValue="The Date of Birth should not be greater than today."/>
18+
<argument name="dob" type="string" defaultValue="15/01/1970"/>
19+
</arguments>
20+
21+
<fillField userInput="{{dob}}" selector="{{AdminCustomerAccountInformationSection.dateOfBirth}}" stepKey="fillDateOfBirth"/>
22+
<click selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="saveCustomer"/>
23+
<dontSee selector="{{AdminCustomerAccountInformationSection.dateOfBirthValidationErrorField}}" userInput="{{message}}" stepKey="seeTheErrorMessageIsDisplayed"/>
24+
</actionGroup>
25+
</actionGroups>

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@
3636
<element name="disabledGroup" type="text" selector="//div[@class='admin__action-group-wrap admin__action-multiselect-wrap action-select-wrap _disabled']"/>
3737
<element name="customerAttribute" type="input" selector="//input[contains(@name,'{{attributeCode}}')]" parameterized="true"/>
3838
<element name="attributeImage" type="block" selector="//div[contains(concat(' ',normalize-space(@class),' '),' file-uploader-preview ')]//img"/>
39+
<element name="dateOfBirthValidationErrorField" type="text" selector="input[name='customer[dob]'] ~ label.admin__field-error"/>
3940
</section>
4041
</sections>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCheckDateOfBirthValidationForFranceDateFormatTest">
11+
<annotations>
12+
<features value="Customer"/>
13+
<stories value="Checks 'Date of Birth' field validation for the France date format value"/>
14+
<title value="Checks 'Date of Birth' field validation for the France date format value"/>
15+
<group value="customer"/>
16+
<group value="ui"/>
17+
</annotations>
18+
<before>
19+
<magentoCLI command="setup:static-content:deploy fr_FR" stepKey="deployStaticContentWithFrenchLocale"/>
20+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
21+
<actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToFrance">
22+
<argument name="InterfaceLocaleByValue" value="fr_FR"/>
23+
</actionGroup>
24+
</before>
25+
26+
<after>
27+
<actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToDefaultValue">
28+
<argument name="InterfaceLocaleByValue" value="en_US"/>
29+
</actionGroup>
30+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
31+
</after>
32+
33+
<actionGroup ref="AdminNavigateNewCustomerActionGroup" stepKey="navigateToNewCustomerPage"/>
34+
<actionGroup ref="AssertAdminCustomerDateOfBirthValidationMessageActionGroup" stepKey="assertDateOfBirthValidationMessage"/>
35+
</test>
36+
</tests>

app/code/Magento/Customer/view/frontend/templates/form/register.phtml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ require([
301301
ignore: ignore ? ':hidden:not(' + ignore + ')' : ':hidden'
302302
<?php endif ?>
303303
}).find('input:text').attr('autocomplete', 'off');
304+
dataForm.submit(function () {
305+
$(this).find(':submit').attr('disabled', 'disabled');
306+
});
307+
dataForm.bind("invalid-form.validate", function () {
308+
$(this).find(':submit').prop('disabled', false);
309+
});
304310

305311
});
306312
</script>

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,12 +1069,12 @@ define([
10691069
$.mage.__('This link is not allowed.')
10701070
],
10711071
'validate-dob': [
1072-
function (value) {
1072+
function (value, param, params) {
10731073
if (value === '') {
10741074
return true;
10751075
}
10761076

1077-
return moment(value).isBefore(moment());
1077+
return moment.utc(value, params.dateFormat).isSameOrBefore(moment.utc());
10781078
},
10791079
$.mage.__('The Date of Birth should not be greater than today.')
10801080
]

dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,20 @@ public function testCustomHandles(): void
8585
$handles = $layout->getUpdate()->getHandles();
8686
$this->assertContains('cms_page_view_selectable_test_custom_layout_page_3_test_selected', $handles);
8787
}
88+
89+
/**
90+
* Check home page custom handle is applied when rendering a page.
91+
*
92+
* @return void
93+
* @throws \Throwable
94+
* @magentoDataFixture Magento/Cms/_files/home_with_custom_handle.php
95+
*/
96+
public function testHomePageCustomHandles(): void
97+
{
98+
$this->dispatch('/');
99+
/** @var LayoutInterface $layout */
100+
$layout = Bootstrap::getObjectManager()->get(LayoutInterface::class);
101+
$handles = $layout->getUpdate()->getHandles();
102+
$this->assertContains('cms_page_view_selectable_home_page_custom_layout', $handles);
103+
}
88104
}

dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ public function testCustomLayoutUpdate(): void
9797
$result = $this->resultFactory->create();
9898
$this->manager->applyUpdate($result, $this->repo->getFor($pageId));
9999
$this->identityMap->remove((int)$page->getId());
100-
$this->assertContains('___selectable_page100_select2', $result->getLayout()->getUpdate()->getHandles());
100+
$this->assertContains(
101+
'cms_page_view_selectable_page100_select2',
102+
$result->getLayout()->getUpdate()->getHandles()
103+
);
101104
}
102105
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Cms\Model\Page as PageModel;
9+
use Magento\Cms\Model\PageFactory as PageModelFactory;
10+
use Magento\TestFramework\Cms\Model\CustomLayoutManager;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
$objectManager = Bootstrap::getObjectManager();
14+
15+
/** @var PageModelFactory $pageFactory */
16+
$pageFactory = $objectManager->get(PageModelFactory::class);
17+
/** @var CustomLayoutManager $fakeManager */
18+
$fakeManager = $objectManager->get(CustomLayoutManager::class);
19+
$layoutRepo = $objectManager->create(PageModel\CustomLayoutRepositoryInterface::class, ['manager' => $fakeManager]);
20+
21+
$customLayoutName = 'page_custom_layout';
22+
23+
/** @var PageModel $page */
24+
$page = $pageFactory->create(['customLayoutRepository' => $layoutRepo]);
25+
$page->load('home');
26+
$cmsPageId = (int)$page->getId();
27+
28+
$fakeManager->fakeAvailableFiles($cmsPageId, [$customLayoutName]);
29+
$page->setData('layout_update_selected', $customLayoutName);
30+
$page->save();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Cms\Api\PageRepositoryInterface;
9+
use Magento\Cms\Model\Page\CustomLayout\CustomLayoutRepository;
10+
use Magento\TestFramework\Helper\Bootstrap;
11+
12+
$objectManager = Bootstrap::getObjectManager();
13+
14+
/** @var PageRepositoryInterface $pageRepository */
15+
$pageRepository = $objectManager->get(PageRepositoryInterface::class);
16+
$cmsPage = $pageRepository->getById('home');
17+
$cmsPageId = (int)$cmsPage->getId();
18+
19+
/** @var CustomLayoutRepository $customLayoutRepository */
20+
$customLayoutRepository = $objectManager->get(CustomLayoutRepository::class);
21+
$customLayoutRepository->deleteFor($cmsPageId);

0 commit comments

Comments
 (0)