Skip to content

Commit

Permalink
Merge pull request #506 from BitBagCommerce/feature/OP-326
Browse files Browse the repository at this point in the history
OP-326: New content elements
  • Loading branch information
jkindly authored Jul 12, 2024
2 parents b586612 + 95e53a9 commit c84b85d
Show file tree
Hide file tree
Showing 55 changed files with 1,708 additions and 61 deletions.
100 changes: 99 additions & 1 deletion features/admin/adding_block.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,111 @@ Feature: Adding blocks
Then I should be notified that the block has been created

@ui @javascript
Scenario: Adding block with content element
Scenario: Adding block with textarea 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 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 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
Given there is an existing media with "image_1" code and name "Image 1"
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 "Single media" content element
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 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
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 "Heading" content element
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
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 carousel" content element
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
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 carousel by Taxon" content element
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
Given the store classifies its products as "Smartphones" and "Laptops"
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 "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 block has been created
And I should see newly created "Taxons list" content element in Content elements section

@ui @javascript
Scenario: Adding block with two content elements
Given there is an existing media with names "Image 1" and "Image 2"
And the store classifies its products as "Smartphones" and "Laptops"
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 "Taxons list" content element
And I add a taxons list content element with "Smartphones" and "Laptops" taxonomy
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 "Taxons list" content element in Content elements section
And I should see newly created "Multiple media" content element in Content elements section

@ui
Scenario: Trying to add block with existing code
Expand Down
106 changes: 105 additions & 1 deletion features/admin/adding_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,115 @@ Feature: Adding new page
Then I should be notified that the page has been created

@ui @javascript
Scenario: Adding page with content element
Scenario: Adding page with textarea content element
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 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
Given there is an existing media with "image_1" code and name "Image 1"
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 "Single media" content element
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
Given there is an existing media with names "Image 1" and "Image 2"
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 "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 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
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 "Heading" content element
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
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 carousel" content element
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
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 carousel by Taxon" content element
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
Given 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 "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 "Taxons list" content element in Content elements section

@ui @javascript
Scenario: Adding page with two content elements
Given there is an existing media with names "Image 1" and "Image 2"
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 "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 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
And I should see newly created "Multiple media" content element in Content elements section
12 changes: 11 additions & 1 deletion features/admin/managing_blocks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,24 @@ Feature: Managing cms blocks

@ui
Scenario: Updating block textarea content element
Given there is a block with "store_phone_number" code and textarea content element
Given there is a block with "store_phone_number" code and "Textarea" content element
When I go to the update "store_phone_number" block page
And I fill the name with "Store phone number" if the name field is empty
And I change textarea content element value to "New content"
And I update it
Then I should be notified that the block has been successfully updated
And I should see "New content" in the textarea content element

@ui @javascript
Scenario: Deleting content element in block
Given there is a block with "store_phone_number" code and "Textarea" content element
When I go to the update "store_phone_number" block page
And I fill the name with "Store phone number" if the name field is empty
And I delete the content element
And I update it
Then I should be notified that the block has been successfully updated
And I should not see "Textarea" content element in the Content elements section

@ui
Scenario: Disabling block
Given there is an existing block with "bitbag_quote" code
Expand Down
11 changes: 10 additions & 1 deletion features/admin/managing_pages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ Feature: Managing cms pages

@ui
Scenario: Updating page with textarea content element
Given there is a page in the store with textarea content element
Given there is a page in the store with "Textarea" content element
When I want to edit this page
And I fill "Code, Name" fields
And I change textarea content element value to "New content"
And I update it
Then I should be notified that the page was updated
And I should see "New content" in the textarea content element

@ui @javascript
Scenario: Deleting content element in page
Given there is a page in the store with "Textarea" content element
When I want to edit this page
And I delete the content element
And I update it
Then I should be notified that the page was updated
And I should not see "Textarea" content element in the Content elements section
76 changes: 76 additions & 0 deletions spec/Form/DataTransformer/MultipleMediaToCodesTransformerSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/

declare(strict_types=1);

namespace spec\BitBag\SyliusCmsPlugin\Form\DataTransformer;

use BitBag\SyliusCmsPlugin\Entity\MediaInterface;
use BitBag\SyliusCmsPlugin\Form\DataTransformer\MultipleMediaToCodesTransformer;
use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface;
use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;

final class MultipleMediaToCodesTransformerSpec extends ObjectBehavior
{
public function let(MediaRepositoryInterface $mediaRepository): void
{
$this->beConstructedWith($mediaRepository);
}

public function it_is_initializable(): void
{
$this->shouldHaveType(MultipleMediaToCodesTransformer::class);
}

public function it_transforms_null_value_to_empty_collection(): void
{
$this->transform(null)->shouldBeAnInstanceOf(ArrayCollection::class);
$this->transform(null)->count()->shouldBe(0);
}

public function it_transforms_empty_array_to_empty_collection(): void
{
$this->transform([])->shouldBeAnInstanceOf(ArrayCollection::class);
$this->transform([])->count()->shouldBe(0);
}

public function it_transforms_non_empty_array_to_collection(
MediaRepositoryInterface $mediaRepository,
MediaInterface $media1,
MediaInterface $media2
): void
{
$mediaCodes = ['code1', 'code2'];
$mediaRepository->findBy(['code' => $mediaCodes])->willReturn([$media1, $media2]);

$this->transform($mediaCodes)->shouldBeAnInstanceOf(ArrayCollection::class);
$this->transform($mediaCodes)->shouldHaveCount(2);
$this->transform($mediaCodes)->toArray()->shouldBe([$media1, $media2]);
}

public function it_reverse_transforms_empty_collection_to_empty_array(): void
{
$collection = new ArrayCollection();
$this->reverseTransform($collection)->shouldBeArray();
$this->reverseTransform($collection)->shouldBe([]);
}

public function it_reverse_transforms_collection_to_array_of_media_codes(
MediaInterface $media1,
MediaInterface $media2
): void
{
$media1->getCode()->willReturn('code1');
$media2->getCode()->willReturn('code2');

$collection = new ArrayCollection([$media1->getWrappedObject(), $media2->getWrappedObject()]);

$this->reverseTransform($collection)->shouldBe(['code1', 'code2']);
}
}
Loading

0 comments on commit c84b85d

Please sign in to comment.