diff --git a/features/admin/managing_blocks.feature b/features/admin/managing_blocks.feature
index b7429a7ae..962c53573 100644
--- a/features/admin/managing_blocks.feature
+++ b/features/admin/managing_blocks.feature
@@ -24,6 +24,16 @@ Feature: Managing cms blocks
And I update it
Then I should be notified that the block has been successfully updated
+ @ui @javascript
+ Scenario: Updating block 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
Scenario: Disabling block
Given there is an existing block with "bitbag_quote" code
diff --git a/tests/Behat/Context/Setup/BlockContext.php b/tests/Behat/Context/Setup/BlockContext.php
index 29885340c..c66b76ac0 100755
--- a/tests/Behat/Context/Setup/BlockContext.php
+++ b/tests/Behat/Context/Setup/BlockContext.php
@@ -12,6 +12,7 @@
use Behat\Behat\Context\Context;
use BitBag\SyliusCmsPlugin\Entity\BlockInterface;
+use BitBag\SyliusCmsPlugin\Entity\ContentConfigurationInterface;
use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\ChannelInterface;
@@ -24,6 +25,7 @@ public function __construct(
private SharedStorageInterface $sharedStorage,
private RandomStringGeneratorInterface $randomStringGenerator,
private FactoryInterface $blockFactory,
+ private FactoryInterface $contentConfigurationFactory,
private BlockRepositoryInterface $blockRepository,
) {
}
@@ -59,6 +61,16 @@ public function thereIsABlockWithCodeAndContent(string $code): void
$this->saveBlock($block);
}
+ /**
+ * @Given there is a block with :code code and textarea content element
+ */
+ public function thereIsABlockWithCodeAndTextareaContentElement(string $code): void
+ {
+ $block = $this->createBlockWithTextareaContentElement($code);
+
+ $this->saveBlock($block);
+ }
+
private function createBlock(
?string $code = null,
ChannelInterface $channel = null,
@@ -80,6 +92,21 @@ private function createBlock(
return $block;
}
+ private function createBlockWithTextareaContentElement(string $code): BlockInterface
+ {
+ $block = $this->createBlock($code);
+
+ /** @var ContentConfigurationInterface $contentConfiguration */
+ $contentConfiguration = $this->contentConfigurationFactory->createNew();
+ $contentConfiguration->setType('textarea');
+ $contentConfiguration->setConfiguration(['textarea' => 'Content']);
+ $contentConfiguration->setBlock($block);
+
+ $block->addContentElement($contentConfiguration);
+
+ return $block;
+ }
+
private function saveBlock(BlockInterface $block): void
{
$this->blockRepository->add($block);
diff --git a/tests/Behat/Context/Ui/Admin/BlockContext.php b/tests/Behat/Context/Ui/Admin/BlockContext.php
index 5ba9e69f8..435d11b43 100755
--- a/tests/Behat/Context/Ui/Admin/BlockContext.php
+++ b/tests/Behat/Context/Ui/Admin/BlockContext.php
@@ -131,6 +131,22 @@ public function iFillTheNameIfItIsEmpty(string $name): void
$this->resolveCurrentPage()->fillNameIfItIsEmpty($name);
}
+ /**
+ * @When I change textarea content element value to :value
+ */
+ public function iChangeTextareaContentElementValueTo(string $value): void
+ {
+ $this->resolveCurrentPage()->changeTextareaContentElementValue($value);
+ }
+
+ /**
+ * @Then I should see :content in the textarea content element
+ */
+ public function iShouldSeeNewContentInTheTextareaContentElement(string $content): void
+ {
+ $this->resolveCurrentPage()->containsTextareaContentElementWithValue($content);
+ }
+
/**
* @When I fill the link with :link
*/
diff --git a/tests/Behat/Page/Admin/Block/UpdatePage.php b/tests/Behat/Page/Admin/Block/UpdatePage.php
index 2aa6913b9..8e59ce73e 100755
--- a/tests/Behat/Page/Admin/Block/UpdatePage.php
+++ b/tests/Behat/Page/Admin/Block/UpdatePage.php
@@ -48,4 +48,14 @@ public function isBlockDisabled(): bool
{
return $this->getDocument()->findField('Enabled')->isChecked();
}
+
+ public function changeTextareaContentElementValue(string $value): void
+ {
+ $this->getDocument()->fillField('Textarea', $value);
+ }
+
+ public function containsTextareaContentElementWithValue(string $value): bool
+ {
+ return $this->getDocument()->findField('Textarea')->getValue() === $value;
+ }
}
diff --git a/tests/Behat/Page/Admin/Block/UpdatePageInterface.php b/tests/Behat/Page/Admin/Block/UpdatePageInterface.php
index 72cc75c30..019357b34 100755
--- a/tests/Behat/Page/Admin/Block/UpdatePageInterface.php
+++ b/tests/Behat/Page/Admin/Block/UpdatePageInterface.php
@@ -26,4 +26,8 @@ public function fillContent(string $content): void;
public function disable(): void;
public function isBlockDisabled(): bool;
+
+ public function changeTextareaContentElementValue(string $value): void;
+
+ public function containsTextareaContentElementWithValue(string $value): bool;
}
diff --git a/tests/Behat/Resources/services/contexts/setup.xml b/tests/Behat/Resources/services/contexts/setup.xml
index 87af1d70e..3f700a5b9 100644
--- a/tests/Behat/Resources/services/contexts/setup.xml
+++ b/tests/Behat/Resources/services/contexts/setup.xml
@@ -8,6 +8,7 @@
+