Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
uses: actions/upload-artifact@v4
if: failure()
with:
name: "Behat logs - Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, ${{ matrix.database }}"
name: "Behat logs - Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, ${{ env.DB_TYPE }}-${{ env.DB_VERSION }}"
path: etc/build/
if-no-files-found: ignore
compression-level: 6
Expand Down
40 changes: 20 additions & 20 deletions features/admin/page/adding_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: Adding new page

@ui
Scenario: Adding page minimal data
When I go to the create page page
When I go to the create page
And I fill the code with "page_with_title"
And I fill the slug with "page_with_title"
And I fill the name with "page_with_title"
Expand All @@ -19,7 +19,7 @@ Feature: Adding new page

@ui
Scenario: Adding page
When I go to the create page page
When I go to the create page
And I fill the code with "top_5_outfits_for_this_summer"
And I fill the slug with "top_5_outfits_for_this_summer"
And I fill the name with "Top 5 outfits for this summer"
Expand All @@ -31,35 +31,35 @@ Feature: Adding new page
@ui
Scenario: Trying to add page with existing code
Given there is an existing page with "terms" code
When I go to the create page page
When I go to the create page
And I fill the code with "terms"
And I try to add it
Then I should be notified that there is already an existing page with provided code

@ui
Scenario: Adding new page with blank data
When I go to the create page page
When I go to the create page
And I add it
And I should be notified that "Code, Name, Slug" fields cannot be blank

@ui
Scenario: Trying to add a page with too short data
When I go to the create page page
When I go to the create page
And I fill "Code, Name, Slug, Meta keywords, Meta description" fields with 1 character
And I try to add it
Then I should be notified that "Code, Name, Slug, Meta keywords, Meta description" fields are too short

@ui
Scenario: Trying to add a page with too long data
When I go to the create page page
When I go to the create page
And I fill "Code, Name, Slug, Meta keywords, Meta description" fields with 6000 characters
And I try to add it
Then I should be notified that "Code, Name, Slug, Meta keywords, Meta description" fields are too long

@ui @javascript
Scenario: Adding page with collections
Given there are existing collections named "Blog" and "Homepage" with "page" type
When I go to the create page page
When I go to the create page
And I fill the code with "best_day_ever"
And I fill the name with "Best day ever"
And I fill the slug with "Slug"
Expand All @@ -70,7 +70,7 @@ Feature: Adding new page

@ui @javascript
Scenario: Adding page with textarea content element
When I go to the create page page
When I go to the create 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"
Expand All @@ -82,7 +82,7 @@ Feature: Adding new page
@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
When I go to the create 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"
Expand All @@ -94,7 +94,7 @@ Feature: Adding new page
@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
When I go to the create 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"
Expand All @@ -105,7 +105,7 @@ Feature: Adding new page

@ui @javascript
Scenario: Adding page with heading content element
When I go to the create page page
When I go to the create 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"
Expand All @@ -117,7 +117,7 @@ Feature: Adding new page
@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
When I go to the create 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"
Expand All @@ -129,7 +129,7 @@ Feature: Adding new page
@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
When I go to the create 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"
Expand All @@ -141,7 +141,7 @@ Feature: Adding new page
@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
When I go to the create 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"
Expand All @@ -153,7 +153,7 @@ Feature: Adding new page
@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
When I go to the create 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"
Expand All @@ -165,7 +165,7 @@ Feature: Adding new page
@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
When I go to the create 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"
Expand All @@ -177,7 +177,7 @@ Feature: Adding new page
@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
When I go to the create 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"
Expand All @@ -191,7 +191,7 @@ Feature: Adding new page
@ui @javascript
Scenario: Adding page with content template
Given there is an existing content template named "Homepage" with "page" type that contains "Textarea, Single media" content elements
When I go to the create page page
When I go to the create 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"
Expand All @@ -204,7 +204,7 @@ Feature: Adding new page

@ui
Scenario: Adding page with with a custom template
When I go to the create page page
When I go to the create 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"
Expand All @@ -218,7 +218,7 @@ Feature: Adding new page
@ui @javascript
Scenario: Adding page with header and content template
Given there is an existing content template named "Homepage" with "page" type that contains "Textarea, Heading" content elements
When I go to the create page page
When I go to the create 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"
Expand Down
16 changes: 8 additions & 8 deletions features/admin/page/sorting_content_elements_on_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: Sorting content elements on a page

@ui @javascript
Scenario: Moving a content element down
When I go to the create page page
When I go to the create page
And I fill the code with "sort-test-page"
And I fill the name with "Sort Test Page"
And I fill the slug with "sort-test-page"
Expand All @@ -22,7 +22,7 @@ Feature: Sorting content elements on a page

@ui @javascript
Scenario: Moving a content element up
When I go to the create page page
When I go to the create page
And I fill the code with "sort-test-page"
And I fill the name with "Sort Test Page"
And I fill the slug with "sort-test-page"
Expand All @@ -34,13 +34,13 @@ Feature: Sorting content elements on a page

