mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Enable and fix behat scenarios
This commit is contained in:
parent
75fa6a25b4
commit
5625cf5968
5 changed files with 28 additions and 16 deletions
|
|
@ -8,7 +8,7 @@ Feature: Adding product review as a customer
|
|||
Given the store operates on a single channel in "United States"
|
||||
And the store has a product "Necronomicon"
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Adding product reviews as a logged in customer
|
||||
Given I am a logged in customer
|
||||
When I want to review product "Necronomicon"
|
||||
|
|
@ -18,7 +18,7 @@ Feature: Adding product review as a customer
|
|||
Then I should be notified that my review is waiting for the acceptation
|
||||
And the "Scary but astonishing" product review of "Necronomicon" product should not be visible for customers
|
||||
|
||||
@no-api @todo-ui
|
||||
@no-api @ui @javascript
|
||||
Scenario: Adding product reviews as a logged in customer with remember me option
|
||||
Given I am a logged in customer by using remember me option
|
||||
When I want to review product "Necronomicon"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Feature: Adding product review as a guest
|
|||
Given the store operates on a single channel in "United States"
|
||||
And the store has a product "Necronomicon"
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Adding product reviews as a guest
|
||||
When I want to review product "Necronomicon"
|
||||
And I leave a comment "I'm never gonna read this terrible book again.", titled "Never again" as "castiel@heaven.com"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Feature: Product review validation
|
|||
Given the store operates on a single channel in "United States"
|
||||
And the store has a product "Necronomicon"
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Trying to add a product review without specifying a rate
|
||||
When I want to review product "Necronomicon"
|
||||
And I leave a comment "This book made me sad, but plot was fine.", titled "Not good, not bad" as "bartholomew@heaven.com"
|
||||
|
|
@ -16,7 +16,7 @@ Feature: Product review validation
|
|||
And I try to add it
|
||||
Then I should be notified that I must check review rating
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Trying to add a product review without specifying a title
|
||||
When I want to review product "Necronomicon"
|
||||
And I leave a comment "This book made me sad, but plot was fine." as "bartholomew@heaven.com"
|
||||
|
|
@ -24,7 +24,7 @@ Feature: Product review validation
|
|||
And I try to add it
|
||||
Then I should be notified that title is required
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Trying to add a product review with too short title
|
||||
When I want to review product "Necronomicon"
|
||||
And I leave a comment "This book made me sad, but plot was fine.", titled "X" as "bartholomew@heaven.com"
|
||||
|
|
@ -32,7 +32,7 @@ Feature: Product review validation
|
|||
And I try to add it
|
||||
Then I should be notified that title must have at least 2 characters
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Trying to add a product review with too long title
|
||||
When I want to review product "Necronomicon"
|
||||
And I leave a comment "This book made me sad, but plot was fine." as "bartholomew@heaven.com"
|
||||
|
|
@ -41,7 +41,7 @@ Feature: Product review validation
|
|||
And I try to add it
|
||||
Then I should be notified that title must have at most 255 characters
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Trying to add a product review without specifying a comment
|
||||
When I want to review product "Necronomicon"
|
||||
And I leave a review titled "Not good, not bad" as "bartholomew@heaven.com"
|
||||
|
|
@ -49,7 +49,7 @@ Feature: Product review validation
|
|||
And I try to add it
|
||||
Then I should be notified that comment is required
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Trying to add a product review without specifying an author email
|
||||
When I want to review product "Necronomicon"
|
||||
And I leave a comment "Not good, not bad", titled "Not good, not bad"
|
||||
|
|
@ -57,7 +57,7 @@ Feature: Product review validation
|
|||
And I try to add it
|
||||
Then I should be notified that I must enter my email
|
||||
|
||||
@api @todo-ui
|
||||
@api @ui @javascript
|
||||
Scenario: Trying to add a product review with specifying already registered author email
|
||||
Given there is a customer account "sam@winchester.com" identified by "familybusiness"
|
||||
When I want to review product "Necronomicon"
|
||||
|
|
@ -66,7 +66,7 @@ Feature: Product review validation
|
|||
And I try to add it
|
||||
Then I should be notified that this email is already registered
|
||||
|
||||
@api
|
||||
@api @no-ui
|
||||
Scenario: Trying to add a product review with an out-of-range rate
|
||||
When I want to review product "Necronomicon"
|
||||
And I leave a comment "This book made me sad, but plot was fine.", titled "Not good, not bad" as "example@example.com"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Sylius\Behat\Page\Shop\ProductReview;
|
||||
|
||||
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage;
|
||||
use Sylius\Behat\Service\DriverHelper;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
class CreatePage extends SymfonyPage implements CreatePageInterface
|
||||
|
|
@ -25,26 +26,31 @@ class CreatePage extends SymfonyPage implements CreatePageInterface
|
|||
|
||||
public function titleReview(?string $title): void
|
||||
{
|
||||
$this->waitForElementToBeReady();
|
||||
$this->getElement('title')->setValue($title);
|
||||
}
|
||||
|
||||
public function setComment(?string $comment): void
|
||||
{
|
||||
$this->waitForElementToBeReady();
|
||||
$this->getElement('comment')->setValue($comment);
|
||||
}
|
||||
|
||||
public function setAuthor(string $author): void
|
||||
{
|
||||
$this->waitForElementToBeReady();
|
||||
$this->getElement('author')->setValue($author);
|
||||
}
|
||||
|
||||
public function rateReview(int $rate): void
|
||||
{
|
||||
$this->getElement('rating_option')->selectOption($rate);
|
||||
$this->waitForElementToBeReady();
|
||||
$this->getElement('rating_option', ['%value%' => $rate])->getParent()->click();
|
||||
}
|
||||
|
||||
public function submitReview(): void
|
||||
{
|
||||
$this->waitForElementToBeReady();
|
||||
$this->getElement('add')->press();
|
||||
}
|
||||
|
||||
|
|
@ -75,8 +81,7 @@ class CreatePage extends SymfonyPage implements CreatePageInterface
|
|||
'author' => '[data-test-author-email]',
|
||||
'comment' => '[data-test-comment]',
|
||||
'rating' => '[data-test-rating]',
|
||||
'rating_error' => '[data-test-rating] [data-test-validation-error]',
|
||||
'rating_option' => '[data-test-rating] [data-test-option]',
|
||||
'rating_option' => '[data-test-rating-option="%value%"]',
|
||||
'title' => '[data-test-title]',
|
||||
]);
|
||||
}
|
||||
|
|
@ -88,4 +93,11 @@ class CreatePage extends SymfonyPage implements CreatePageInterface
|
|||
|
||||
return $errorElement->getText();
|
||||
}
|
||||
|
||||
private function waitForElementToBeReady(): void
|
||||
{
|
||||
if (DriverHelper::isJavascript($this->getDriver())) {
|
||||
$this->getDocument()->waitFor(1, fn (): bool => $this->isOpen());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,10 +54,10 @@
|
|||
{% block _sylius_shop_product_review_rating_widget %}
|
||||
{% from '@SyliusAdmin/shared/helper/icon.html.twig' import icon %}
|
||||
|
||||
<div class="sylius-rating">
|
||||
<div class="sylius-rating" {{ sylius_test_html_attribute('rating') }}>
|
||||
{% for entry in form.children %}
|
||||
<label>
|
||||
<input type="radio" value="{{ entry.vars.value }}" id="{{ entry.vars.id }}" name="{{ entry.vars.full_name }}" {{ sylius_test_html_attribute('rating', entry.vars.value) }} {{ entry.vars.checked ? 'checked' }}>
|
||||
<input type="radio" value="{{ entry.vars.value }}" id="{{ entry.vars.id }}" name="{{ entry.vars.full_name }}" {{ sylius_test_html_attribute('rating-option', entry.vars.value) }} {{ entry.vars.checked ? 'checked' }}>
|
||||
{{ icon({ icon: 'star' }) }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue