Skip to content

Commit 245bce8

Browse files
committed
Merge remote-tracking branch 'somat-211/issue-30196' into ACP2E-89
# Conflicts: # app/code/Magento/Review/view/frontend/templates/customer/list.phtml # app/code/Magento/Review/view/frontend/templates/customer/recent.phtml # app/code/Magento/Review/view/frontend/templates/customer/view.phtml
2 parents 49c88a3 + 74c6793 commit 245bce8

File tree

3 files changed

+155
-4
lines changed

3 files changed

+155
-4
lines changed
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontSetProductRatingStarsActionGroup">
11+
<arguments>
12+
<argument name="ratingName" type="string"/>
13+
<argument name="stars" type="string"/>
14+
</arguments>
15+
<waitForElementVisible selector="#{{ratingName}}_{{stars}}_label" stepKey="waitForStarElement"/>
16+
<executeJS function="jQuery('#{{ratingName}}_{{stars}}_label').click()" stepKey="clickStar"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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="StoreFrontReviewRatingByCustomerTest">
12+
<annotations>
13+
<features value="Review"/>
14+
<stories value="Review By Customers"/>
15+
<title value="StoreFront Review Rating By Customers"/>
16+
<description value="Check if product rating is the same at list, table view on PLP and customers account."/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value=""/>
19+
</annotations>
20+
<before>
21+
<!-- Enable singe store view to view ratings-->
22+
<magentoCLI command="config:set general/single_store_mode/enabled 1" stepKey="enabledSingleStoreMode"/>
23+
<!--Login-->
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
25+
<!--Create product and Category-->
26+
<createData stepKey="category" entity="SimpleSubCategory"/>
27+
<createData stepKey="createProduct1" entity="SimpleProduct">
28+
<requiredEntity createDataKey="category"/>
29+
</createData>
30+
<createData stepKey="createProduct2" entity="SimpleProduct">
31+
<requiredEntity createDataKey="category"/>
32+
</createData>
33+
</before>
34+
<after>
35+
<!-- Delete reviews -->
36+
<actionGroup ref="AdminOpenReviewsPageActionGroup" stepKey="openAllReviewsPage"/>
37+
<actionGroup ref="AdminDeleteReviewsByUserNicknameActionGroup" stepKey="deleteCustomerReview"/>
38+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearNickNameReviewFilters"/>
39+
<!-- Delete customer -->
40+
<actionGroup ref="AdminDeleteCustomerActionGroup" stepKey="deleteCustomer">
41+
<argument name="customerEmail" value="CustomerEntityOne.email"/>
42+
</actionGroup>
43+
<!--delete Category and Products -->
44+
<deleteData createDataKey="createProduct1" stepKey="deleteProduct1"/>
45+
<deleteData createDataKey="createProduct2" stepKey="deleteProduct2"/>
46+
<deleteData createDataKey="category" stepKey="deleteCategory"/>
47+
<!--Logout-->
48+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
49+
<!-- Disable single store view back-->
50+
<magentoCLI command="config:set general/single_store_mode/enabled 0" stepKey="enabledSingleStoreMode"/>
51+
</after>
52+
<!-- Go to frontend and make a user account and login with it -->
53+
<actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="signUpNewUser">
54+
<argument name="Customer" value="CustomerEntityOne"/>
55+
</actionGroup>
56+
<!-- Go to the product view page -->
57+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openStorefrontProductPage">
58+
<argument name="productUrl" value="$$createProduct1.custom_attributes[url_key]$$"/>
59+
</actionGroup>
60+
<!-- Click on reviews and add reviews with current user -->
61+
<click selector="{{StorefrontProductReviewsSection.reviewsTab}}" stepKey="openReviewTab"/>
62+
<!-- set product rating stars -->
63+
<actionGroup ref="StorefrontSetProductRatingStarsActionGroup" stepKey="setQualityStars">
64+
<argument name="ratingName" value="Quality"/>
65+
<argument name="stars" value="3"/>
66+
</actionGroup>
67+
<actionGroup ref="StorefrontSetProductRatingStarsActionGroup" stepKey="setValueStars">
68+
<argument name="ratingName" value="Value"/>
69+
<argument name="stars" value="4"/>
70+
</actionGroup>
71+
<actionGroup ref="StorefrontSetProductRatingStarsActionGroup" stepKey="setPriceStars">
72+
<argument name="ratingName" value="Price"/>
73+
<argument name="stars" value="5"/>
74+
</actionGroup>
75+
<!-- Click on reviews and add reviews with current user -->
76+
<actionGroup ref="StorefrontAddProductReviewActionGroup" stepKey="addReview"/>
77+
<!-- Go to Pending reviews page and clear filters -->
78+
<actionGroup ref="AdminOpenPendingReviewsPageActionGroup" stepKey="openReviewsPage"/>
79+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilters"/>
80+
<!-- Moderate first product reviews: change review status from pending to approved, save -->
81+
<actionGroup ref="AdminOpenReviewByUserNicknameActionGroup" stepKey="openFirstCustomerReviews"/>
82+
<actionGroup ref="AdminChangeReviewStatusActionGroup" stepKey="changeFirstReviewStatus"/>
83+
<actionGroup ref="AdminSaveReviewActionGroup" stepKey="saveModeratedFirstReview"/>
84+
<!-- Navigate to PLP and check product rating for list and table views -->
85+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="amOnStoreViewHomePage"/>
86+
<actionGroup ref="StoreFrontQuickSearchActionGroup" stepKey="searchBySku">
87+
<argument name="query" value="$$createProduct1.sku$$"/>
88+
</actionGroup>
89+
<!-- Check stars at list view -->
90+
<click selector="{{StorefrontCategoryTopToolbarSection.listMode}}" stepKey="switchCategoryViewToListMode"/>
91+
<grabAttributeFrom selector="#rating-result_$$createProduct1.id$$ span" userInput="style" stepKey="getProductStarsAtListView"/>
92+
<assertEquals stepKey="checkProductStarsAtListView">
93+
<actualResult type="string">$getProductStarsAtListView</actualResult>
94+
<expectedResult type="string">width: 80%;</expectedResult>
95+
</assertEquals>
96+
<!-- Check stars at grid view -->
97+
<click selector="{{StorefrontCategoryTopToolbarSection.gridMode}}" stepKey="switchCategoryViewToGridMode"/>
98+
<grabAttributeFrom selector="#rating-result_$$createProduct1.id$$ span" userInput="style" stepKey="getProductStarsAtGridView"/>
99+
<assertEquals stepKey="checkProductStarsAtGridView">
100+
<actualResult type="string">$getProductStarsAtGridView</actualResult>
101+
<expectedResult type="string">width: 80%;</expectedResult>
102+
</assertEquals>
103+
<!-- Navigate to user account and check product ratings-->
104+
<amOnPage url="review/customer/" stepKey="amOnCustomerReviewPage"/>
105+
<click selector=".action.more" stepKey="amOnProductReviewDetailsPage"/>
106+
<!-- Check stars at rating result under the product name -->
107+
<grabAttributeFrom selector="#rating-result_$$createProduct1.id$$ span" userInput="style" stepKey="getProductResultStarsUnderProductName"/>
108+
<assertEquals stepKey="checkProductResultStarsUnderProductName">
109+
<actualResult type="string">$getProductResultStarsUnderProductName</actualResult>
110+
<expectedResult type="string">width: 80%;</expectedResult>
111+
</assertEquals>
112+
<!-- Check that the rating are accurate-->
113+
<grabAttributeFrom selector=".rating-result.Quality span" userInput="style" stepKey="getProductQualityStarsAtUserAccount"/>
114+
<assertEquals stepKey="checkProductQualityStarsAtUserAccount">
115+
<actualResult type="string">$getProductQualityStarsAtUserAccount</actualResult>
116+
<expectedResult type="string">width: 60%;</expectedResult>
117+
</assertEquals>
118+
<grabAttributeFrom selector=".rating-result.Value span" userInput="style" stepKey="getProductValueStarsAtUserAccount"/>
119+
<assertEquals stepKey="checkProductValueStarsAtUserAccount">
120+
<actualResult type="string">$getProductValueStarsAtUserAccount</actualResult>
121+
<expectedResult type="string">width: 80%;</expectedResult>
122+
</assertEquals>
123+
<grabAttributeFrom selector=".rating-result.Price span" userInput="style" stepKey="getProductPriceStarsAtUserAccount"/>
124+
<assertEquals stepKey="checkProductPriceStarsAtUserAccount">
125+
<actualResult type="string">$getProductPriceStarsAtUserAccount</actualResult>
126+
<expectedResult type="string">width: 100%;</expectedResult>
127+
</assertEquals>
128+
</test>
129+
</tests>

