mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Promotion] Review fixes
This commit is contained in:
parent
c7bce5c9b3
commit
3ea281c958
8 changed files with 69 additions and 30 deletions
|
|
@ -14,7 +14,7 @@ Feature: Adding promotion with filter
|
|||
When I specify its code as "10_for_all_products_over_10"
|
||||
And I name it "$10 discount for all products over $10!"
|
||||
And I add the "Item fixed discount" action configured with amount of "$10"
|
||||
And I specify that this filter should be applied for amount greater then "$10"
|
||||
And I specify that this action should be applied to items with price greater then "$10"
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
And the "$10 discount for all products over $10!" promotion should appear in the registry
|
||||
|
|
@ -25,7 +25,7 @@ Feature: Adding promotion with filter
|
|||
When I specify its code as "10_for_all_products_over_10"
|
||||
And I name it "$10 discount for (almost) all products!"
|
||||
And I add the "Item fixed discount" action configured with amount of "$10"
|
||||
And I specify that this filter should be applied for amount greater then "$10" but lesser then "$100"
|
||||
And I specify that this action should be applied to items with price between "$10" and "$100"
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
And the "$10 discount for (almost) all products!" promotion should appear in the registry
|
||||
|
|
@ -36,7 +36,7 @@ Feature: Adding promotion with filter
|
|||
When I specify its code as "10_for_all_products_over_10"
|
||||
And I name it "$10 discount for all products over $10!"
|
||||
And I add the "Item percentage discount" action configured with a percentage value of 10%
|
||||
And I specify that this filter should be applied for amount greater then "$10"
|
||||
And I specify that this action should be applied to items with price greater then "$10"
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
And the "$10 discount for all products over $10!" promotion should appear in the registry
|
||||
|
|
@ -47,7 +47,7 @@ Feature: Adding promotion with filter
|
|||
When I specify its code as "10_for_all_products_over_10"
|
||||
And I name it "$10 discount for (almost) all products!"
|
||||
And I add the "Item percentage discount" action configured with a percentage value of 10%
|
||||
And I specify that this filter should be applied for amount greater then "$10" but lesser then "$100"
|
||||
And I specify that this action should be applied to items with price between "$10" and "$100"
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
And the "$10 discount for (almost) all products!" promotion should appear in the registry
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
@managing_promotions
|
||||
Feature: Promotion filters validation
|
||||
In order to avoid making mistakes when managing a promotion with filters
|
||||
As an Administrator
|
||||
I want to be prevented from defining filters without specifying required fields
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Adding a promotion with wrong minimum price on price range filter
|
||||
Given I want to create a new promotion
|
||||
When I specify its code as "10_for_all_products_over_10"
|
||||
And I name it "$10 discount for all products over $10!"
|
||||
And I add the "Item percentage discount" action configured with a percentage value of 10%
|
||||
And I specify that this action should be applied to items with price greater then "$asdasd"
|
||||
And I try to add it
|
||||
Then I should be notified that a minimum value should be a numeric value
|
||||
And promotion with name "$10 discount for all products over $10!" should not be added
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Adding a promotion with wrong maximum price on price range filter
|
||||
Given I want to create a new promotion
|
||||
When I specify its code as "10_for_all_products_over_10"
|
||||
And I name it "$10 discount for (almost) all products!"
|
||||
And I add the "Item percentage discount" action configured with a percentage value of 10%
|
||||
And I specify that this action should be applied to items with price lesser then "$asdasda"
|
||||
And I try to add it
|
||||
Then I should be notified that a maximum value should be a numeric value
|
||||
And promotion with name "$10 discount for (almost) all products!" should not be added
|
||||
|
|
@ -177,7 +177,7 @@ final class ManagingPromotionsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Given /^I add the "([^"]+)" action configured with amount of ("(?:€|£|\$)[^"]+")$/
|
||||
* @Given /^I add the "([^"]+)" action configured with amount of "(?:€|£|\$)([^"]+)"$/
|
||||
*/
|
||||
public function iAddTheActionConfiguredWithAmount($actionType, $amount)
|
||||
{
|
||||
|
|
@ -186,7 +186,7 @@ final class ManagingPromotionsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @When /^I specify that this filter should be applied for amount greater then ("(?:€|£|\$)[^"]+")$/
|
||||
* @When /^I specify that this action should be applied to items with price greater then "(?:€|£|\$)([^"]+)"$/
|
||||
*/
|
||||
public function iAddAMinPriceFilterRange($minimum)
|
||||
{
|
||||
|
|
@ -194,13 +194,20 @@ final class ManagingPromotionsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @When /^I specify that this filter should be applied for amount greater then ("(?:€|£|\$)[^"]+") but lesser then ("(?:€|£|\$)[^"]+")$/
|
||||
* @When /^I specify that this action should be applied to items with price lesser then "(?:€|£|\$)([^"]+)"$/
|
||||
*/
|
||||
public function iAddAMaxPriceFilterRange($maximum)
|
||||
{
|
||||
$this->createPage->fillActionOption('Max', $maximum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I specify that this action should be applied to items with price between "(?:€|£|\$)([^"]+)" and "(?:€|£|\$)([^"]+)"$/
|
||||
*/
|
||||
public function iAddAMinMaxPriceFilterRange($minimum, $maximum)
|
||||
{
|
||||
$this->iAddAMinPriceFilterRange($minimum);
|
||||
|
||||
$this->createPage->fillActionOption('Max', $maximum);
|
||||
$this->iAddAMaxPriceFilterRange($maximum);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -255,6 +262,14 @@ final class ManagingPromotionsContext implements Context
|
|||
$this->assertFieldValidationMessage($element, sprintf('Please enter promotion %s.', $element));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that a :element value should be a numeric value
|
||||
*/
|
||||
public function iShouldBeNotifiedThatAMinimalValueShouldBeNumeric($element)
|
||||
{
|
||||
$this->assertFieldValidationMessage($element, 'This value is not valid.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that promotion with this code already exists
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -148,6 +148,8 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
'actions' => '#sylius_promotion_actions',
|
||||
'code' => '#sylius_promotion_code',
|
||||
'ends_at' => '#sylius_promotion_endsAt',
|
||||
'minimum' => '#sylius_promotion_actions_0_configuration_filters_price_range_min',
|
||||
'maximum' => '#sylius_promotion_actions_0_configuration_filters_price_range_max',
|
||||
'name' => '#sylius_promotion_name',
|
||||
'rules' => '#sylius_promotion_rules',
|
||||
'starts_at' => '#sylius_promotion_startsAt',
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ use Symfony\Component\Validator\Constraints\Type;
|
|||
class UnitFixedDiscountConfigurationType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
|
@ -37,12 +36,12 @@ class UnitFixedDiscountConfigurationType extends AbstractType
|
|||
new Type(['type' => 'numeric']),
|
||||
],
|
||||
])
|
||||
->add('filters', 'sylius_promotion_filters')
|
||||
->add('filters', 'sylius_promotion_filters', ['required' => false])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,13 +25,10 @@ use Symfony\Component\Validator\Constraints\Type;
|
|||
class UnitPercentageDiscountConfigurationType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('percentage', 'percent', [
|
||||
'label' => 'sylius.form.promotion_action.percentage_discount_configuration.percentage',
|
||||
|
|
@ -46,10 +43,13 @@ class UnitPercentageDiscountConfigurationType extends AbstractType
|
|||
]),
|
||||
],
|
||||
])
|
||||
->add('filters', 'sylius_promotion_filters')
|
||||
->add('filters', 'sylius_promotion_filters', ['required' => false])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_promotion_action_unit_percentage_discount_configuration';
|
||||
|
|
|
|||
|
|
@ -23,21 +23,13 @@ use Symfony\Component\Validator\Constraints\Type;
|
|||
class PriceRangeFilterConfigurationType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('min', 'sylius_money', [
|
||||
'constraints' => [
|
||||
new Type(['type' => 'numeric']),
|
||||
],
|
||||
])->add('max', 'sylius_money', [
|
||||
'constraints' => [
|
||||
new Type(['type' => 'numeric']),
|
||||
],
|
||||
])
|
||||
->add('min', 'sylius_money', ['required' => false, 'constraints' => [new Type(['type' => 'numeric'])]])
|
||||
->add('max', 'sylius_money', ['required' => false, 'constraints' => [new Type(['type' => 'numeric'])]])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class PromotionFiltersType extends AbstractType
|
|||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('price_range', 'sylius_promotion_action_filter_price_range_configuration');
|
||||
$builder->add('price_range', 'sylius_promotion_action_filter_price_range_configuration', ['required' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue