diff --git a/features/admin/adding_block.feature b/features/admin/adding_block.feature index bfa95711..61550185 100644 --- a/features/admin/adding_block.feature +++ b/features/admin/adding_block.feature @@ -102,6 +102,32 @@ Feature: Adding blocks 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 products grid content element + Given the store has "iPhone 8" and "iPhone X" products + 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 "Products grid" content element + And I add a products grid 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 grid" content element in Content elements section + + @ui @javascript + Scenario: Adding block with products grid by taxon content element + Given the store has "Smartphones" taxonomy + 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 "Products grid by Taxon" content element + And I add a products grid 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 grid by Taxon" content element in Content elements section + @ui @javascript Scenario: Adding block with taxons list content element Given the store classifies its products as "Smartphones" and "Laptops" diff --git a/features/admin/adding_page.feature b/features/admin/adding_page.feature index fc9bd1cc..28ac7ae6 100644 --- a/features/admin/adding_page.feature +++ b/features/admin/adding_page.feature @@ -149,6 +149,34 @@ Feature: Adding new page 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 products grid content element + Given the store has "iPhone 8" and "iPhone X" products + 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 "Products grid" content element + And I add a products grid 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 grid" content element in Content elements section + + @ui @javascript + Scenario: Adding page with products grid by taxon content element + Given the store has "Smartphones" taxonomy + 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 "Products grid by Taxon" content element + And I add a products grid 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 grid by Taxon" content element in Content elements section + @ui @javascript Scenario: Adding page with taxons list content element Given the store classifies its products as "Smartphones" and "Laptops" diff --git a/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php new file mode 100644 index 00000000..3745ca5d --- /dev/null +++ b/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php @@ -0,0 +1,77 @@ +beConstructedWith($twig, $productRepository, $taxonRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(ProductsGridByTaxonContentElementRenderer::class); + } + + public function it_implements_content_element_renderer_interface(): void + { + $this->shouldImplement(ContentElementRendererInterface::class); + } + + public function it_supports_products_grid_by_taxon_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(ProductsGridByTaxonContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_products_grid_by_taxon_content_element( + Environment $twig, + ProductRepositoryInterface $productRepository, + TaxonRepositoryInterface $taxonRepository, + ContentConfigurationInterface $contentConfiguration, + TaxonInterface $taxon, + Product $product1, + Product $product2 + ): void + { + $contentConfiguration->getConfiguration()->willReturn([ + 'products_grid_by_taxon' => 'taxon_code' + ]); + + $taxonRepository->findOneBy(['code' => 'taxon_code'])->willReturn($taxon); + $productRepository->findByTaxon($taxon)->willReturn([$product1, $product2]); + + $twig->render('@BitBagSyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => '@BitBagSyliusCmsPlugin/Shop/ContentElement/_products_grid.html.twig', + 'products' => [$product1, $product2], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php new file mode 100644 index 00000000..f5f01203 --- /dev/null +++ b/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php @@ -0,0 +1,72 @@ +beConstructedWith($twig, $productRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(ProductsGridContentElementRenderer::class); + } + + public function it_implements_content_element_renderer_interface(): void + { + $this->shouldImplement(ContentElementRendererInterface::class); + } + + public function it_supports_products_grid_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(ProductsGridContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_products_grid_content_element( + Environment $twig, + ProductRepositoryInterface $productRepository, + ContentConfigurationInterface $contentConfiguration, + Product $product1, + Product $product2 + ): void + { + $contentConfiguration->getConfiguration()->willReturn([ + 'products_grid' => ['products' => ['code1', 'code2']] + ]); + + $productRepository->findBy(['code' => ['code1', 'code2']])->willReturn([$product1, $product2]); + + $twig->render('@BitBagSyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => '@BitBagSyliusCmsPlugin/Shop/ContentElement/_products_grid.html.twig', + 'products' => [$product1, $product2], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/src/Form/Type/ContentElements/ProductsGridByTaxonContentElementType.php b/src/Form/Type/ContentElements/ProductsGridByTaxonContentElementType.php new file mode 100644 index 00000000..9721f89d --- /dev/null +++ b/src/Form/Type/ContentElements/ProductsGridByTaxonContentElementType.php @@ -0,0 +1,47 @@ +add(self::TYPE, TaxonAutocompleteChoiceType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.taxon', + 'choice_value' => 'code', + 'resource' => 'sylius.taxon', + ]) + ; + + $builder->get(self::TYPE)->addModelTransformer( + new ReversedTransformer(new ResourceToIdentifierTransformer($this->taxonRepository, 'code')), + ); + } + + public function getBlockPrefix(): string + { + return 'bitbag_sylius_cms_plugin_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/ProductsGridContentElementType.php b/src/Form/Type/ContentElements/ProductsGridContentElementType.php new file mode 100644 index 00000000..a4674337 --- /dev/null +++ b/src/Form/Type/ContentElements/ProductsGridContentElementType.php @@ -0,0 +1,34 @@ +add(self::TYPE, ForProductsScopeConfigurationType::class, [ + 'label' => false, + ]) + ; + } + + public function getBlockPrefix(): string + { + return 'bitbag_sylius_cms_plugin_content_elements_' . self::TYPE; + } +} diff --git a/src/Migrations/Version20240715083336.php b/src/Migrations/Version20240715083336.php index 86120282..98bb6432 100644 --- a/src/Migrations/Version20240715083336.php +++ b/src/Migrations/Version20240715083336.php @@ -1,5 +1,11 @@ addSql('ALTER TABLE bitbag_cms_media_channels DROP FOREIGN KEY FK_D109622EE9ED820C'); $this->addSql('DROP INDEX IDX_D109622EE9ED820C ON bitbag_cms_media_channels'); $this->addSql('DROP INDEX `primary` ON bitbag_cms_media_channels'); @@ -31,7 +33,6 @@ public function up(Schema $schema): void public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE bitbag_cms_media_channels DROP FOREIGN KEY FK_D109622EEA9FDD75'); $this->addSql('DROP INDEX IDX_D109622EEA9FDD75 ON bitbag_cms_media_channels'); $this->addSql('DROP INDEX `PRIMARY` ON bitbag_cms_media_channels'); diff --git a/src/Renderer/ContentElement/ProductsGridByTaxonContentElementRenderer.php b/src/Renderer/ContentElement/ProductsGridByTaxonContentElementRenderer.php new file mode 100644 index 00000000..3877ddda --- /dev/null +++ b/src/Renderer/ContentElement/ProductsGridByTaxonContentElementRenderer.php @@ -0,0 +1,47 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $taxonCode = $contentConfiguration->getConfiguration()['products_grid_by_taxon']; + + /** @var TaxonInterface $taxon */ + $taxon = $this->taxonRepository->findOneBy(['code' => $taxonCode]); + $products = $this->productRepository->findByTaxon($taxon); + + return $this->twig->render('@BitBagSyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => '@BitBagSyliusCmsPlugin/Shop/ContentElement/_products_grid.html.twig', + 'products' => $products, + ]); + } +} diff --git a/src/Renderer/ContentElement/ProductsGridContentElementRenderer.php b/src/Renderer/ContentElement/ProductsGridContentElementRenderer.php new file mode 100644 index 00000000..1b24a451 --- /dev/null +++ b/src/Renderer/ContentElement/ProductsGridContentElementRenderer.php @@ -0,0 +1,42 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $configuration = $contentConfiguration->getConfiguration(); + $productsCodes = $configuration['products_grid']['products']; + $products = $this->productRepository->findBy(['code' => $productsCodes]); + + return $this->twig->render('@BitBagSyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => '@BitBagSyliusCmsPlugin/Shop/ContentElement/_products_grid.html.twig', + 'products' => $products, + ]); + } +} diff --git a/src/Resources/config/services/form.xml b/src/Resources/config/services/form.xml index 0c5f534c..2c5efc27 100644 --- a/src/Resources/config/services/form.xml +++ b/src/Resources/config/services/form.xml @@ -8,6 +8,8 @@ BitBag\SyliusCmsPlugin\Form\Type\ContentElements\HeadingContentElementType::TYPE BitBag\SyliusCmsPlugin\Form\Type\ContentElements\ProductsCarouselContentElementType::TYPE BitBag\SyliusCmsPlugin\Form\Type\ContentElements\ProductsCarouselByTaxonContentElementType::TYPE + BitBag\SyliusCmsPlugin\Form\Type\ContentElements\ProductsGridContentElementType::TYPE + BitBag\SyliusCmsPlugin\Form\Type\ContentElements\ProductsGridByTaxonContentElementType::TYPE BitBag\SyliusCmsPlugin\Form\Type\ContentElements\TaxonsListContentElementType::TYPE @@ -107,6 +109,17 @@ + + + + + + + + + + + diff --git a/src/Resources/config/services/renderer.xml b/src/Resources/config/services/renderer.xml index 61c251c3..2f2fba36 100644 --- a/src/Resources/config/services/renderer.xml +++ b/src/Resources/config/services/renderer.xml @@ -46,6 +46,19 @@ + + + + + + + + + + + + + diff --git a/src/Resources/translations/messages.cs.yml b/src/Resources/translations/messages.cs.yml index a055354b..6ad54fb2 100755 --- a/src/Resources/translations/messages.cs.yml +++ b/src/Resources/translations/messages.cs.yml @@ -16,6 +16,8 @@ bitbag_sylius_cms_plugin: products_carousel: Produkty v karuselu products_carousel_by_taxon: Produkty v karuselu podle taxonu taxons_list: Seznam taxonů + products_grid: Produkty v mřížce + products_grid_by_taxon: Produkty v mřížce podle taxonu heading_type: Typ nadpisu taxon: Taxon cms: diff --git a/src/Resources/translations/messages.cs_CZ.yml b/src/Resources/translations/messages.cs_CZ.yml index a055354b..6ad54fb2 100755 --- a/src/Resources/translations/messages.cs_CZ.yml +++ b/src/Resources/translations/messages.cs_CZ.yml @@ -16,6 +16,8 @@ bitbag_sylius_cms_plugin: products_carousel: Produkty v karuselu products_carousel_by_taxon: Produkty v karuselu podle taxonu taxons_list: Seznam taxonů + products_grid: Produkty v mřížce + products_grid_by_taxon: Produkty v mřížce podle taxonu heading_type: Typ nadpisu taxon: Taxon cms: diff --git a/src/Resources/translations/messages.de.yml b/src/Resources/translations/messages.de.yml index f1288dad..18cb3c28 100755 --- a/src/Resources/translations/messages.de.yml +++ b/src/Resources/translations/messages.de.yml @@ -66,5 +66,7 @@ bitbag_sylius_cms_plugin: products_carousel: Produkte im Karussell products_carousel_by_taxon: Produkte im Karussell nach Taxon taxons_list: Taxon-Liste + products_grid: Produkte im Raster + products_grid_by_taxon: Produkte im Raster nach Taxon heading_type: Überschrift-Typ taxon: Taxon diff --git a/src/Resources/translations/messages.en.yml b/src/Resources/translations/messages.en.yml index 6fe4d115..d8daf5cf 100755 --- a/src/Resources/translations/messages.en.yml +++ b/src/Resources/translations/messages.en.yml @@ -70,6 +70,8 @@ bitbag_sylius_cms_plugin: products_carousel: Products carousel products_carousel_by_taxon: Products carousel by Taxon taxons_list: Taxons list + products_grid: Products grid + products_grid_by_taxon: Products grid by Taxon heading_type: Heading type taxon: Taxon seo: SEO diff --git a/src/Resources/translations/messages.es.yml b/src/Resources/translations/messages.es.yml index 49c98b21..b93bfcac 100755 --- a/src/Resources/translations/messages.es.yml +++ b/src/Resources/translations/messages.es.yml @@ -45,5 +45,7 @@ bitbag_sylius_cms_plugin: products_carousel: Productos en carrusel products_carousel_by_taxon: Productos en carrusel por taxón taxons_list: Lista de taxones + products_grid: Productos en cuadrícula + products_grid_by_taxon: Productos en cuadrícula por taxón heading_type: Tipo de encabezado taxon: Taxón diff --git a/src/Resources/translations/messages.fr.yml b/src/Resources/translations/messages.fr.yml index e785e607..04ece97e 100755 --- a/src/Resources/translations/messages.fr.yml +++ b/src/Resources/translations/messages.fr.yml @@ -63,5 +63,7 @@ bitbag_sylius_cms_plugin: products_carousel: Produits en carrousel products_carousel_by_taxon: Produits en carrousel par taxon taxons_list: Liste de taxons + products_grid: Produits en grille + products_grid_by_taxon: Produits en grille par taxon heading_type: Type d'en-tête taxon: Taxon diff --git a/src/Resources/translations/messages.hr.yml b/src/Resources/translations/messages.hr.yml index 9ee30842..9296a322 100755 --- a/src/Resources/translations/messages.hr.yml +++ b/src/Resources/translations/messages.hr.yml @@ -45,5 +45,7 @@ bitbag_sylius_cms_plugin: products_carousel: Proizvodi u karijeslu products_carousel_by_taxon: Proizvodi u karijeslu po taksonu taxons_list: Lista taksona + products_grid: Proizvodi u mreži + products_grid_by_taxon: Proizvodi u mreži po taksonu heading_type: Tip naslova taxon: Takson diff --git a/src/Resources/translations/messages.lt.yml b/src/Resources/translations/messages.lt.yml index c3da8446..6799bf34 100644 --- a/src/Resources/translations/messages.lt.yml +++ b/src/Resources/translations/messages.lt.yml @@ -62,5 +62,7 @@ bitbag_sylius_cms_plugin: products_carousel: Produktų karuselė products_carousel_by_taxon: Produktų karuselė pagal taksoną taxons_list: Taksonų sąrašas + products_grid: Produktų tinklelis + products_grid_by_taxon: Produktų tinklelis pagal taksoną heading_type: Antraštės tipas taxon: Taksonas diff --git a/src/Resources/translations/messages.nl.yml b/src/Resources/translations/messages.nl.yml index 349242b8..4b23f947 100755 --- a/src/Resources/translations/messages.nl.yml +++ b/src/Resources/translations/messages.nl.yml @@ -44,5 +44,7 @@ bitbag_sylius_cms_plugin: products_carousel: Producten in carrousel products_carousel_by_taxon: Producten in carrousel per taxon taxons_list: Taxon lijst + products_grid: Producten grid + products_grid_by_taxon: Producten grid per taxon heading_type: Kop type taxon: Taxon diff --git a/src/Resources/translations/messages.pl.yml b/src/Resources/translations/messages.pl.yml index 9a0e3410..67a9d2ef 100755 --- a/src/Resources/translations/messages.pl.yml +++ b/src/Resources/translations/messages.pl.yml @@ -49,5 +49,7 @@ bitbag_sylius_cms_plugin: products_carousel: Karuzela produktów products_carousel_by_taxon: Karuzela produktów według taksonomii taxons_list: Lista taksonomii + products_grid: Siatka produktów + products_grid_by_taxon: Siatka produktów według taksonomii heading_type: Typ nagłówka taxon: Taksonomia diff --git a/src/Resources/translations/messages.ru.yml b/src/Resources/translations/messages.ru.yml index d16b832c..6de939b4 100755 --- a/src/Resources/translations/messages.ru.yml +++ b/src/Resources/translations/messages.ru.yml @@ -62,5 +62,7 @@ bitbag_sylius_cms_plugin: products_carousel: Продукты в карусели products_carousel_by_taxon: Продукты в карусели по таксону taxons_list: Список таксонов + products_grid: Продукты в сетке + products_grid_by_taxon: Продукты в сетке по таксону heading_type: Тип заголовка taxon: Таксон diff --git a/src/Resources/translations/messages.sk.yml b/src/Resources/translations/messages.sk.yml index 3d0b5db5..3e8fd822 100644 --- a/src/Resources/translations/messages.sk.yml +++ b/src/Resources/translations/messages.sk.yml @@ -63,5 +63,7 @@ bitbag_sylius_cms_plugin: products_carousel: Produkty v karuseli products_carousel_by_taxon: Produkty v karuseli podľa taxónu taxons_list: Zoznam taxónov + products_grid: Produkty v mriežke + products_grid_by_taxon: Produkty v mriežke podľa taxónu heading_type: Typ nadpisu taxon: Taxón diff --git a/src/Resources/translations/messages.uk.yml b/src/Resources/translations/messages.uk.yml index fdea329b..dba77b1e 100755 --- a/src/Resources/translations/messages.uk.yml +++ b/src/Resources/translations/messages.uk.yml @@ -62,5 +62,7 @@ bitbag_sylius_cms_plugin: products_carousel: Продукти в каруселі products_carousel_by_taxon: Продукти в каруселі за таксоном taxons_list: Список таксонів + products_grid: Продукти в сітці + products_grid_by_taxon: Продукти в сітці за таксоном heading_type: Тип заголовка taxon: Таксон diff --git a/src/Resources/views/Shop/ContentElement/_products_grid.html.twig b/src/Resources/views/Shop/ContentElement/_products_grid.html.twig new file mode 100644 index 00000000..c48272e8 --- /dev/null +++ b/src/Resources/views/Shop/ContentElement/_products_grid.html.twig @@ -0,0 +1,3 @@ +
+ {% include '@SyliusShop/Product/_horizontalList.html.twig' %} +
diff --git a/tests/Behat/Behaviour/ContainsContentElementTrait.php b/tests/Behat/Behaviour/ContainsContentElementTrait.php index db6e686e..0d3c0485 100644 --- a/tests/Behat/Behaviour/ContainsContentElementTrait.php +++ b/tests/Behat/Behaviour/ContainsContentElementTrait.php @@ -23,6 +23,8 @@ public function containsContentElement(string $contentElement): bool 'Multiple media', 'Products carousel', 'Products carousel by Taxon', + 'Products grid', + 'Products grid by Taxon', 'Taxons list' => true, default => false, }; diff --git a/tests/Behat/Context/Ui/Admin/BlockContext.php b/tests/Behat/Context/Ui/Admin/BlockContext.php index 6d250cd3..607c2e30 100755 --- a/tests/Behat/Context/Ui/Admin/BlockContext.php +++ b/tests/Behat/Context/Ui/Admin/BlockContext.php @@ -203,6 +203,22 @@ public function iAddAProductsCarouselByTaxonContentElementWithTaxon(string $taxo $this->resolveCurrentPage()->addProductsCarouselByTaxonContentElementWithTaxon($taxon); } + /** + * @When I add a products grid content element with :firstProductName and :secondProductName products + */ + public function iAddAProductsGridContentElementWithProducts(string ...$productsNames): void + { + $this->resolveCurrentPage()->addProductsGridContentElementWithProducts($productsNames); + } + + /** + * @When I add a products grid by taxon content element with :taxon taxonomy + */ + public function iAddAProductsGridByTaxonContentElementWithTaxon(string $taxon): void + { + $this->resolveCurrentPage()->addProductsGridByTaxonContentElementWithTaxon($taxon); + } + /** * @When I add a taxons list content element with :firstTaxon and :secondTaxon taxonomy */ diff --git a/tests/Behat/Context/Ui/Admin/PageContext.php b/tests/Behat/Context/Ui/Admin/PageContext.php index b5f3d488..fd1af330 100755 --- a/tests/Behat/Context/Ui/Admin/PageContext.php +++ b/tests/Behat/Context/Ui/Admin/PageContext.php @@ -249,6 +249,22 @@ public function iAddAProductsCarouselByTaxonContentElementWithTaxon(string $taxo $this->resolveCurrentPage()->addProductsCarouselByTaxonContentElementWithTaxon($taxon); } + /** + * @When I add a products grid content element with :firstProductName and :secondProductName products + */ + public function iAddAProductsGridContentElementWithProducts(string ...$productsNames): void + { + $this->resolveCurrentPage()->addProductsGridContentElementWithProducts($productsNames); + } + + /** + * @When I add a products grid by taxon content element with :taxon taxonomy + */ + public function iAddAProductsGridByTaxonContentElementWithTaxon(string $taxon): void + { + $this->resolveCurrentPage()->addProductsGridByTaxonContentElementWithTaxon($taxon); + } + /** * @When I add a taxons list content element with :firstTaxon and :secondTaxon taxonomy */ diff --git a/tests/Behat/Helpers/ContentElementHelper.php b/tests/Behat/Helpers/ContentElementHelper.php index c2915b9d..3f0ca2ef 100644 --- a/tests/Behat/Helpers/ContentElementHelper.php +++ b/tests/Behat/Helpers/ContentElementHelper.php @@ -21,6 +21,8 @@ public static function getDefinedElementThatShouldAppearAfterSelectContentElemen 'Heading' => 'content_elements_heading', 'Products carousel' => 'content_elements_products_carousel', 'Products carousel by Taxon' => 'content_elements_products_carousel_by_taxon', + 'Products grid' => 'content_elements_products_grid', + 'Products grid by Taxon' => 'content_elements_products_grid_by_taxon', 'Taxons list' => 'content_elements_taxons_list', default => throw new \InvalidArgumentException(sprintf('Content element with name "%s" does not exist.', $contentElement)), }; @@ -40,6 +42,13 @@ public static function getExampleConfigurationByContentElement(string $contentEl ], ]], 'Products carousel by Taxon' => ['products_carousel_by_taxon' => 'MENU_CATEGORY'], + 'Products grid' => ['products_grid' => [ + 'products' => [ + 'Everyday_white_basic_T_Shirt', + 'Loose_white_designer_T_Shirt', + ], + ]], + 'Products grid by Taxon' => ['products_grid_by_taxon' => 'MENU_CATEGORY'], 'Taxons list' => ['taxons_list' => [ 'taxons' => [ 'MENU_CATEGORY', diff --git a/tests/Behat/Page/Admin/Block/CreatePage.php b/tests/Behat/Page/Admin/Block/CreatePage.php index 7af9cc02..98a9031b 100755 --- a/tests/Behat/Page/Admin/Block/CreatePage.php +++ b/tests/Behat/Page/Admin/Block/CreatePage.php @@ -197,6 +197,44 @@ public function addProductsCarouselByTaxonContentElementWithTaxon(string $taxon) $item->click(); } + public function addProductsGridContentElementWithProducts(array $productsNames): void + { + $dropdown = $this->getElement('content_elements_products_grid'); + $dropdown->click(); + + foreach ($productsNames as $productName) { + $dropdown->waitFor(5, function () use ($productName): bool { + return $this->hasElement('content_elements_products_grid_item', [ + '%item%' => $productName, + ]); + }); + + $item = $this->getElement('content_elements_products_grid_item', [ + '%item%' => $productName, + ]); + + $item->click(); + } + } + + public function addProductsGridByTaxonContentElementWithTaxon(string $taxon): void + { + $dropdown = $this->getElement('content_elements_products_grid_by_taxon'); + $dropdown->click(); + + $dropdown->waitFor(5, function () use ($taxon): bool { + return $this->hasElement('content_elements_products_grid_by_taxon_item', [ + '%item%' => $taxon, + ]); + }); + + $item = $this->getElement('content_elements_products_grid_by_taxon_item', [ + '%item%' => $taxon, + ]); + + $item->click(); + } + public function addTaxonsListContentElementWithTaxons(array $taxons): void { $dropdown = $this->getElement('content_elements_taxons_list'); @@ -235,6 +273,10 @@ protected function getDefinedElements(): array 'content_elements_products_carousel_item' => '.field > label:contains("Products") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', 'content_elements_products_carousel_by_taxon' => '.field > label:contains("Taxon") ~ .sylius-autocomplete', 'content_elements_products_carousel_by_taxon_item' => '.field > label:contains("Taxon") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', + 'content_elements_products_grid' => '.field > label:contains("Products") ~ .sylius-autocomplete', + 'content_elements_products_grid_item' => '.field > label:contains("Products") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', + 'content_elements_products_grid_by_taxon' => '.field > label:contains("Taxon") ~ .sylius-autocomplete', + 'content_elements_products_grid_by_taxon_item' => '.field > label:contains("Taxon") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', 'content_elements_taxons_list' => '.field > label:contains("Taxons") ~ .sylius-autocomplete', 'content_elements_taxons_list_item' => '.field > label:contains("Taxons") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', ]); diff --git a/tests/Behat/Page/Admin/Block/CreatePageInterface.php b/tests/Behat/Page/Admin/Block/CreatePageInterface.php index 95bbcfbb..54605051 100755 --- a/tests/Behat/Page/Admin/Block/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Block/CreatePageInterface.php @@ -45,6 +45,10 @@ public function addProductsCarouselContentElementWithProducts(array $productsNam public function addProductsCarouselByTaxonContentElementWithTaxon(string $taxon): void; + public function addProductsGridContentElementWithProducts(array $productsNames): void; + + public function addProductsGridByTaxonContentElementWithTaxon(string $taxon): void; + public function addTaxonsListContentElementWithTaxons(array $taxons): void; public function disable(): void; diff --git a/tests/Behat/Page/Admin/Page/CreatePage.php b/tests/Behat/Page/Admin/Page/CreatePage.php index c2eedbb3..2e292220 100755 --- a/tests/Behat/Page/Admin/Page/CreatePage.php +++ b/tests/Behat/Page/Admin/Page/CreatePage.php @@ -206,6 +206,44 @@ public function addProductsCarouselByTaxonContentElementWithTaxon(string $taxon) $item->click(); } + public function addProductsGridContentElementWithProducts(array $productsNames): void + { + $dropdown = $this->getElement('content_elements_products_grid'); + $dropdown->click(); + + foreach ($productsNames as $productName) { + $dropdown->waitFor(5, function () use ($productName): bool { + return $this->hasElement('content_elements_products_grid_item', [ + '%item%' => $productName, + ]); + }); + + $item = $this->getElement('content_elements_products_grid_item', [ + '%item%' => $productName, + ]); + + $item->click(); + } + } + + public function addProductsGridByTaxonContentElementWithTaxon(string $taxon): void + { + $dropdown = $this->getElement('content_elements_products_grid_by_taxon'); + $dropdown->click(); + + $dropdown->waitFor(5, function () use ($taxon): bool { + return $this->hasElement('content_elements_products_grid_by_taxon_item', [ + '%item%' => $taxon, + ]); + }); + + $item = $this->getElement('content_elements_products_grid_by_taxon_item', [ + '%item%' => $taxon, + ]); + + $item->click(); + } + public function addTaxonsListContentElementWithTaxons(array $taxons): void { $dropdown = $this->getElement('content_elements_taxons_list'); @@ -245,6 +283,10 @@ protected function getDefinedElements(): array 'content_elements_products_carousel_item' => '.field > label:contains("Products") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', 'content_elements_products_carousel_by_taxon' => '.field > label:contains("Taxon") ~ .sylius-autocomplete', 'content_elements_products_carousel_by_taxon_item' => '.field > label:contains("Taxon") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', + 'content_elements_products_grid' => '.field > label:contains("Products") ~ .sylius-autocomplete', + 'content_elements_products_grid_item' => '.field > label:contains("Products") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', + 'content_elements_products_grid_by_taxon' => '.field > label:contains("Taxon") ~ .sylius-autocomplete', + 'content_elements_products_grid_by_taxon_item' => '.field > label:contains("Taxon") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', 'content_elements_taxons_list' => '.field > label:contains("Taxons") ~ .sylius-autocomplete', 'content_elements_taxons_list_item' => '.field > label:contains("Taxons") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', ]); diff --git a/tests/Behat/Page/Admin/Page/CreatePageInterface.php b/tests/Behat/Page/Admin/Page/CreatePageInterface.php index 5b511a7c..cd67dc2b 100755 --- a/tests/Behat/Page/Admin/Page/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Page/CreatePageInterface.php @@ -51,5 +51,9 @@ public function addProductsCarouselContentElementWithProducts(array $productsNam public function addProductsCarouselByTaxonContentElementWithTaxon(string $taxon): void; + public function addProductsGridContentElementWithProducts(array $productsNames): void; + + public function addProductsGridByTaxonContentElementWithTaxon(string $taxon): void; + public function addTaxonsListContentElementWithTaxons(array $taxons): void; }