app/code/Magento/Review/view/frontend/templates/helper/summary.phtml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ $urlForm = $block->getReviewsUrl() . '#review-form';
1919
<?php if ($rating):?>
2020
<div class="rating-summary">
2121
<span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
22-
<div class="rating-result" title="<?= $block->escapeHtmlAttr($rating); ?>%">
22+
<div class="rating-result"
23+
id="rating-result_<?= /* @noEscape */ $block->getProduct()->getId() ?>"
24+
title="<?= $block->escapeHtmlAttr($rating) ?>%"
25+
>
2326
<span>
2427
<span>
2528
<span itemprop="ratingValue"><?= $block->escapeHtml($rating); ?>
@@ -28,9 +31,10 @@ $urlForm = $block->getReviewsUrl() . '#review-form';
2831
</span>
2932
</div>
3033
</div>
31-
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
32-
"width:" . $block->escapeHtmlAttr($rating) . "%",
33-
'div.rating-summary div.rating-result>span:first-child'
34+
<?= /* @noEscape */
35+
$secureRenderer->renderStyleAsTag(
36+
'width:' . $block->escapeHtmlAttr($rating) . '%',
37+
'#rating-result_' . $block->getProduct()->getId() . ' span'
3438
) ?>
3539
<?php endif;?>
3640
<div class="reviews-actions">

0 commit comments

Comments
 (0)