Skip to content

Commit bdf3746

Browse files
committed
Merge branch 'ACP2E-1435' of https://github.com/magento-l3/magento2ce into PR-L3-2023-01-31
2 parents 5feff93 + 9182f77 commit bdf3746

File tree

7 files changed

+221
-2
lines changed

7 files changed

+221
-2
lines changed

app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
*/
66
namespace Magento\Reports\Block\Adminhtml\Shopcart\Abandoned;
77

8+
use Magento\Framework\App\ObjectManager;
9+
use Magento\Framework\Stdlib\Parameters;
10+
use Magento\Framework\Url\DecoderInterface;
11+
812
/**
913
* Adminhtml abandoned shopping carts report grid block
1014
*
@@ -15,6 +19,16 @@
1519
*/
1620
class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
1721
{
22+
/**
23+
* @var DecoderInterface
24+
*/
25+
private $urlDecoder;
26+
27+
/**
28+
* @var Parameters
29+
*/
30+
private $parameters;
31+
1832
/**
1933
* @var \Magento\Reports\Model\ResourceModel\Quote\CollectionFactory
2034
*/
@@ -24,16 +38,22 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
2438
* @param \Magento\Backend\Block\Template\Context $context
2539
* @param \Magento\Backend\Helper\Data $backendHelper
2640
* @param \Magento\Reports\Model\ResourceModel\Quote\CollectionFactory $quotesFactory
41+
* @param DecoderInterface|null $urlDecoder
42+
* @param Parameters|null $parameters
2743
* @param array $data
2844
*/
2945
public function __construct(
3046
\Magento\Backend\Block\Template\Context $context,
3147
\Magento\Backend\Helper\Data $backendHelper,
3248
\Magento\Reports\Model\ResourceModel\Quote\CollectionFactory $quotesFactory,
49+
DecoderInterface $urlDecoder = null,
50+
Parameters $parameters = null,
3351
array $data = []
3452
) {
3553
$this->_quotesFactory = $quotesFactory;
3654
parent::__construct($context, $backendHelper, $data);
55+
$this->urlDecoder = $urlDecoder ?? ObjectManager::getInstance()->get(DecoderInterface::class);
56+
$this->parameters = $parameters ?? ObjectManager::getInstance()->get(Parameters::class);
3757
}
3858

3959
/**
@@ -59,8 +79,12 @@ protected function _prepareCollection()
5979

6080
$filter = $this->getParam($this->getVarNameFilter(), []);
6181
if ($filter) {
62-
$filter = base64_decode($filter);
63-
parse_str(urldecode($filter), $data);
82+
// this is a replacement for base64_decode()
83+
$filter = $this->urlDecoder->decode($filter);
84+
85+
// this is a replacement for parse_str()
86+
$this->parameters->fromString($filter);
87+
$data = $this->parameters->toArray();
6488
}
6589

6690
if (!empty($data)) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminAbandonedCartsReportFilterEmailActionGroup">
11+
<annotations>
12+
<description>Filter in "Abandoned Carts" report by email.</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="email" type="string" defaultValue="{{Simple_US_Customer.email}}"/>
16+
</arguments>
17+
18+
<fillField selector="{{AbandonedCartsReportMainSection.email}}" userInput="{{email}}" stepKey="fillEmailFilterField" />
19+
<click selector="{{AbandonedCartsReportMainSection.searchButton}}" stepKey="clickSearch"/>
20+
</actionGroup>
21+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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="AdminAssertNumberOfRecordsInAbandonedCartsReportActionGroup">
12+
<annotations>
13+
<description>Validates that the Number of Records listed on the Abandoned Carts Report grid page is present and correct.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="number" type="string" defaultValue="1"/>
17+
</arguments>
18+
<grabTextFrom selector="{{AbandonedCartsReportMainSection.recordsFound}}" stepKey="grabAbandonedCartsAmount"/>
19+
<assertEquals message="Wrong records were found, should be only 1" stepKey="checkNumberOfRecords">
20+
<expectedResult type="string">{{number}}</expectedResult>
21+
<actualResult type="variable">grabAbandonedCartsAmount</actualResult>
22+
</assertEquals>
23+
</actionGroup>
24+
</actionGroups>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
9+
<page name="AdminAbandonedCartsReportPage" url="reports/report_shopcart/abandoned/" area="admin" module="Reports">
10+
<section name="AbandonedCartsReportMainSection"/>
11+
<section name="AbandonedCartsGridSection"/>
12+
</page>
13+
</pages>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AbandonedCartsGridSection">
12+
<element name="email" type="input" selector="//tr/td[contains(@class, 'col-email')][contains(text(), '{{email1}}')]" parameterized="true"/>
13+
</section>
14+
</sections>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AbandonedCartsReportMainSection">
12+
<element name="customer" type="input" selector="#gridAbandoned_filter_customer_name"/>
13+
<element name="email" type="input" selector="#gridAbandoned_filter_email"/>
14+
<element name="searchButton" type="button" selector="//button/span[text()='Search']"/>
15+
<element name="resetButton" type="button" selector="//button/span[text()='Reset Filter']"/>
16+
<element name="recordsFound" type="text" selector="#gridAbandoned-total-count"/>
17+
</section>
18+
</sections>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminReportsAbandonedCartsSearchEmailWithPlusTest">
12+
<annotations>
13+
<features value="Reports"/>
14+
<stories value="Search in Grid"/>
15+
<title value="Admin Reports Abandoned Carts Search Email With Plus"/>
16+
<description value="Admin should be able to search for email that contains plus > Abandoned Carts"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-7465"/>
19+
<useCaseId value="ACP2E-1435"/>
20+
<group value="reports"/>
21+
</annotations>
22+
<before>
23+
<!-- Create Category and Product -->
24+
<createData entity="_defaultCategory" stepKey="createCategory"/>
25+
<createData entity="_defaultProduct" stepKey="createProduct" />
26+
27+
<!-- Create Customers -->
28+
<createData entity="Simple_US_Customer" stepKey="createCustomer">
29+
<field key="email">John+Doe@example.com</field>
30+
</createData>
31+
<createData entity="Simple_US_Customer" stepKey="createCustomer2">
32+
<field key="email">JohnDoe@example.com</field>
33+
</createData>
34+
35+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
36+
</before>
37+
38+
<after>
39+
<!-- Delete created Product, Category and Customers -->
40+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
41+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
42+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
43+
<deleteData createDataKey="createCustomer2" stepKey="deleteCustomer2"/>
44+
45+
<!-- Reset filter on Abandoned Carts Report page -->
46+
<amOnPage url="{{AdminAbandonedCartsReportPage.url}}" stepKey="amOnAbandonedCartsReportPage"/>
47+
<click selector="{{AbandonedCartsReportMainSection.resetButton}}" stepKey="clickResetButton"/>
48+
49+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
50+
</after>
51+
52+
<!-- Login as a Customer on Storefront -->
53+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomerToStorefront">
54+
<argument name="Customer" value="$createCustomer$"/>
55+
</actionGroup>
56+
57+
<!-- Open product and add product to cart of the first customer -->
58+
<actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openProductFromCategory">
59+
<argument name="productUrlKey" value="$$createProduct.custom_attributes[url_key]$$"/>
60+
</actionGroup>
61+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addProductToCart">
62+
<argument name="product" value="$createProduct$"/>
63+
<argument name="productCount" value="1"/>
64+
</actionGroup>
65+
66+
<!-- Logout from customer account -->
67+
<actionGroup ref="CustomerLogoutStorefrontByMenuItemsActionGroup" stepKey="logoutFirstCustomer"/>
68+
69+
<!-- Login as a second Customer on Storefront -->
70+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomerToStorefront2">
71+
<argument name="Customer" value="$createCustomer2$"/>
72+
</actionGroup>
73+
74+
<!-- Open product and add product to cart of the first customer -->
75+
<actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openProductFromCategory2">
76+
<argument name="productUrlKey" value="$$createProduct.custom_attributes[url_key]$$"/>
77+
</actionGroup>
78+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addProductToCart2">
79+
<argument name="product" value="$createProduct$"/>
80+
<argument name="productCount" value="1"/>
81+
</actionGroup>
82+
83+
<!-- Open Abandoned carts report in Admin -->
84+
<amOnPage url="{{AdminDashboardPage.url}}" stepKey="amOnDashboardPage"/>
85+
<actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToAbandonedCartsPage">
86+
<argument name="menuUiId" value="{{AdminMenuReports.dataUiId}}"/>
87+
<argument name="submenuUiId" value="{{AdminMenuReportsMarketingAbandonedCarts.dataUiId}}"/>
88+
</actionGroup>
89+
<actionGroup ref="AdminAssertPageTitleActionGroup" stepKey="seePageTitle">
90+
<argument name="title" value="{{AdminMenuReportsMarketingAbandonedCarts.pageTitle}}"/>
91+
</actionGroup>
92+
93+
<!-- Search for email containing '+' sign -->
94+
<actionGroup ref="AdminAbandonedCartsReportFilterEmailActionGroup" stepKey="searchForEmailWithPlus">
95+
<argument name="email" value="John+"/>
96+
</actionGroup>
97+
98+
<!-- Check record is present -->
99+
<seeElement selector="{{AbandonedCartsGridSection.email('John+')}}" stepKey="seeCartInGrid"/>
100+
101+
<!-- Check that only one record is present -->
102+
<actionGroup ref="AdminAssertNumberOfRecordsInAbandonedCartsReportActionGroup" stepKey="checkOnlyOneRecordIsFound"/>
103+
104+
</test>
105+
</tests>

0 commit comments

Comments
 (0)