Skip to content

Commit 6ae3305

Browse files
committed
Merge remote-tracking branch 'origin/MC-37540' into 2.4-develop-sidecar-pr6
2 parents c528377 + 533a39d commit 6ae3305

File tree

5 files changed

+241
-0
lines changed

5 files changed

+241
-0
lines changed

app/code/Magento/Cms/Test/Mftf/Data/BlockData.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@
1515
<data key="content">sales25off everything!</data>
1616
<data key="is_active">0</data>
1717
</entity>
18+
<entity name="ActiveTestBlock" type="block">
19+
<data key="title" unique="suffix">Test Block</data>
20+
<data key="identifier" unique="suffix">ActiveTestBlock</data>
21+
<data key="store_id">All Store Views</data>
22+
<data key="content">Test Block content</data>
23+
<data key="is_active">1</data>
24+
</entity>
1825
</entities>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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="AdminUseQuickSearchInAdminDataGridsTest">
11+
<annotations>
12+
<features value="Cms"/>
13+
<stories value="Create CMS Page"/>
14+
<title value="[CMS Grids] Use quick search in Admin data grids"/>
15+
<description value="Verify that Merchant can use quick search in order to simplify the data grid filtering in Admin"/>
16+
<testCaseId value="MC-27559" />
17+
<severity value="MAJOR"/>
18+
<group value="cms"/>
19+
<group value="ui"/>
20+
</annotations>
21+
<before>
22+
<createData entity="simpleCmsPage" stepKey="createFirstCMSPage" />
23+
<createData entity="_newDefaultCmsPage" stepKey="createSecondCMSPage" />
24+
<createData entity="_emptyCmsPage" stepKey="createThirdCMSPage" />
25+
<createData entity="Sales25offBlock" stepKey="createFirstCmsBlock"/>
26+
<createData entity="ActiveTestBlock" stepKey="createSecondCmsBlock"/>
27+
<createData entity="_emptyCmsBlock" stepKey="createThirdCmsBlock"/>
28+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
29+
</before>
30+
<after>
31+
<deleteData createDataKey="createFirstCMSPage" stepKey="deleteFirstCMSPage" />
32+
<deleteData createDataKey="createSecondCMSPage" stepKey="deleteSecondCMSPage" />
33+
<deleteData createDataKey="createThirdCMSPage" stepKey="deleteThirdCMSPage" />
34+
<deleteData createDataKey="createFirstCmsBlock" stepKey="deleteFirstCmsBlock" />
35+
<deleteData createDataKey="createSecondCmsBlock" stepKey="deleteSecondCmsBlock" />
36+
<deleteData createDataKey="createThirdCmsBlock" stepKey="deleteThirdCmsBlock" />
37+
<actionGroup ref="AdminOpenCMSPagesGridActionGroup" stepKey="navigateToCMSPageGrid"/>
38+
<actionGroup ref="AdminGridFilterResetActionGroup" stepKey="clearCmsPagesGridFilters"/>
39+
<actionGroup ref="AdminOpenCmsBlocksGridActionGroup" stepKey="navigateToCmsBlockGrid"/>
40+
<actionGroup ref="AdminGridFilterResetActionGroup" stepKey="clearCmsBlockGridFilters"/>
41+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
42+
</after>
43+
<!--Go to "Cms Pages Grid" page and filter by title-->
44+
<actionGroup ref="AdminOpenCMSPagesGridActionGroup" stepKey="navigateToCmsPageGrid"/>
45+
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchFirstCmsPage">
46+
<argument name="keyword" value="$createFirstCMSPage.title$"/>
47+
</actionGroup>
48+
<see userInput="$createFirstCMSPage.title$" selector="{{AdminGridRow.rowOne}}" stepKey="seeFirstCmsPageAfterFiltering"/>
49+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsInCmsPageGrid"/>
50+
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchSecondCmsPage">
51+
<argument name="keyword" value="$createSecondCMSPage.title$"/>
52+
</actionGroup>
53+
<see userInput="$createSecondCMSPage.title$" selector="{{AdminGridRow.rowOne}}" stepKey="seeSecondCmsPageAfterFiltering"/>
54+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsAfterFilteringSecondCmsPage"/>
55+
<actionGroup ref="AdminGridFilterResetActionGroup" stepKey="clearGridFilters"/>
56+
<grabTextFrom selector="{{AdminGridHeaders.totalRecords}}" stepKey="grabTotalRecordsCmsPagesBeforeClickSearchButton"/>
57+
<click selector="{{AdminDataGridHeaderSection.submitSearch}}" stepKey="clickSearchMagnifierButton"/>
58+
<grabTextFrom selector="{{AdminGridHeaders.totalRecords}}" stepKey="grabTotalRecordsCmsPagesAfterClickSearchButton"/>
59+
<assertEquals stepKey="assertTotalRecordsCmsPages">
60+
<expectedResult type="string">$grabTotalRecordsCmsPagesBeforeClickSearchButton</expectedResult>
61+
<actualResult type="string">$grabTotalRecordsCmsPagesAfterClickSearchButton</actualResult>
62+
</assertEquals>
63+
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="enterNonExistentEntityInQuickSearch">
64+
<argument name="keyword" value="TestQueryNonExistentEntity"/>
65+
</actionGroup>
66+
<dontSeeElement selector="{{AdminDataGridTableSection.rows}}" stepKey="dontSeeResultRows"/>
67+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsAfterFilteringNonExistentCmsPage">
68+
<argument name="number" value="0"/>
69+
</actionGroup>
70+
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchThirdCmsPage">
71+
<argument name="keyword" value="$createThirdCMSPage.title$"/>
72+
</actionGroup>
73+
<see userInput="$createThirdCMSPage.title$" selector="{{AdminGridRow.rowOne}}" stepKey="seeThirdCmsPageAfterFiltering"/>
74+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsAfterFilteringThirdCmsPage"/>
75+
76+
<!--Go to "Cms Blocks Grid" page and filter by title-->
77+
<actionGroup ref="AdminOpenCmsBlocksGridActionGroup" stepKey="navigateToCmsBlockGrid"/>
78+
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchFirstCmsBlock">
79+
<argument name="keyword" value="$createFirstCmsBlock.title$"/>
80+
</actionGroup>
81+
<see userInput="$createFirstCmsBlock.title$" selector="{{AdminGridRow.rowOne}}" stepKey="seeFirstCmsBlockAfterFiltering"/>
82+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsInBlockGrid"/>
83+
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchSecondCmsBlock">
84+
<argument name="keyword" value="$createSecondCmsBlock.title$"/>
85+
</actionGroup>
86+
<see userInput="$createSecondCmsBlock.title$" selector="{{AdminGridRow.rowOne}}" stepKey="seeSecondCmsBlockAfterFiltering"/>
87+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsAfterFilteringSecondBlock"/>
88+
<actionGroup ref="AdminGridFilterResetActionGroup" stepKey="clearGridFiltersOnBlocksGridPage"/>
89+
<grabTextFrom selector="{{AdminGridHeaders.totalRecords}}" stepKey="grabTotalRecordsBlocksBeforeClickSearchButton"/>
90+
<click selector="{{AdminDataGridHeaderSection.submitSearch}}" stepKey="clickSearchMagnifierButtonOnBlocksGridPage"/>
91+
<grabTextFrom selector="{{AdminGridHeaders.totalRecords}}" stepKey="grabTotalRecordsBlocksAfterClickSearchButton"/>
92+
<assertEquals stepKey="assertTotalRecordsBlocks">
93+
<expectedResult type="string">$grabTotalRecordsBlocksBeforeClickSearchButton</expectedResult>
94+
<actualResult type="string">$grabTotalRecordsBlocksAfterClickSearchButton</actualResult>
95+
</assertEquals>
96+
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="enterNonExistentEntityInQuickSearchOnBlocksGridPage">
97+
<argument name="keyword" value="TestQueryNonExistentEntity"/>
98+
</actionGroup>
99+
<dontSeeElement selector="{{AdminDataGridTableSection.rows}}" stepKey="dontSeeResultRowsOnBlocksGrid"/>
100+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsAfterFilteringNonExistentCmsBlock">
101+
<argument name="number" value="0"/>
102+
</actionGroup>
103+
<actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchThirdCmsBlock">
104+
<argument name="keyword" value="$createThirdCmsBlock.title$"/>
105+
</actionGroup>
106+
<see userInput="$createThirdCmsBlock.title$" selector="{{AdminGridRow.rowOne}}" stepKey="seeThirdCmsBlockAfterFiltering"/>
107+
<actionGroup ref="AdminAssertNumberOfRecordsInUiGridActionGroup" stepKey="assertNumberOfRecordsAfterFilteringThirdBlock"/>
108+
</test>
109+
</tests>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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="AdminAssertNumberOfRecordsInUiGridActionGroup">
12+
<annotations>
13+
<description>Validates that the Number of Records listed on the Ui grid page is present and correct.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="number" type="string" defaultValue="1"/>
17+
</arguments>
18+
<see userInput="{{number}} records found" selector="{{AdminGridHeaders.totalRecords}}" stepKey="seeRecords"/>
19+
</actionGroup>
20+
</actionGroups>

