mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Merge pull request #4774 from Zales0123/adding-promotion-with-action-feature
[Admin][Promotion] Adding promotion with action feature
This commit is contained in:
commit
87d68fcbec
7 changed files with 88 additions and 8 deletions
|
|
@ -22,6 +22,7 @@ var paths = {
|
|||
'node_modules/semantic-ui-css/semantic.min.js',
|
||||
'src/Sylius/Bundle/UiBundle/Resources/private/js/**',
|
||||
'src/Sylius/Bundle/ShippingBundle/Resources/public/js/**',
|
||||
'src/Sylius/Bundle/PromotionBundle/Resources/public/js/sylius-promotion.js'
|
||||
],
|
||||
sass: [
|
||||
'src/Sylius/Bundle/UiBundle/Resources/private/sass/**',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
@managing_promotions
|
||||
Feature: Adding a new promotion with action
|
||||
In order to give possibility to pay specifically less price for some goods
|
||||
As an Administrator
|
||||
I want to add a new promotion with action to the registry
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "France"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Adding a new promotion with fixed discount
|
||||
Given I want to create a new promotion
|
||||
When I specify its code as "10_for_all_products"
|
||||
And I name it "€10.00 for all products!"
|
||||
And I add the "Order fixed discount" action configured with €10.00
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
And the promotion "€10.00 for all products!" should appear in the registry
|
||||
|
|
@ -154,6 +154,15 @@ final class ManagingPromotionsContext implements Context
|
|||
$this->createPage->fillRuleOption('Amount', $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given I add the "Order fixed discount" action configured with €:amount
|
||||
*/
|
||||
public function stepDefinition($amount)
|
||||
{
|
||||
$this->createPage->addAction('Order fixed discount');
|
||||
$this->createPage->fillActionOption('Amount', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that it has been successfully created
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
*/
|
||||
public function selectRuleOption($option, $value, $multiple = false)
|
||||
{
|
||||
$this->getLastAddedRule()->find('named', array('select', $option))->selectOption($value, $multiple);
|
||||
$this->getLastAddedCollectionItem('rules')->find('named', array('select', $option))->selectOption($value, $multiple);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -47,7 +47,33 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
*/
|
||||
public function fillRuleOption($option, $value)
|
||||
{
|
||||
$this->getLastAddedRule()->fillField($option, $value);
|
||||
$this->getLastAddedCollectionItem('rules')->fillField($option, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addAction($actionName)
|
||||
{
|
||||
$this->getDocument()->clickLink('Add action');
|
||||
|
||||
$this->selectActionOption('Type', $actionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function selectActionOption($option, $value, $multiple = false)
|
||||
{
|
||||
$this->getLastAddedCollectionItem('actions')->find('named', array('select', $option))->selectOption($value, $multiple);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fillActionOption($option, $value)
|
||||
{
|
||||
$this->getLastAddedCollectionItem('actions')->fillField($option, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -56,6 +82,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
protected function getDefinedElements()
|
||||
{
|
||||
return [
|
||||
'actions' => '#sylius_promotion_actions',
|
||||
'code' => '#sylius_promotion_code',
|
||||
'name' => '#sylius_promotion_name',
|
||||
'rules' => '#sylius_promotion_rules',
|
||||
|
|
@ -63,11 +90,13 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @param string $collection
|
||||
*
|
||||
* @return NodeElement
|
||||
*/
|
||||
private function getLastAddedRule()
|
||||
private function getLastAddedCollectionItem($collection)
|
||||
{
|
||||
$rules = $this->getElement('rules')->findAll('css', 'div[data-form-collection="item"]');
|
||||
$rules = $this->getElement($collection)->findAll('css', 'div[data-form-collection="item"]');
|
||||
|
||||
return end($rules);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,23 @@ interface CreatePageInterface extends BaseCreatePageInterface
|
|||
* @param string $value
|
||||
*/
|
||||
public function fillRuleOption($option, $value);
|
||||
|
||||
/**
|
||||
* @param string $actionName
|
||||
*/
|
||||
public function addAction($actionName);
|
||||
|
||||
/**
|
||||
* @param string $option
|
||||
* @param string $value
|
||||
* @param bool $multiple
|
||||
*/
|
||||
public function selectActionOption($option, $value, $multiple = false);
|
||||
|
||||
/**
|
||||
* @param string $option
|
||||
* @param string $value
|
||||
*/
|
||||
public function fillActionOption($option, $value);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,14 @@
|
|||
{{ form_row(form.name) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="eight wide column">
|
||||
<div class="eight wide column" id="rules">
|
||||
<div class="field">
|
||||
{{ form_row(form.rules) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="eight wide column" id="actions">
|
||||
<div class="field">
|
||||
{{ form_row(form.actions) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ namespace Sylius\Bundle\PromotionBundle\Form\Type;
|
|||
|
||||
use Sylius\Bundle\PromotionBundle\Form\EventListener\BuildActionFormSubscriber;
|
||||
use Sylius\Bundle\PromotionBundle\Form\Type\Core\AbstractConfigurationType;
|
||||
use Sylius\Component\Promotion\Model\ActionInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @author Saša Stamenković <umpirsky@gmail.com>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue