Skip to content

Commit 75025d6

Browse files
committed
MC-39953: After changing the layout the theme doesn't apply
1 parent 7e72494 commit 75025d6

File tree

3 files changed

+107
-10
lines changed

3 files changed

+107
-10
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function execute()
8484
$page = $this->pageRepository->getById($pageId);
8585
try {
8686
$extendedPageData = $page->getData();
87-
$pageData = $this->filterPostWithoutDate($postItems[$pageId], $extendedPageData);
87+
$pageData = $this->filterPostWithDateConverting($postItems[$pageId], $extendedPageData);
8888
$this->validatePost($pageData, $page, $error, $messages);
8989
$this->setCmsPageData($page, $extendedPageData, $pageData);
9090
$this->pageRepository->save($page);
@@ -128,28 +128,30 @@ protected function filterPost($postData = [])
128128
}
129129

130130
/**
131-
* Filtering posted data without changing custom theme dates
131+
* Filtering posted data with converting custom theme dates to proper format
132132
*
133133
* @param array $postData
134134
* @param array $pageData
135135
* @return array
136136
*/
137-
private function filterPostWithoutDate($postData = [], $pageData = [])
137+
private function filterPostWithDateConverting($postData = [], $pageData = [])
138138
{
139139
$newPageData = $this->filterPost($postData);
140140
if (
141-
!empty($newPageData['custom_theme_from']) &&
142-
date("Y-m-d", strtotime($postData['custom_theme_from'])) ===
143-
date("Y-m-d", strtotime($pageData['custom_theme_from']))
141+
!empty($newPageData['custom_theme_from'])
142+
&& date("Y-m-d", strtotime($postData['custom_theme_from']))
143+
=== date("Y-m-d", strtotime($pageData['custom_theme_from']))
144144
) {
145145
$newPageData['custom_theme_from'] = date("Y-m-d", strtotime($postData['custom_theme_from']));
146-
} elseif (
147-
!empty($newPageData['custom_theme_to']) &&
148-
date("Y-m-d", strtotime($postData['custom_theme_to'])) ===
149-
date("Y-m-d", strtotime($pageData['custom_theme_to']))
146+
}
147+
if (
148+
!empty($newPageData['custom_theme_to'])
149+
&& date("Y-m-d", strtotime($postData['custom_theme_to']))
150+
=== date("Y-m-d", strtotime($pageData['custom_theme_to']))
150151
) {
151152
$newPageData['custom_theme_to'] = date("Y-m-d", strtotime($postData['custom_theme_to']));
152153
}
154+
153155
return $newPageData;
154156
}
155157