app/code/Magento/Ui/Test/Mftf/Section/AdminGridControlsSection/AdminGridHeadersSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<element name="title" type="text" selector=".page-title-wrapper h1"/>
1212
<element name="headerByName" type="text" selector="//div[@data-role='grid-wrapper']//span[@class='data-grid-cell-content' and contains(text(), '{{var1}}')]/parent::*" parameterized="true"/>
1313
<element name="columnsNames" type="text" selector="[data-role='grid-wrapper'] .data-grid-th &gt; span"/>
14+
<element name="totalRecords" type="text" selector="div.admin__data-grid-header-row.row.row-gutter div.row div.admin__control-support-text"/>
1415
</section>
1516
</sections>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
namespace Magento\Cms\Ui\Component;
9+
10+
use Magento\Cms\Api\Data\BlockInterface;
11+
use Magento\Cms\Api\Data\PageInterface;
12+
use Magento\Framework\App\RequestInterface;
13+
use Magento\Framework\ObjectManagerInterface;
14+
use Magento\Framework\View\Element\UiComponentFactory;
15+
use Magento\Framework\View\Element\UiComponentInterface;
16+
use Magento\TestFramework\Helper\Bootstrap;
17+
use PHPUnit\Framework\TestCase;
18+
19+
/**
20+
* Checks Cms UI component data provider behaviour
21+
*
22+
* @magentoAppArea adminhtml
23+
* @magentoDbIsolation enabled
24+
*/
25+
class DataProviderTest extends TestCase
26+
{
27+
/** @var ObjectManagerInterface */
28+
private $objectManager;
29+
30+
/** @var UiComponentFactory */
31+
private $componentFactory;
32+
33+
/** @var RequestInterface */
34+
private $request;
35+
36+
/**
37+
* @inheritdoc
38+
*/
39+
protected function setUp(): void
40+
{
41+
parent::setUp();
42+
43+
$this->objectManager = Bootstrap::getObjectManager();
44+
$this->request = $this->objectManager->get(RequestInterface::class);
45+
$this->componentFactory = $this->objectManager->get(UiComponentFactory::class);
46+
}
47+
48+
/**
49+
* @magentoDataFixture Magento/Cms/_files/pages.php
50+
*
51+
* @return void
52+
*/
53+
public function testPageFilteringByTitlePart(): void
54+
{
55+
$this->request->setParams(['search' => 'Cms Page 1']);
56+
$data = $this->getComponentProvidedData('cms_page_listing');
57+
$items = $data['items'];
58+
$this->assertCount(1, $items);
59+
$this->assertEquals('page100', reset($items)[PageInterface::IDENTIFIER]);
60+
}
61+
62+
/**
63+
* @magentoDataFixture Magento/Cms/_files/blocks.php
64+
*
65+
* @return void
66+
*/
67+
public function testBlockFilteringByTitlePart(): void
68+
{
69+
$this->request->setParams(['search' => 'Enabled CMS Block']);
70+
$data = $this->getComponentProvidedData('cms_block_listing');
71+
$items = $data['items'];
72+
$this->assertCount(1, $items);
73+
$this->assertEquals('enabled_block', reset($items)[BlockInterface::IDENTIFIER]);
74+
}
75+
76+
/**
77+
* Call prepare method in the child components
78+
*
79+
* @param UiComponentInterface $component
80+
* @return void
81+
*/
82+
private function prepareChildComponents(UiComponentInterface $component): void
83+
{
84+
foreach ($component->getChildComponents() as $child) {
85+
$this->prepareChildComponents($child);
86+
}
87+
88+
$component->prepare();
89+
}
90+
91+
/**
92+
* Get component provided data
93+
*
94+
* @param string $namespace
95+
* @return array
96+
*/
97+
private function getComponentProvidedData(string $namespace): array
98+
{
99+
$component = $this->componentFactory->create($namespace);
100+
$this->prepareChildComponents($component);
101+
102+
return $component->getContext()->getDataProvider()->getData();
103+
}
104+
}

0 commit comments

Comments
 (0)