@ui @javascript
Scenario: Reordering keeps textarea contents at their new positions
When I go to the create page page
When I go to the create page
And I fill the code with "sort-test-page"
And I fill the name with "Sort Test Page"
And I fill the slug with "sort-test-page"
And I add a textarea content element with "First textarea content" content
And I add a textarea content element with "Second textarea content" content
When I move the 2nd content element up
And I move the 2nd content element up
Then the 1st content element should be a "Textarea" element
And the 2nd content element should be a "Textarea" element
And the 1st content element should contain "Second textarea content"
Expand All @@ -49,19 +49,19 @@ Feature: Sorting content elements on a page
@ui @javascript
Scenario: Reordering keeps the selected media of adjacent autocomplete elements
Given there is an existing media with names "Image 1" and "Image 2"
When I go to the create page page
When I go to the create page
And I fill the code with "sort-test-page"
And I fill the name with "Sort Test Page"
And I fill the slug with "sort-test-page"
And I add a single media content element with name "Image 1"
And I add a single media content element with name "Image 2"
When I move the 2nd content element up
And I move the 2nd content element up
Then the 1st content element should contain "Image 2"
And the 2nd content element should contain "Image 1"

@ui @javascript
Scenario: The first content element cannot be moved up
When I go to the create page page
When I go to the create page
And I fill the code with "sort-test-page"
And I fill the name with "Sort Test Page"
And I fill the slug with "sort-test-page"
Expand All @@ -71,7 +71,7 @@ Feature: Sorting content elements on a page

@ui @javascript
Scenario: The last content element cannot be moved down
When I go to the create page page
When I go to the create page
And I fill the code with "sort-test-page"
And I fill the name with "Sort Test Page"
And I fill the slug with "sort-test-page"
Expand Down
4 changes: 2 additions & 2 deletions features/admin/wysiwyg/quill/manging_pages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Feature: Managing dynamic content on block page

@ui @javascript
Scenario: Adding page
When I go to the create page page
When I go to the create page
Then I should see the Quill WYSIWYG editor initialized

@ui @javascript
Scenario: Updating page
Given there is an existing page with "test_page" code
When I go to the update "test_page" page page
When I go to the update "test_page" page
Then I should see the Quill WYSIWYG editor initialized
4 changes: 2 additions & 2 deletions features/admin/wysiwyg/trix/manging_pages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Feature: Managing dynamic content on block page

@ui @javascript
Scenario: Adding page
When I go to the create page page
When I go to the create page
Then I should see the Trix WYSIWYG editor initialized

@ui @javascript
Scenario: Updating page
Given there is an existing page with "test_page" code
When I go to the update "test_page" page page
When I go to the update "test_page" page
Then I should see the Trix WYSIWYG editor initialized

21 changes: 21 additions & 0 deletions src/Form/Type/ContentConfigurationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use Sylius\CmsPlugin\Form\Type\ContentElements\ContentElementConfigurationType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType;
Expand Down Expand Up @@ -65,6 +67,25 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'required' => false,
])
;

$builder->get('contentElements')->addEventListener(
FormEvents::PRE_SUBMIT,
static function (FormEvent $event): void {
$data = $event->getData();
if (!is_array($data)) {
return;
}

foreach ($data as $key => $element) {
if (!is_array($element) || '' === ($element['type'] ?? '')) {
unset($data[$key]);
}
}

$event->setData($data);
},
1,
);
}

public function configureOptions(OptionsResolver $resolver): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Behat/Context/Ui/Admin/ContentCollectionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Tests\Sylius\CmsPlugin\Behat\Context\Ui\Admin;

use Behat\Behat\Context\Context;
use Behat\Step\Then;
use Sylius\CmsPlugin\Form\Type\ContentElements\HeadingContentElementType;
use Sylius\CmsPlugin\Form\Type\ContentElements\MultipleMediaContentElementType;
use Sylius\CmsPlugin\Form\Type\ContentElements\ProductsCarouselByTaxonContentElementType;
Expand Down Expand Up @@ -233,9 +234,7 @@ public function theContentElementAtPositionShouldBeOfType(string $ordinal, strin
);
}

/**
* @Then the :ordinal content element should contain :content
*/
#[Then('the :ordinal content element should contain :content')]
public function theContentElementAtPositionShouldContain(string $ordinal, string $content): void
{
Assert::contains(
Expand Down
8 changes: 4 additions & 4 deletions tests/Behat/Context/Ui/Admin/PageContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public function iGoToTheCmsPagesPage(): void
}

/**
* @When I go to the create page page
* @When I go to the create page
*/
public function iGoToTheCreatePagePage(): void
public function iGoToTheCreatePage(): void
{
$this->createPage->open();
}
Expand All @@ -77,9 +77,9 @@ public function iWantToEditThisPage(): void
}

/**
* @When I go to the update :code page page
* @When I go to the update :code page
*/
public function iGoToTheUpdatePagePage(string $code): void
public function iGoToTheUpdatePage(string $code): void
{
$page = $this->pageRepository->findOneBy(['code' => $code]);

Expand Down
2 changes: 1 addition & 1 deletion tests/Behat/Context/Ui/Shop/PageContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
}

/**
* @When I go to the :slug page
* @When I go to the ":slug" page
*/
public function iGoToThePage(string $slug): void
{
Expand Down
Loading