diff --git a/features/admin/adding_block.feature b/features/admin/adding_block.feature index f3853c35..1bb3cd92 100644 --- a/features/admin/adding_block.feature +++ b/features/admin/adding_block.feature @@ -51,6 +51,19 @@ Feature: Adding blocks 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 multiple media content element + Given there is an existing media with names "Image 1" and "Image 2" + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Multiple media" content element + 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 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 When I go to the create block page diff --git a/features/admin/adding_page.feature b/features/admin/adding_page.feature index df5e2e98..045460b3 100644 --- a/features/admin/adding_page.feature +++ b/features/admin/adding_page.feature @@ -162,3 +162,42 @@ Feature: Adding new page 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 + + @ui @javascript + Scenario: Adding page with multiple content elements + Given there is an existing media with names "Image 1" and "Image 2" + And the store has "iPhone 8" and "iPhone X" products + And the store classifies its products as "Smartphones" and "Laptops" + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Textarea" content element + And I add a textarea content element with "Welcome to our store" content + And I click on Add button in Content elements section + And I select "Single media" content element + And I add a single media content element with name "Image 1" + And I click on Add button in Content elements section + And I select "Multiple media" content element + And I add a multiple media content element with names "Image 1" and "Image 2" + And I click on Add button in Content elements section + And I select "Heading" content element + And I add a heading content element with type "H2" and "Welcome to our store" content + And I click on Add button in Content elements section + And I select "Products carousel" content element + And I add a products carousel content element with "iPhone 8" and "iPhone X" products + And I click on Add button in Content elements section + And I select "Products carousel by Taxon" content element + And I add a products carousel by taxon content element with "Smartphones" taxonomy + And I click on Add button in Content elements section + And I select "Taxons list" content element + 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 "Textarea" content element in Content elements section + And I should see newly created "Single media" content element in Content elements section + And I should see newly created "Multiple media" content element in Content elements section + And I should see newly created "Heading" content element in Content elements section + And I should see newly created "Products carousel" content element in Content elements section + And I should see newly created "Products carousel by Taxon" content element in Content elements section diff --git a/tests/Behat/Behaviour/ContainsContentElementTrait.php b/tests/Behat/Behaviour/ContainsContentElementTrait.php index 19726f05..3cc68547 100644 --- a/tests/Behat/Behaviour/ContainsContentElementTrait.php +++ b/tests/Behat/Behaviour/ContainsContentElementTrait.php @@ -31,9 +31,11 @@ public function containsContentElement(string $contentElement): bool ?? $this->getDocument()->findById('bitbag_sylius_cms_plugin_page_contentElements'); if (null === $contentElements) { - throw new \InvalidArgumentException('Content elements container not found'); + throw new \InvalidArgumentException('Content elements container not found.'); } + // Autocomplete fields doesn't have labels directly above input field, so we can't use hasField method, + // so we need to check if input field with search class exists instead. return $isAutocompleteField ? $contentElements->has('css', 'input.search') : $contentElements->hasField($contentElement); diff --git a/tests/Behat/Context/Ui/Admin/BlockContext.php b/tests/Behat/Context/Ui/Admin/BlockContext.php index 0bbafab1..e2c7b338 100755 --- a/tests/Behat/Context/Ui/Admin/BlockContext.php +++ b/tests/Behat/Context/Ui/Admin/BlockContext.php @@ -171,6 +171,14 @@ public function iAddASingleMediaContentElementWithName(string $name): void $this->resolveCurrentPage()->addSingleMediaContentElementWithName($name); } + /** + * @When I add a multiple media content element with names :firstMediaName and :secondMediaName + */ + public function iAddAMultipleMediaContentElementWithNames(string ...$mediaNames): void + { + $this->resolveCurrentPage()->addMultipleMediaContentElementWithNames($mediaNames); + } + /** * @When I add a heading content element with type :type and :content content */ diff --git a/tests/Behat/Page/Admin/Block/CreatePage.php b/tests/Behat/Page/Admin/Block/CreatePage.php index 0fedd848..4a4a2f66 100755 --- a/tests/Behat/Page/Admin/Block/CreatePage.php +++ b/tests/Behat/Page/Admin/Block/CreatePage.php @@ -143,6 +143,29 @@ public function addSingleMediaContentElementWithName(string $name): void $item->click(); } + /** + * @throws ElementNotFoundException + */ + public function addMultipleMediaContentElementWithNames(array $mediaNames): void + { + $dropdown = $this->getElement('content_elements_multiple_media_dropdown'); + $dropdown->click(); + + foreach ($mediaNames as $mediaName) { + $dropdown->waitFor(10, function () use ($mediaName): bool { + return $this->hasElement('content_elements_multiple_media_dropdown_item', [ + '%item%' => $mediaName, + ]); + }); + + $item = $this->getElement('content_elements_multiple_media_dropdown_item', [ + '%item%' => $mediaName, + ]); + + $item->click(); + } + } + /** * @throws ElementNotFoundException */ @@ -232,6 +255,8 @@ protected function getDefinedElements(): array 'content_elements_textarea' => '.field > label:contains("Textarea") ~ textarea', 'content_elements_single_media_dropdown' => '.field > label:contains("Single media") ~ .bitbag-media-autocomplete', 'content_elements_single_media_dropdown_item' => '.field > label:contains("Single media") ~ .bitbag-media-autocomplete > div.menu > div.item:contains("%item%")', + 'content_elements_multiple_media_dropdown' => '.field > label:contains("Multiple media") ~ .bitbag-media-autocomplete', + 'content_elements_multiple_media_dropdown_item' => '.field > label:contains("Multiple media") ~ .bitbag-media-autocomplete > div.menu > div.item:contains("%item%")', 'content_elements_heading' => '.field > label:contains("Heading type") ~ select', 'content_elements_heading_content' => '.field > label:contains("Heading") ~ input[type="text"]', 'content_elements_products_carousel' => '.field > label:contains("Products") ~ .sylius-autocomplete', diff --git a/tests/Behat/Page/Admin/Block/CreatePageInterface.php b/tests/Behat/Page/Admin/Block/CreatePageInterface.php index 7d60c0a1..95bbcfbb 100755 --- a/tests/Behat/Page/Admin/Block/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Block/CreatePageInterface.php @@ -37,6 +37,8 @@ public function addTextareaContentElementWithContent(string $content): void; public function addSingleMediaContentElementWithName(string $name): void; + public function addMultipleMediaContentElementWithNames(array $mediaNames): void; + public function addHeadingContentElementWithTypeAndContent(string $type, string $content): void; public function addProductsCarouselContentElementWithProducts(array $productsNames): void;