bug #11549 Behat for reordering taxon feature ()

This PR was merged into the 1.7 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.7
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.6 or 1.7 branches (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set
-->


Commits
-------

eb54c52702 Behat for reordering taxon feature
This commit is contained in:
Łukasz Chruściel 2020-06-09 09:10:04 +02:00 committed by GitHub
commit 23f3828dfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 2 deletions

View file

@ -8,7 +8,7 @@ Feature: Reordering taxons
Given the store classifies its products as "T-Shirts", "Watches", "Belts" and "Wallets"
And I am logged in as an administrator
@ui @javascript @todo
@ui @javascript
Scenario: Moving up the taxon on list
When I want to see all taxons in store
And I move up "Watches" taxon
@ -16,7 +16,7 @@ Feature: Reordering taxons
And I should see the taxon named "T-Shirts" in the list
But the first taxon on the list should be "Watches"
@ui @javascript @todo
@ui @javascript
Scenario: Moving down the taxon on list
When I want to see all taxons in store
And I move down "T-Shirts" taxon

View file

@ -398,6 +398,30 @@ final class ManagingTaxonsContext implements Context
);
}
/**
* @When I move up :taxonName taxon
*/
public function iMoveUpTaxon(string $taxonName)
{
$this->createPage->moveUpTaxon($taxonName);
}
/**
* @When I move down :taxonName taxon
*/
public function iMoveDownTaxon(string $taxonName)
{
$this->createPage->moveDownTaxon($taxonName);
}
/**
* @Then the first taxon on the list should be :taxonName
*/
public function theFirstTaxonOnTheListShouldBe(string $taxonName)
{
Assert::same($this->createPage->getFirstTaxonOnTheList(), $taxonName);
}
/**
* @return CreatePageInterface|CreateForParentPageInterface|UpdatePageInterface
*/

View file

@ -120,6 +120,31 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
}
}
public function moveUpTaxon(string $name): void
{
$taxonElement = $this->getElement('tree_item', ['%taxon%' => $name]);
$treeAction = $taxonElement->getParent()->getParent()->find('css', '.sylius-tree__action');
$treeAction->click();
JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
$treeAction->find('css', '.sylius-taxon-move-up .up')->click();
JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
}
public function moveDownTaxon(string $name): void
{
$taxonElement = $this->getElement('tree_item', ['%taxon%' => $name]);
$treeAction = $taxonElement->getParent()->getParent()->find('css', '.sylius-tree__action');
$treeAction->click();
JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
$treeAction->find('css', '.sylius-taxon-move-down .down')->click();
JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
}
public function getFirstTaxonOnTheList(): string
{
return $this->getLeaves()[0]->getText();
}
protected function getElement(string $name, array $parameters = []): NodeElement
{
if (!isset($parameters['%language%'])) {
@ -140,6 +165,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
'name' => '#sylius_taxon_translations_%language%_name',
'slug' => '#sylius_taxon_translations_%language%_slug',
'tree' => '.sylius-tree',
'tree_item' => '.sylius-tree__item a:contains("%taxon%")',
]);
}

View file

@ -49,4 +49,10 @@ interface CreatePageInterface extends BaseCreatePageInterface
public function getLeaves(TaxonInterface $parentTaxon = null): array;
public function activateLanguageTab(string $locale): void;
public function moveUpTaxon(string $name): void;
public function moveDownTaxon(string $name): void;
public function getFirstTaxonOnTheList(): string;
}