mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Merge pull request #6593 from Zales0123/recalculating-product-average-rating-after-rate-change-in-admin-panel
[Behat][ProductReview] Recalculate average rating after review rate change
This commit is contained in:
commit
fbf0a5bd52
7 changed files with 44 additions and 9 deletions
|
|
@ -14,6 +14,6 @@ Feature: Browsing product reviews
|
|||
@ui
|
||||
Scenario: Browsing all product reviews in store
|
||||
When I want to browse product reviews
|
||||
Then I should see 2 product reviews in the list
|
||||
Then I should see 2 reviews in the list
|
||||
And I should see the product review "Awesome" in the list
|
||||
And I should also see the product review "Bad" in the list
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Feature: Editing product reviews
|
|||
@ui
|
||||
Scenario: Seeing a product's name while editing a product review
|
||||
When I want to modify the "Awesome" product review
|
||||
Then I should see the product "Lamborghini Gallardo Model"
|
||||
Then I should be editing review of product "Lamborghini Gallardo Model"
|
||||
|
||||
@ui
|
||||
Scenario: Seeing a customer's name while editing a product review
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
@managing_product_reviews
|
||||
Feature: Recalculating product average rating
|
||||
In order to have my product's average rating properly calculated
|
||||
As an Administrator
|
||||
I want to have product's average rating recalculated after review rate change
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And the store has a product "Lamborghini Gallardo Model"
|
||||
And this product has a review titled "Awesome" and rated 4 with a comment "Nice product" added by customer "ross@teammike.com"
|
||||
And this product has a review titled "Not bad" and rated 3 with a comment "Not bad car" added by customer "specter@teamharvey.com"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Product's average rating is correctly recalculated after review's rate change
|
||||
When I want to modify the "Awesome" product review
|
||||
And I choose 5 as its rating
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And average rating of product "Lamborghini Gallardo Model" should be 4
|
||||
|
|
@ -74,9 +74,9 @@ final class ManagingProductReviewsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :amount product reviews in the list
|
||||
* @Then I should see :amount reviews in the list
|
||||
*/
|
||||
public function iShouldSeeProductReviewsInTheList($amount)
|
||||
public function iShouldSeeReviewsInTheList($amount)
|
||||
{
|
||||
Assert::same(
|
||||
(int) $amount,
|
||||
|
|
@ -149,9 +149,9 @@ final class ManagingProductReviewsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should see the product :productName
|
||||
* @Then I should be editing review of product :productName
|
||||
*/
|
||||
public function iShouldSeeTheProduct($productName)
|
||||
public function iShouldBeEditingReviewOfProduct($productName)
|
||||
{
|
||||
Assert::same(
|
||||
$productName,
|
||||
|
|
|
|||
|
|
@ -382,9 +382,9 @@ final class ProductContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :count product reviews in the list
|
||||
* @Then /^I should see (\d+) product reviews in the list$/
|
||||
*/
|
||||
public function iShouldSeeProductReviewsInTheList($count)
|
||||
public function iShouldSeeNumberOfProductReviewsInTheList($count)
|
||||
{
|
||||
Assert::same(
|
||||
(int) $count,
|
||||
|
|
@ -420,9 +420,11 @@ final class ProductContext implements Context
|
|||
*/
|
||||
public function iShouldSeeAsItsAverageRating($rating)
|
||||
{
|
||||
$averageRating = $this->showPage->getAverageRating();
|
||||
|
||||
Assert::same(
|
||||
(float) $rating,
|
||||
$this->showPage->getAverageRating(),
|
||||
$averageRating,
|
||||
'Product should have average rating %2$s but has %s.'
|
||||
);
|
||||
}
|
||||
|
|
@ -459,4 +461,13 @@ final class ProductContext implements Context
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^average rating of (product "[^"]+") should be (\d+)$/
|
||||
*/
|
||||
public function thisProductAverageRatingShouldBe(ProductInterface $product, $averageRating)
|
||||
{
|
||||
$this->showPage->tryToOpen(['slug' => $product->getSlug()]);
|
||||
$this->iShouldSeeAsItsAverageRating($averageRating);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,15 +9,18 @@ default:
|
|||
|
||||
- sylius.behat.context.transform.lexical
|
||||
- sylius.behat.context.transform.customer
|
||||
- sylius.behat.context.transform.product
|
||||
- sylius.behat.context.transform.product_review
|
||||
- sylius.behat.context.transform.shared_storage
|
||||
|
||||
- sylius.behat.context.setup.admin_security
|
||||
- sylius.behat.context.setup.channel
|
||||
- sylius.behat.context.setup.customer
|
||||
- sylius.behat.context.setup.product
|
||||
- sylius.behat.context.setup.product_review
|
||||
|
||||
- sylius.behat.context.ui.admin.managing_product_reviews
|
||||
- sylius.behat.context.ui.admin.notification
|
||||
- sylius.behat.context.ui.shop.product
|
||||
filters:
|
||||
tags: "@managing_product_reviews && @ui"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
</service>
|
||||
<service id="sylius.listener.review_change" class="Sylius\Bundle\ReviewBundle\EventListener\ReviewChangeListener">
|
||||
<argument type="service" id="sylius.average_rating_updater" />
|
||||
<tag name="kernel.event_listener" event="sylius.product_review.post_update" method="recalculateSubjectRating" />
|
||||
<tag name="kernel.event_listener" event="sylius.product_review.post_delete" method="recalculateSubjectRating" />
|
||||
</service>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue