diff --git a/features/admin/adding_block.feature b/features/admin/adding_block.feature index 448b16e3..773dbc47 100644 --- a/features/admin/adding_block.feature +++ b/features/admin/adding_block.feature @@ -26,6 +26,15 @@ Feature: Adding blocks And I add it Then I should be notified that the block has been created + @ui @javascript + Scenario: Adding block with content element + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I add a textarea content element with "Welcome to our store" content + And I add it + Then I should be notified that the block has been created + @ui Scenario: Trying to add block with existing code Given there is an existing block with "homepage_image" code diff --git a/tests/Behat/Context/Ui/Admin/BlockContext.php b/tests/Behat/Context/Ui/Admin/BlockContext.php index c6372c88..5ba9e69f 100755 --- a/tests/Behat/Context/Ui/Admin/BlockContext.php +++ b/tests/Behat/Context/Ui/Admin/BlockContext.php @@ -163,6 +163,14 @@ public function iAddAndCollectionsToIt(string ...$collectionsNames): void $this->resolveCurrentPage()->associateCollections($collectionsNames); } + /** + * @When I add a textarea content element with :content content + */ + public function iAddATextareaContentElementWithContent(string $content): void + { + $this->resolveCurrentPage()->addTextareaContentElementWithContent($content); + } + /** * @When I add it * @When I try to add it diff --git a/tests/Behat/Page/Admin/Block/CreatePage.php b/tests/Behat/Page/Admin/Block/CreatePage.php index 08a0eaa9..4a91aa30 100755 --- a/tests/Behat/Page/Admin/Block/CreatePage.php +++ b/tests/Behat/Page/Admin/Block/CreatePage.php @@ -10,6 +10,7 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Block; +use Behat\Mink\Exception\ElementNotFoundException; use DMore\ChromeDriver\ChromeDriver; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait; @@ -78,11 +79,31 @@ public function associateCollections(array $collectionsNames): void } } + /** + * @throws ElementNotFoundException + */ + public function addTextareaContentElementWithContent(string $content): void + { + Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); + + $addButton = $this->getElement('content_elements_add_button'); + $addButton->click(); + + $addButton->waitFor(3, function (): bool { + return $this->hasElement('content_elements_textarea'); + }); + + $textarea = $this->getElement('content_elements_textarea'); + $textarea->setValue($content); + } + protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ 'association_dropdown_collection' => '.field > label:contains("Collections") ~ .sylius-autocomplete', 'association_dropdown_collection_item' => '.field > label:contains("Collections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', + 'content_elements_add_button' => 'h4:contains("Content elements") .field a[data-form-collection="add"]', + 'content_elements_textarea' => '.field > label:contains("Textarea") ~ textarea', ]); } } diff --git a/tests/Behat/Page/Admin/Block/CreatePageInterface.php b/tests/Behat/Page/Admin/Block/CreatePageInterface.php index 0c44751e..b96ffe4c 100755 --- a/tests/Behat/Page/Admin/Block/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Block/CreatePageInterface.php @@ -29,5 +29,7 @@ public function fillContent(string $content): void; public function associateCollections(array $collectionsNames): void; + public function addTextareaContentElementWithContent(string $content): void; + public function disable(): void; }