From 440a4cf6c465fab862706b4faed460e9dd7f7a29 Mon Sep 17 00:00:00 2001 From: Yash Bhayani <72012678+Yash-Bhayani@users.noreply.github.com> Date: Sat, 10 Oct 2020 17:05:50 +0530 Subject: [PATCH 1/4] Update BackButton.php --- .../Block/Adminhtml/Edit/BackButton.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/BackButton.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/BackButton.php index 11ca201dcdb4c..b8fa812437a5c 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/BackButton.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/BackButton.php @@ -12,6 +12,26 @@ */ class BackButton extends GenericButton implements ButtonProviderInterface { + /** + * @var Form + */ + private $form; + /** + * @var \Magento\Framework\Url\DecoderInterface + */ + private $decoder; + + public function __construct( + \Magento\Framework\Url\DecoderInterface $decoder, + \Magento\Customer\Block\Adminhtml\Edit\Form $form, + \Magento\Backend\Block\Widget\Context $context, + \Magento\Framework\Registry $registry + ) { + parent::__construct($context, $registry); + $this->form = $form; + $this->decoder = $decoder; + } + /** * @return array */ @@ -32,6 +52,12 @@ public function getButtonData() */ public function getBackUrl() { + if ($fromPath=$this->decoder->decode($this->form->getRequest()->getParam('fromPath'))) { + return $this->getUrl( + $fromPath, + ['id' => $this->form->getRequest()->getParam('review_id')] + ); + } return $this->getUrl('*/*/'); } } From 206335fd0c13f23ecbd3acb1c5bdb316933e177a Mon Sep 17 00:00:00 2001 From: Yash Bhayani <72012678+Yash-Bhayani@users.noreply.github.com> Date: Sat, 10 Oct 2020 17:13:37 +0530 Subject: [PATCH 2/4] Update Form.php --- .../Review/Block/Adminhtml/Edit/Form.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php index 346d5b60aad1b..65e5c66d5c1ab 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php @@ -36,6 +36,10 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @var \Magento\Store\Model\System\Store */ protected $_systemStore; + /** + * @var \Magento\Framework\Url\EncoderInterface + */ + private $urlEncoder; /** * @param \Magento\Backend\Block\Template\Context $context @@ -45,6 +49,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Customer\APi\CustomerRepositoryInterface $customerRepository * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Review\Helper\Data $reviewData + * @param \Magento\Framework\Url\EncoderInterface $urlEncoder * @param array $data */ public function __construct( @@ -55,13 +60,16 @@ public function __construct( \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Review\Helper\Data $reviewData, + \Magento\Framework\Url\EncoderInterface $urlEncoder, array $data = [] ) { $this->_reviewData = $reviewData; $this->customerRepository = $customerRepository; $this->_productFactory = $productFactory; $this->_systemStore = $systemStore; + $this->urlEncoder = $urlEncoder; parent::__construct($context, $registry, $formFactory, $data); + } /** @@ -120,10 +128,19 @@ protected function _prepareForm() ); try { + $fromPath=$this->urlEncoder->encode('review/product/edit'); $customer = $this->customerRepository->getById($review->getCustomerId()); $customerText = __( '%2 %3 (%4)', - $this->getUrl('customer/index/edit', ['id' => $customer->getId(), 'active_tab' => 'review']), + $this->getUrl( + 'customer/index/edit', + [ + 'id' => $customer->getId(), + 'active_tab' => 'review', + 'fromPath' => $fromPath, + 'review_id' => $this->getRequest()->getParam('id') + ] + ), $this->escapeHtml($customer->getFirstname()), $this->escapeHtml($customer->getLastname()), $this->escapeHtml($customer->getEmail()) From 0a81ed8eec87720c5abff9feb1b1c00b7c6bfab0 Mon Sep 17 00:00:00 2001 From: Yash Bhayani <72012678+Yash-Bhayani@users.noreply.github.com> Date: Sat, 10 Oct 2020 20:00:18 +0530 Subject: [PATCH 3/4] Update Form.php --- app/code/Magento/Review/Block/Adminhtml/Edit/Form.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php index 65e5c66d5c1ab..b2d5372b02ee4 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php @@ -69,7 +69,6 @@ public function __construct( $this->_systemStore = $systemStore; $this->urlEncoder = $urlEncoder; parent::__construct($context, $registry, $formFactory, $data); - } /** From 2ded1c1df1069d4a864800d2df28656d9f86af4d Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Mon, 18 Jan 2021 17:58:30 +0200 Subject: [PATCH 4/4] magento/magento2#30436: Fix For Issue:Incorrect redirect navigate on the review edit page. --- ...nOpenCustomerPageFromReviewActionGroup.xml | 20 ++++++ .../Test/Mftf/Page/AdminEditReviewPage.xml | 14 ++++ .../Section/AdminReviewDetailsSection.xml | 15 +++++ .../Test/AdminReviewCorrectBackButtonTest.xml | 66 +++++++++++++++++++ .../AdminClickBackButtonActionGroup.xml | 23 +++++++ 5 files changed, 138 insertions(+) create mode 100644 app/code/Magento/Review/Test/Mftf/ActionGroup/AdminOpenCustomerPageFromReviewActionGroup.xml create mode 100644 app/code/Magento/Review/Test/Mftf/Page/AdminEditReviewPage.xml create mode 100644 app/code/Magento/Review/Test/Mftf/Section/AdminReviewDetailsSection.xml create mode 100644 app/code/Magento/Review/Test/Mftf/Test/AdminReviewCorrectBackButtonTest.xml create mode 100644 app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickBackButtonActionGroup.xml diff --git a/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminOpenCustomerPageFromReviewActionGroup.xml b/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminOpenCustomerPageFromReviewActionGroup.xml new file mode 100644 index 0000000000000..c352221bedc79 --- /dev/null +++ b/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminOpenCustomerPageFromReviewActionGroup.xml @@ -0,0 +1,20 @@ + + + + + + Open Customer Page of Review author. + + + + + + + + diff --git a/app/code/Magento/Review/Test/Mftf/Page/AdminEditReviewPage.xml b/app/code/Magento/Review/Test/Mftf/Page/AdminEditReviewPage.xml new file mode 100644 index 0000000000000..324377b95927e --- /dev/null +++ b/app/code/Magento/Review/Test/Mftf/Page/AdminEditReviewPage.xml @@ -0,0 +1,14 @@ + + + + + +
+ + diff --git a/app/code/Magento/Review/Test/Mftf/Section/AdminReviewDetailsSection.xml b/app/code/Magento/Review/Test/Mftf/Section/AdminReviewDetailsSection.xml new file mode 100644 index 0000000000000..2a5f8d76d9246 --- /dev/null +++ b/app/code/Magento/Review/Test/Mftf/Section/AdminReviewDetailsSection.xml @@ -0,0 +1,15 @@ + + + + +
+ + +
+
diff --git a/app/code/Magento/Review/Test/Mftf/Test/AdminReviewCorrectBackButtonTest.xml b/app/code/Magento/Review/Test/Mftf/Test/AdminReviewCorrectBackButtonTest.xml new file mode 100644 index 0000000000000..065fbb12f265d --- /dev/null +++ b/app/code/Magento/Review/Test/Mftf/Test/AdminReviewCorrectBackButtonTest.xml @@ -0,0 +1,66 @@ + + + + + + + + + + <description value="Verify 'Back' button redirects on correct page if Customer page opened from Review page."/> + <severity value="MAJOR"/> + <testCaseId value="MC-36271"/> + </annotations> + <before> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> + </before> + <after> + <actionGroup ref="AdminOpenReviewsPageActionGroup" stepKey="openAllReviewsPage"/> + <actionGroup ref="AdminDeleteReviewsByUserNicknameActionGroup" stepKey="deleteCustomerReview"/> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearNickNameReviewFilters"/> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + <!-- Create Review on Storefront --> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="storefrontCustomerLogin"> + <argument name="Customer" value="$$createCustomer$$"/> + </actionGroup> + <actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openStorefrontProductPage"> + <argument name="productUrl" value="$$createProduct.custom_attributes[url_key]$$"/> + </actionGroup> + <actionGroup ref="StorefrontAddProductReviewActionGroup" stepKey="addReview"/> + + <!-- Grab Review's id --> + <actionGroup ref="AdminOpenPendingReviewsPageActionGroup" stepKey="openReviewsPage"/> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilters"/> + <actionGroup ref="AdminOpenReviewByUserNicknameActionGroup" stepKey="openFirstCustomerReviews"/> + <grabFromCurrentUrl regex="~/id/(\d+)/~" stepKey="grabReviewId"/> + + <!-- Check if "Back" button works correctly if Customer page opened from Review page --> + <actionGroup ref="AdminOpenCustomerPageFromReviewActionGroup" stepKey="openCustomerPageFromReview"/> + <actionGroup ref="AdminClickBackButtonActionGroup" stepKey="clickBackToEditReviewPage"> + <argument name="expectedPageUrl" value="{{AdminEditReviewPage.url('$grabReviewId')}}"/> + </actionGroup> + + <!-- Check if "Back" button works correctly if Customer page opened not from Review page --> + <actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="openCustomerEditPage"> + <argument name="customerId" value="$$createCustomer.id$$"/> + </actionGroup> + <actionGroup ref="AdminClickBackButtonActionGroup" stepKey="clickBackToCustomerIndexPage"> + <argument name="expectedPageUrl" value="{{AdminCustomerPage.url}}"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickBackButtonActionGroup.xml b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickBackButtonActionGroup.xml new file mode 100644 index 0000000000000..d5416bf94cf3d --- /dev/null +++ b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickBackButtonActionGroup.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminClickBackButtonActionGroup"> + <annotations> + <description>Click on 'Back' button. Validate correct page opened.</description> + </annotations> + <arguments> + <argument name="expectedPageUrl" type="string"/> + </arguments> + + <click selector="{{AdminGridMainControls.back}}" stepKey="clickBackButton"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <seeInCurrentUrl url="{{expectedPageUrl}}" stepKey="assertOnExpectedPage"/> + </actionGroup> +</actionGroups>