Tests fixes

This commit is contained in:
Mateusz Zalewski 2019-03-14 14:48:12 +01:00
parent c96f032e59
commit cdf7818384
No known key found for this signature in database
GPG key ID: 0545A7503DD474B8
3 changed files with 13 additions and 22 deletions

View file

@ -7,13 +7,13 @@ Feature: Deleting a taxon
Background: Background:
Given I am logged in as an administrator Given I am logged in as an administrator
@ui @ui @javascript
Scenario: Deleted taxon should disappear from the registry Scenario: Deleted taxon should disappear from the registry
Given the store classifies its products as "T-Shirts" Given the store classifies its products as "T-Shirts"
When I delete taxon named "T-Shirts" When I delete taxon named "T-Shirts"
Then the taxon named "T-Shirts" should no longer exist in the registry Then the taxon named "T-Shirts" should no longer exist in the registry
@ui @ui @javascript
Scenario: Deleting a taxon with a child does not delete any other taxons Scenario: Deleting a taxon with a child does not delete any other taxons
Given the store classifies its products as "Main catalog" Given the store classifies its products as "Main catalog"
And the "Main catalog" taxon has children taxon "Shoes" and "Shovels" And the "Main catalog" taxon has children taxon "Shoes" and "Shovels"

View file

@ -53,7 +53,7 @@ final class IndexPage extends CrudIndexPage implements IndexPageInterface
protected function getDefinedElements(): array protected function getDefinedElements(): array
{ {
return array_merge(parent::getDefinedElements(), [ return array_merge(parent::getDefinedElements(), [
'taxon_filter' => '.item a:contains("%taxon%")', 'taxon_filter' => '.sylius-tree__item a:contains("%taxon%")',
]); ]);
} }
} }

View file

@ -18,6 +18,7 @@ use Behat\Mink\Element\NodeElement;
use Behat\Mink\Exception\ElementNotFoundException; use Behat\Mink\Exception\ElementNotFoundException;
use Sylius\Behat\Behaviour\SpecifiesItsCode; use Sylius\Behat\Behaviour\SpecifiesItsCode;
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
use Sylius\Behat\Service\JQueryHelper;
use Sylius\Behat\Service\SlugGenerationHelper; use Sylius\Behat\Service\SlugGenerationHelper;
use Sylius\Component\Core\Model\TaxonInterface; use Sylius\Component\Core\Model\TaxonInterface;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
@ -47,9 +48,13 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
public function deleteTaxonOnPageByName(string $name): void public function deleteTaxonOnPageByName(string $name): void
{ {
$leaves = $this->getLeaves(); $leaves = $this->getLeaves();
/** @var NodeElement $leaf */
foreach ($leaves as $leaf) { foreach ($leaves as $leaf) {
if ($leaf->getText() === $name) { if ($leaf->find('css', '.sylius-tree__title')->getText() === $name) {
$leaf->getParent()->find('css', '.ui.red.button')->press(); $leaf->find('css', '.sylius-tree__action__trigger')->click();
JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
$leaf->find('css', '.sylius-tree__action button')->press();
$this->getElement('confirmation_button')->click();
return; return;
} }
@ -99,22 +104,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
public function getLeaves(TaxonInterface $parentTaxon = null): array public function getLeaves(TaxonInterface $parentTaxon = null): array
{ {
$tree = $this->getElement('tree'); return $this->getDocument()->findAll('css', '.sylius-tree__item');
Assert::notNull($tree);
/** @var NodeElement[] $leaves */
$leaves = $tree->findAll('css', '.item > .content > .header > a');
if (null === $parentTaxon) {
return $leaves;
}
foreach ($leaves as $leaf) {
if ($leaf->getText() === $parentTaxon->getName()) {
return $leaf->findAll('css', '.item > .content > .header');
}
}
return [];
} }
public function activateLanguageTab(string $locale): void public function activateLanguageTab(string $locale): void
@ -142,12 +132,13 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
{ {
return array_merge(parent::getDefinedElements(), [ return array_merge(parent::getDefinedElements(), [
'code' => '#sylius_taxon_code', 'code' => '#sylius_taxon_code',
'confirmation_button' => '#confirmation-button',
'description' => '#sylius_taxon_translations_en_US_description', 'description' => '#sylius_taxon_translations_en_US_description',
'images' => '#sylius_taxon_images', 'images' => '#sylius_taxon_images',
'language_tab' => '[data-locale="%locale%"] .title', 'language_tab' => '[data-locale="%locale%"] .title',
'name' => '#sylius_taxon_translations_%language%_name', 'name' => '#sylius_taxon_translations_%language%_name',
'slug' => '#sylius_taxon_translations_%language%_slug', 'slug' => '#sylius_taxon_translations_%language%_slug',
'tree' => '.ui.list', 'tree' => '.sylius-tree',
]); ]);
} }