app/code/Magento/Cms/Test/Mftf/Section/CmsNewPagePageContentSection/CmsDesignSection.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1010
<section name="CmsDesignSection">
1111
<element name="DesignTab" type="button" selector="//strong[@class='admin__collapsible-title']//span[text()='Design']"/>
12+
<element name="customDesignUpdateTab" type="button" selector="//strong[@class='admin__collapsible-title']//span[text()='Custom Design Update']"/>
13+
<element name="customDesignFrom" type="input" selector="input[name='custom_theme_from']"/>
14+
<element name="customDesignTo" type="input" selector="input[name='custom_theme_to']"/>
15+
<element name="customDesignFromGrid" type="input" selector="tr.data-grid-editable-row:not([style*='display: none']) [name='custom_theme_from']"/>
16+
<element name="customDesignToGrid" type="input" selector="tr.data-grid-editable-row:not([style*='display: none']) [name='custom_theme_to']"/>
17+
<element name="customLayoutGrid" type="input" selector="tr.data-grid-editable-row:not([style*='display: none']) [name='page_layout']"/>
18+
<element name="saveInGrid" type="button" selector="tr.data-grid-editable-row-actions button.action-primary" timeout="30"/>
19+
<element name="customTheme" type="select" selector="select[name='custom_theme']"/>
1220
<element name="LayoutDropdown" type="select" selector="select[name='page_layout']"/>
1321
</section>
1422
</sections>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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="AdminCMSPageInlineEditTest">
11+
<annotations>
12+
<features value="Cms"/>
13+
<stories value="Edit CMS Page"/>
14+
<title value="Inline changing CMS page custom theme will be applied with proper dates"/>
15+
<description value="Verify that Merchant can inline edit CMS pages in grid and dates will be proper"/>
16+
<testCaseId value="MC-40900" />
17+
<severity value="MAJOR"/>
18+
<group value="cms"/>
19+
<group value="ui"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
</before>
24+
<after>
25+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="resetGridFilters"/>
26+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
27+
</after>
28+
<generateDate date="+0 day" format="m/d/Y" stepKey="today"/>
29+
<generateDate date="+1 day" format="m/d/Y" stepKey="tomorrow"/>
30+
<generateDate date="+0 day" format="M j, Y" stepKey="todayFormatted"/>
31+
<generateDate date="+1 day" format="M j, Y" stepKey="tomorrowFormatted"/>
32+
<generateDate date="+100 day" format="m/d/Y" stepKey="newDateFrom"/>
33+
<generateDate date="+101 day" format="m/d/Y" stepKey="newDateTo"/>
34+
<generateDate date="+100 day" format="M j, Y" stepKey="newDateFromFormatted"/>
35+
<generateDate date="+101 day" format="M j, Y" stepKey="newDateToFormatted"/>
36+
<actionGroup ref="AdminOpenCMSPagesGridActionGroup" stepKey="navigateToCmsPageGrid"/>
37+
<waitForPageLoad stepKey="waitForCmsPageGrid"/>
38+
<actionGroup ref="AdminGridColumnShowActionGroup" stepKey="showCustomerEmailColumn">
39+
<argument name="columnLabel" value="Custom design from"/>
40+
</actionGroup>
41+
<actionGroup ref="AdminGridColumnShowActionGroup" stepKey="showCustomerEmailColumnTwo">
42+
<argument name="columnLabel" value="Custom design to"/>
43+
</actionGroup>
44+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
45+
<fillField selector="{{AdminDataGridHeaderSection.search}}" userInput="404 Not Found" stepKey="fillKeywordSearchFieldWithSecondCustomerEmail"/>
46+
<click selector="{{AdminDataGridHeaderSection.submitSearch}}" stepKey="clickKeywordSearch"/>
47+
<waitForPageLoad stepKey="waitForPageLoad"/>
48+
<see userInput="404 Not Found" selector="{{AdminGridRow.rowOne}}" stepKey="seeFirstCmsPageAfterFiltering"/>
49+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsInCmsPageGrid"/>
50+
<click selector="{{CmsPagesPageActionsSection.firstItemSelectButton}}" stepKey="clickOnSelectButton"/>
51+
<click selector="{{CmsPagesPageActionsSection.firstItemEditButton}}" stepKey="clickOnEditButton"/>
52+
<waitForPageLoad stepKey="waitForEditPageLoad"/>
53+
<click selector="{{CmsDesignSection.customDesignUpdateTab}}" stepKey="clickOnDesignTab"/>
54+
<waitForElementVisible selector="{{CmsDesignSection.customDesignFrom}}" stepKey="waitForLayoutDropDown" />
55+
<fillField selector="{{CmsDesignSection.customDesignFrom}}" userInput="{$today}" stepKey="fillDateFrom"/>
56+
<fillField selector="{{CmsDesignSection.customDesignTo}}" userInput="{$tomorrow}" stepKey="fillDateTo"/>
57+
<selectOption selector="{{CmsDesignSection.customTheme}}" userInput="Magento Blank" stepKey="fillCustomTheme"/>
58+
<click selector="{{CmsNewPagePageActionsSection.expandSplitButton}}" stepKey="expandButtonMenu"/>
59+
<waitForElementVisible selector="{{CmsNewPagePageActionsSection.splitButtonMenu}}" stepKey="waitForSplitButtonMenuVisible"/>
60+
<click selector="{{CmsNewPagePageActionsSection.savePage}}" stepKey="clickSavePage"/>
61+
<see userInput="You saved the page." stepKey="seeSuccessMessage"/>
62+
<see userInput="{$todayFormatted}" selector="{{AdminOrdersGridSection.gridCell('2','Custom design from')}}" stepKey="assertCustomDesignFrom"/>
63+
<see userInput="{$tomorrowFormatted}" selector="{{AdminOrdersGridSection.gridCell('2','Custom design to')}}" stepKey="assertCustomDesignTo"/>
64+
<click selector="{{AdminDataGridTableSection.rows}}" stepKey="clickEdit"/>
65+
<waitForElementVisible selector="{{CmsDesignSection.customLayoutGrid}}" stepKey="waitForDate"/>
66+
<selectOption userInput="2 columns with right bar" selector="{{CmsDesignSection.customLayoutGrid}}" stepKey="changeLayoutFromGrid"/>
67+
<click selector="{{CmsDesignSection.saveInGrid}}" stepKey="clickSaveFromGrid"/>
68+
<waitForPageLoad stepKey="waitForPageSave"/>
69+
<see userInput="{$todayFormatted}" selector="{{AdminOrdersGridSection.gridCell('2','Custom design from')}}" stepKey="assertCustomDesignFrom2"/>
70+
<see userInput="{$tomorrowFormatted}" selector="{{AdminOrdersGridSection.gridCell('2','Custom design to')}}" stepKey="assertCustomDesignTo2"/>
71+
<click selector="{{AdminDataGridTableSection.rows}}" stepKey="clickEdit2"/>
72+
<waitForElementVisible selector="{{CmsDesignSection.customLayoutGrid}}" stepKey="waitForDate2"/>
73+
<selectOption userInput="2 columns with left bar" selector="{{CmsDesignSection.customLayoutGrid}}" stepKey="changeLayoutFromGrid2"/>
74+
<click selector="{{CmsDesignSection.saveInGrid}}" stepKey="clickSaveFromGrid2"/>
75+
<waitForPageLoad stepKey="waitForPageSave2"/>
76+
<see userInput="{$todayFormatted}" selector="{{AdminOrdersGridSection.gridCell('2','Custom design from')}}" stepKey="assertCustomDesignFrom3"/>
77+
<see userInput="{$tomorrowFormatted}" selector="{{AdminOrdersGridSection.gridCell('2','Custom design to')}}" stepKey="assertCustomDesignTo3"/>
78+
<click selector="{{AdminDataGridTableSection.rows}}" stepKey="clickEdit3"/>
79+
<waitForElementVisible selector="{{CmsDesignSection.customDesignFromGrid}}" stepKey="waitForDate3"/>
80+
<fillField selector="{{CmsDesignSection.customDesignFromGrid}}" userInput="{$newDateFrom}" stepKey="fillDateFromInGrid"/>
81+
<fillField selector="{{CmsDesignSection.customDesignToGrid}}" userInput="{$newDateTo}" stepKey="fillDateToInGrid"/>
82+
<click selector="{{CmsDesignSection.saveInGrid}}" stepKey="clickSaveFromGrid3"/>
83+
<waitForPageLoad stepKey="waitForPageSave3"/>
84+
<see userInput="{$newDateFromFormatted}" selector="{{AdminOrdersGridSection.gridCell('2','Custom design from')}}" stepKey="assertCustomDesignFrom4"/>
85+
<see userInput="{$newDateToFormatted}" selector="{{AdminOrdersGridSection.gridCell('2','Custom design to')}}" stepKey="assertCustomDesignTo4"/>
86+
</test>
87+
</tests>

0 commit comments

Comments
 (0)