mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Taxon][Behat] Rest of scenarios implementation
This commit is contained in:
parent
45755d0ad4
commit
435a6052be
7 changed files with 99 additions and 16 deletions
|
|
@ -13,6 +13,7 @@ Feature: Adding a new taxon
|
|||
Given I want to create a new taxon
|
||||
When I specify its code as "t-shirts"
|
||||
And I name it "T-Shirts" in "English (United States)"
|
||||
And I set its slug to "t-shirts"
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
And the "T-Shirts" taxon should appear in the registry
|
||||
|
|
@ -22,7 +23,7 @@ Feature: Adding a new taxon
|
|||
Given I want to create a new taxon
|
||||
When I specify its code as "category"
|
||||
And I name it "Category" in "English (United States)"
|
||||
And I specify its slug as "category" in "English (United States)"
|
||||
And I set its slug to "category"
|
||||
And I describe it as "Main taxonomy for products." in "English (United States)"
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Feature: Editing taxon's slug
|
|||
Given the store is available in "English (United States)"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui @javascript @todo
|
||||
@ui @javascript
|
||||
Scenario: Creating a root taxon with an autogenerated slug
|
||||
Given I want to create a new taxon
|
||||
When I specify its code as "MEDIEVAL_WEAPONS"
|
||||
|
|
@ -25,7 +25,7 @@ Feature: Editing taxon's slug
|
|||
And I add it
|
||||
Then this taxon slug should be "mw"
|
||||
|
||||
@ui @javascript @todo
|
||||
@ui @javascript
|
||||
Scenario: Creating a taxon with an autogenerated slug for parent
|
||||
Given the store has "Medieval weapons" taxonomy
|
||||
And I want to create a new taxon for "Medieval weapons"
|
||||
|
|
@ -44,37 +44,37 @@ Feature: Editing taxon's slug
|
|||
And I add it
|
||||
Then this taxon slug should be "medieval-weapons/siege"
|
||||
|
||||
@ui @todo
|
||||
@ui
|
||||
Scenario: Seeing disabled slug field when editing a taxon
|
||||
Given the store has "Medieval weapons" taxonomy
|
||||
When I want to modify this taxon
|
||||
When I want to modify the "Medieval weapons" taxon
|
||||
Then the slug field should not be editable
|
||||
|
||||
@ui @javascript @todo
|
||||
@ui @javascript
|
||||
Scenario: Prevent from editing a slug while changing a taxon name
|
||||
Given the store has "Medieval weapons" taxonomy
|
||||
When I want to modify this taxon
|
||||
When I want to modify the "Medieval weapons" taxon
|
||||
And I rename it to "Renaissance weapons" in "English (United States)"
|
||||
And I save my changes
|
||||
Then the slug of the "Renaissance weapons" taxon should still be "medieval-weapons"
|
||||
|
||||
@ui @javascript @todo
|
||||
@ui @javascript
|
||||
Scenario: Automatically changing a taxon's slug while editing a taxon's name
|
||||
Given the store has "Medieval weapons" taxonomy
|
||||
When I want to modify this taxon
|
||||
When I want to modify the "Medieval weapons" taxon
|
||||
And I enable slug modification
|
||||
And I rename it to "Renaissance weapons" in "English (United States)"
|
||||
And I save my changes
|
||||
Then the slug of the "Renaissance weapons" taxon should be "renaissance-weapons"
|
||||
|
||||
@ui @javascript @todo
|
||||
@ui @javascript
|
||||
Scenario: Manually changing a taxon's slug while editing a taxon's name
|
||||
Given the store has "Medieval weapons" taxonomy
|
||||
When I want to modify this taxon
|
||||
When I want to modify the "Medieval weapons" taxon
|
||||
And I enable slug modification
|
||||
And I rename it to "Renaissance weapons" in "English (United States)"
|
||||
And I set its slug to "renaissance"
|
||||
And I save my changes
|
||||
Then the slug of the "Renaissance weapons" product should be "renaissance"
|
||||
Then the slug of the "Renaissance weapons" taxon should be "renaissance"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use Sylius\Behat\Page\Admin\Taxon\CreatePageInterface;
|
|||
use Sylius\Behat\Page\Admin\Taxon\UpdatePageInterface;
|
||||
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
|
||||
use Sylius\Behat\Service\SharedStorageInterface;
|
||||
use Sylius\Component\Core\Model\Taxon;
|
||||
use Sylius\Component\Core\Model\TaxonInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
|
|
@ -90,7 +91,6 @@ final class ManagingTaxonsContext implements Context
|
|||
|
||||
/**
|
||||
* @Given /^I want to modify the ("[^"]+" taxon)$/
|
||||
* @Given /^I want to modify (this taxon)$/
|
||||
*/
|
||||
public function iWantToModifyATaxon(TaxonInterface $taxon)
|
||||
{
|
||||
|
|
@ -138,6 +138,25 @@ final class ManagingTaxonsContext implements Context
|
|||
$currentPage->specifySlug($slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the slug field should not be editable
|
||||
*/
|
||||
public function theSlugFieldShouldNotBeEditable()
|
||||
{
|
||||
Assert::true(
|
||||
$this->updatePage->isSlugReadOnly(),
|
||||
'Slug should be immutable, but it does not.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I enable slug modification
|
||||
*/
|
||||
public function iEnableSlugModification()
|
||||
{
|
||||
$this->updatePage->enableSlugModification();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I change its description to :description in :language
|
||||
*/
|
||||
|
|
@ -263,6 +282,19 @@ final class ManagingTaxonsContext implements Context
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the slug of the ("[^"]+" taxon) should(?:| still) be "([^"]+)"$/
|
||||
*/
|
||||
public function productSlugShouldBe(TaxonInterface $taxon, $slug)
|
||||
{
|
||||
$this->updatePage->open(['id' => $taxon->getId()]);
|
||||
|
||||
Assert::true(
|
||||
$this->updatePage->hasResourceValues(['slug' => $slug]),
|
||||
sprintf('Taxon\'s slug should be %s.', $slug)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^this taxon should (belongs to "[^"]+")$/
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
public function nameIt($name, $languageCode)
|
||||
{
|
||||
$this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_name', $languageCode), $name);
|
||||
|
||||
$this->waitForSlugGenerationIfNecessary();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -275,4 +277,13 @@ JS;
|
|||
|
||||
return $driver;
|
||||
}
|
||||
|
||||
private function waitForSlugGenerationIfNecessary()
|
||||
{
|
||||
if ($this->getDriver() instanceof Selenium2Driver) {
|
||||
$this->getDocument()->waitFor(1000, function () {
|
||||
return '' !== $this->getElement('slug')->getValue();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Sylius\Behat\Page\Admin\Taxon;
|
||||
|
||||
use Behat\Mink\Driver\Selenium2Driver;
|
||||
use Behat\Mink\Element\NodeElement;
|
||||
use Behat\Mink\Exception\ElementNotFoundException;
|
||||
use Sylius\Behat\Behaviour\ChecksCodeImmutability;
|
||||
|
|
@ -47,6 +48,8 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
public function nameIt($name, $languageCode)
|
||||
{
|
||||
$this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_name', $languageCode), $name);
|
||||
|
||||
$this->waitForSlugGenerationIfNecessary();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,6 +96,14 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
return false === stripos($pageText, '404 Not Found');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isSlugReadOnly()
|
||||
{
|
||||
return 'readonly' === $this->getElement('slug')->getAttribute('readonly');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -108,6 +119,11 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
$imageElement->clickLink('Delete');
|
||||
}
|
||||
|
||||
public function enableSlugModification()
|
||||
{
|
||||
$this->getElement('toggle_taxon_slug_modification_button')->press();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -195,6 +211,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
'name' => '#sylius_taxon_translations_en_US_name',
|
||||
'parent' => '#sylius_taxon_parent',
|
||||
'slug' => '#sylius_taxon_translations_en_US_slug',
|
||||
'toggle_taxon_slug_modification_button' => '#toggle-taxon-slug-modification',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -246,4 +263,21 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
|
||||
return $inputCode->getParent()->getParent()->getParent();
|
||||
}
|
||||
|
||||
private function waitForSlugGenerationIfNecessary()
|
||||
{
|
||||
if (!$this->getDriver() instanceof Selenium2Driver) {
|
||||
return;
|
||||
}
|
||||
|
||||
$slugElement = $this->getElement('slug');
|
||||
if ($slugElement->hasAttribute('readonly')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$value = $slugElement->getValue();
|
||||
$this->getDocument()->waitFor(1000, function () use ($slugElement, $value) {
|
||||
return $value !== $slugElement->getValue();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
|
|||
*/
|
||||
public function isImageWithCodeDisplayed($code);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSlugReadOnly();
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*/
|
||||
|
|
@ -72,6 +77,8 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
|
|||
|
||||
public function removeFirstImage();
|
||||
|
||||
public function enableSlugModification();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ function updateSlug($element) {
|
|||
|
||||
if ('' != $slugInput.attr('data-parent') && undefined != $slugInput.attr('data-parent')) {
|
||||
$data = { name: $element.val(), parentId: $slugInput.attr('data-parent') };
|
||||
} else if ($('#sylius_taxon_parent').length > 0 && $('#sylius_taxon_parent').is(':visible')) {
|
||||
} else if ($('#sylius_taxon_parent').length > 0 && $('#sylius_taxon_parent').is(':visible') && '' != $('#sylius_taxon_parent').val()) {
|
||||
$data = { name: $element.val(), parentId: $('#sylius_taxon_parent').val() };
|
||||
} else {
|
||||
$data = { name: $element.val() };
|
||||
|
|
@ -53,11 +53,9 @@ function updateSlug($element) {
|
|||
|
||||
function toggleSlugModification($button, $slugInput) {
|
||||
if ($slugInput.attr('readonly')) {
|
||||
console.log('unlock');
|
||||
$slugInput.removeAttr('readonly');
|
||||
$button.html('<i class="lock icon"></i>');
|
||||
} else {
|
||||
console.log('lock');
|
||||
$slugInput.attr('readonly', 'readonly');
|
||||
$button.html('<i class="unlock icon"></i>');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue