diff --git a/features/admin/adding_block.feature b/features/admin/adding_block.feature index a5bdf66ac..f3853c355 100644 --- a/features/admin/adding_block.feature +++ b/features/admin/adding_block.feature @@ -36,6 +36,7 @@ Feature: Adding blocks 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 + And I should see newly created "Textarea" content element in Content elements section @ui @javascript Scenario: Adding block with single media content element @@ -48,6 +49,7 @@ Feature: Adding blocks And I add a single media content element with name "Image 1" And I add it Then I should be notified that the block has been created + And I should see newly created "Single media" content element in Content elements section @ui @javascript Scenario: Adding block with heading content element @@ -59,6 +61,7 @@ Feature: Adding blocks And I add a heading content element with type "H3" and "Welcome to our store" content And I add it Then I should be notified that the block has been created + And I should see newly created "Heading" content element in Content elements section @ui @javascript Scenario: Adding block with products carousel content element @@ -71,6 +74,7 @@ Feature: Adding blocks And I add a products carousel content element with "iPhone 8" and "iPhone X" products And I add it Then I should be notified that the block has been created + And I should see newly created "Products carousel" content element in Content elements section @ui @javascript Scenario: Adding block with products carousel by taxon content element @@ -83,6 +87,7 @@ Feature: Adding blocks And I add a products carousel by taxon content element with "Smartphones" taxonomy And I add it Then I should be notified that the block has been created + And I should see newly created "Products carousel by Taxon" content element in Content elements section @ui @javascript Scenario: Adding block with taxons list content element @@ -95,6 +100,7 @@ Feature: Adding blocks And I add a taxons list content element with "Smartphones" and "Laptops" taxonomy And I add it Then I should be notified that the block has been created + And I should see newly created "Taxons list" content element in Content elements section @ui Scenario: Trying to add block with existing code diff --git a/features/admin/adding_page.feature b/features/admin/adding_page.feature index 67c78348f..df5e2e98e 100644 --- a/features/admin/adding_page.feature +++ b/features/admin/adding_page.feature @@ -78,6 +78,7 @@ Feature: Adding new page And I add a textarea content element with "Welcome to our store" content And I add it Then I should be notified that the page has been created + And I should see newly created "Textarea" content element in Content elements section @ui @javascript Scenario: Adding page with single media content element @@ -91,6 +92,7 @@ Feature: Adding new page And I add a single media content element with name "Image 1" And I add it Then I should be notified that the page has been created + And I should see newly created "Single media" content element in Content elements section @ui @javascript Scenario: Adding page with multiple media content element @@ -104,6 +106,7 @@ Feature: Adding new page And I add a multiple media content element with names "Image 1" and "Image 2" And I add it Then I should be notified that the page has been created + And I should see newly created "Multiple media" content element in Content elements section @ui @javascript Scenario: Adding page with heading content element @@ -116,6 +119,7 @@ Feature: Adding new page And I add a heading content element with type "H3" and "Welcome to our store" content And I add it Then I should be notified that the page has been created + And I should see newly created "Heading" content element in Content elements section @ui @javascript Scenario: Adding page with products carousel content element @@ -129,6 +133,7 @@ Feature: Adding new page And I add a products carousel content element with "iPhone 8" and "iPhone X" products And I add it Then I should be notified that the page has been created + And I should see newly created "Products carousel" content element in Content elements section @ui @javascript Scenario: Adding page with products carousel by taxon content element @@ -142,6 +147,7 @@ Feature: Adding new page And I add a products carousel by taxon content element with "Smartphones" taxonomy And I add it Then I should be notified that the page has been created + And I should see newly created "Products carousel by Taxon" content element in Content elements section @ui @javascript Scenario: Adding page with taxons list content element @@ -155,3 +161,4 @@ Feature: Adding new page And I add a taxons list content element with "Smartphones" and "Laptops" taxonomy And I add it Then I should be notified that the page has been created + And I should see newly created "Taxons list" content element in Content elements section diff --git a/tests/Behat/Behaviour/ContainsContentElementInterface.php b/tests/Behat/Behaviour/ContainsContentElementInterface.php new file mode 100644 index 000000000..76bc9dd94 --- /dev/null +++ b/tests/Behat/Behaviour/ContainsContentElementInterface.php @@ -0,0 +1,16 @@ + 'Products', + 'Products carousel by taxon' => 'Taxon', + 'Taxons list' => 'Taxons', + default => $contentElement, + }; + + $contentElements = $this->getDocument()->findById('bitbag_sylius_cms_plugin_block_contentElements') + ?? $this->getDocument()->findById('bitbag_sylius_cms_plugin_page_contentElements'); + + if (null === $contentElements) { + throw new \InvalidArgumentException('Content elements container not found'); + } + + return $contentElements->hasField($fieldName); + } +} diff --git a/tests/Behat/Context/Ui/Admin/PageContext.php b/tests/Behat/Context/Ui/Admin/PageContext.php index cc1edccb7..b172780c3 100755 --- a/tests/Behat/Context/Ui/Admin/PageContext.php +++ b/tests/Behat/Context/Ui/Admin/PageContext.php @@ -150,7 +150,7 @@ public function iChangeTextareaContentElementValueTo(string $value): void */ public function iShouldSeeNewContentInTheTextareaContentElement(string $content): void { - $this->resolveCurrentPage()->containsTextareaContentElementWithValue($content); + Assert::true($this->resolveCurrentPage()->containsTextareaContentElementWithValue($content)); } /** @@ -257,6 +257,14 @@ public function iAddATaxonsListContentElementWithTaxons(string ...$taxons): void $this->resolveCurrentPage()->addTaxonsListContentElementWithTaxons($taxons); } + /** + * @Then I should see newly created :contentElement content element in Content elements section + */ + public function iShouldSeeNewlyCreatedContentElementInContentElementsSection(string $contentElement): void + { + Assert::true($this->resolveCurrentPage()->containsContentElement($contentElement)); + } + /** * @When I add it * @When I try to add it diff --git a/tests/Behat/Page/Admin/Page/CreatePage.php b/tests/Behat/Page/Admin/Page/CreatePage.php index 2771612a5..e8b344e54 100755 --- a/tests/Behat/Page/Admin/Page/CreatePage.php +++ b/tests/Behat/Page/Admin/Page/CreatePage.php @@ -14,6 +14,7 @@ use DMore\ChromeDriver\ChromeDriver; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Sylius\Behat\Service\SlugGenerationHelper; +use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsContentElementTrait; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait; use Tests\BitBag\SyliusCmsPlugin\Behat\Helpers\ContentElementHelper; use Tests\BitBag\SyliusCmsPlugin\Behat\Service\FormHelper; @@ -22,6 +23,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface { use ContainsErrorTrait; + use ContainsContentElementTrait; public function fillField(string $field, string $value): void { diff --git a/tests/Behat/Page/Admin/Page/CreatePageInterface.php b/tests/Behat/Page/Admin/Page/CreatePageInterface.php index 5b511a7c5..bd4ee90db 100755 --- a/tests/Behat/Page/Admin/Page/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Page/CreatePageInterface.php @@ -11,9 +11,13 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Page; use Sylius\Behat\Page\Admin\Crud\CreatePageInterface as BaseCreatePageInterface; +use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsContentElementInterface; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorInterface; -interface CreatePageInterface extends BaseCreatePageInterface, ContainsErrorInterface +interface CreatePageInterface extends + BaseCreatePageInterface, + ContainsErrorInterface, + ContainsContentElementInterface { public const IMAGE_FORM_ID = 'bitbag_sylius_cms_plugin_page_translations_en_US_image';