Skip to content

Commit 762b5c9

Browse files
add info to upgrade-4.4.md
1 parent d3faae3 commit 762b5c9

6 files changed

Lines changed: 329 additions & 3 deletions

File tree

UPGRADE-4.4.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
This update adds support for Trix (as an optional WYSIWYG editor). If you would like to replace CKeditor with Trix review the plugin installation steps.
44

5-
Therefore, the configuration has been split and the `fos_ck_editor` configuration is required to be added with this update.
5+
The configuration has been split and the `fos_ck_editor` configuration is required to be added with this update.
66

7-
Import required CKeditor config in your `config/packages/_sylius.yaml` file:
7+
1. Import required CKeditor config in your `config/packages/_sylius.yaml` file:
88
```yaml
99
# config/packages/_sylius.yaml
1010

@@ -14,4 +14,32 @@ imports:
1414
- { resource: "@BitBagSyliusCmsPlugin/Resources/config/fos_ck_editor/fos_ck_editor.yml" }
1515
```
1616
17-
Or copy contents of `vendor/BitBag/cms-plugin/src/Resources/config/fos_ck_editor/fos_ck_editor.yml` to `config/packages/fos_ck_editor.yaml` file.
17+
*Or copy contents of `vendor/BitBag/cms-plugin/src/Resources/config/fos_ck_editor/fos_ck_editor.yml` to `config/packages/fos_ck_editor.yaml` file.*
18+
19+
2. If project use a `./vendor/bitbag/cms-plugin/webpack.config.js` file in `webpack.config.js` you need change:
20+
21+
From:
22+
```js
23+
// webpack.config.js
24+
25+
const [ bitbagCmsShop, bitbagCmsAdmin ] = require('./vendor/bitbag/cms-plugin/webpack.config.js')
26+
27+
...
28+
29+
module.exports = [..., bitbagCmsShop, bitbagCmsAdmin];
30+
```
31+
32+
To:
33+
```js
34+
// webpack.config.js
35+
36+
const createCmsConfigs = require('./vendor/bitbag/cms-plugin/webpack.config.js)
37+
38+
...
39+
40+
const [bitbagCmsShop, bitbagCmsAdmin] = createCmsConfigs({
41+
wysiwyg: 'ckeditor' // 'ckeditor' | 'trix'
42+
});
43+
44+
module.exports = [..., bitbagCmsShop, bitbagCmsAdmin];
45+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@managing_trix_wysiwyg
2+
Feature: Managing dynamic content on store pages
3+
In order to present and manage dynamic content on my store pages
4+
As an Administrator
5+
I want to be able to use the Trix WYSIWYG editor
6+
7+
Background:
8+
Given I am logged in as an administrator
9+
And the store operates on a single channel in "United States"
10+
11+
@managing_blocks @ui @javascript
12+
Scenario: Adding block
13+
When I go to the create block page
14+
Then I should see the Trix WYSIWYG editor initialized
15+
#
16+
# @managing_sections @ui @javascript
17+
# Scenario: Adding section
18+
# When I go to the create section page
19+
# Then I should see the Trix WYSIWYG editor initialized
20+
#
21+
# @managing_pages @ui @javascript
22+
# Scenario: Adding page
23+
# When I go to the create page page
24+
# Then I should see the Trix WYSIWYG editor initialized
25+
#
26+
# @managing_media @ui @javascript
27+
# Scenario: Adding media
28+
# When I go to the create media page
29+
# Then I should see the Trix WYSIWYG editor initialized
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@managing_blocks
2+
Feature: Managing dynamic content on block page
3+
As an Administrator
4+
I want to be able to use the Trix WYSIWYG editor
5+
6+
Background:
7+
Given I am logged in as an administrator
8+
And the store operates on a single channel in "United States"
9+
10+
@ui @javascript
11+
Scenario: Adding block
12+
When I go to the create block page
13+
Then I should see the Trix WYSIWYG editor initialized
14+
15+
@ui @javascript
16+
Scenario: Updating block
17+
Given there is a block with "content" code and "<p>Content !</p>" content
18+
When I go to the update "content" block page
19+
Then I should see the Trix WYSIWYG editor initialized
20+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@managing_blocks
2+
Feature: Managing dynamic content on block page
3+
As an Administrator
4+
I want to be able to use the Trix WYSIWYG editor
5+
6+
Background:
7+
Given I am logged in as an administrator
8+
And the store operates on a single channel in "United States"
9+
10+
@ui @javascript
11+
Scenario: Adding block
12+
When I go to the create block page
13+
Then I should see the Trix WYSIWYG editor initialized
14+
15+
@ui @javascript
16+
Scenario: Updating block
17+
Given there is a block with "content" code and "<p>Content !</p>" content
18+
When I go to the update "content" block page
19+
Then I should see the Trix WYSIWYG editor initialized
20+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% block bitbag_sylius_cms_plugin_trix_strategy_widget %}
2+
<input
3+
type="{{ app.environment == 'test' ? 'text' : 'hidden' }}"
4+
id="{{ id }}"
5+
name="{{ full_name }}"
6+
value="{{ value }}"
7+
{{ block('widget_attributes') }}
8+
/>
9+
10+
<trix-editor input="{{ id }}"></trix-editor>
11+
{% endblock %}
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
<?php
2+
3+
/*
4+
* This file was created by developers working at BitBag
5+
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
6+
* 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
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace Tests\BitBag\SyliusCmsPlugin\Behat\Context\Ui\Admin;
12+
13+
use Behat\Behat\Context\Context;
14+
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPageInterface;
15+
use Sylius\Behat\NotificationType;
16+
use Sylius\Behat\Service\NotificationCheckerInterface;
17+
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
18+
use Sylius\Behat\Service\SharedStorageInterface;
19+
use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section\CreatePageInterface;
20+
use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section\IndexPageInterface;
21+
use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section\UpdatePageInterface;
22+
use Tests\BitBag\SyliusCmsPlugin\Behat\Service\RandomStringGeneratorInterface;
23+
use Webmozart\Assert\Assert;
24+
25+
final class SectionContext implements Context
26+
{
27+
public function __construct(
28+
private SharedStorageInterface $sharedStorage,
29+
private CurrentPageResolverInterface $currentPageResolver,
30+
private NotificationCheckerInterface $notificationChecker,
31+
private IndexPageInterface $indexPage,
32+
private CreatePageInterface $createPage,
33+
private UpdatePageInterface $updatePage,
34+
private RandomStringGeneratorInterface $randomStringGenerator,
35+
) {
36+
}
37+
38+
/**
39+
* @When I go to the sections page
40+
*/
41+
public function iGoToTheSectionsPage(): void
42+
{
43+
$this->indexPage->open();
44+
}
45+
46+
/**
47+
* @When I go to the create section page
48+
*/
49+
public function iGoToTheCreateSectionPage(): void
50+
{
51+
$this->createPage->open();
52+
}
53+
54+
/**
55+
* @When I delete this section
56+
*/
57+
public function iDeleteThisSection(): void
58+
{
59+
$section = $this->sharedStorage->get('section');
60+
61+
$this->indexPage->deleteSection($section->getCode());
62+
}
63+
64+
/**
65+
* @When I want to edit this section
66+
*/
67+
public function iWantToEditThisSection(): void
68+
{
69+
$section = $this->sharedStorage->get('section');
70+
71+
$this->updatePage->open(['id' => $section->getId()]);
72+
}
73+
74+
/**
75+
* @When I fill the code with :code
76+
*/
77+
public function iFillTheCodeWith(string $code): void
78+
{
79+
$this->resolveCurrentPage()->fillCode($code);
80+
}
81+
82+
/**
83+
* @When I fill the name with :name
84+
*/
85+
public function iFillTheNameWith(string $name): void
86+
{
87+
$this->resolveCurrentPage()->fillName($name);
88+
}
89+
90+
/**
91+
* @When I add it
92+
* @When I try to add it
93+
*/
94+
public function iAddIt(): void
95+
{
96+
$this->createPage->create();
97+
}
98+
99+
/**
100+
* @When /^I fill "([^"]*)" fields with (\d+) (?:character|characters)$/
101+
*/
102+
public function iFillFieldsWithCharacters(string $fields, int $length): void
103+
{
104+
$fields = explode(',', $fields);
105+
106+
foreach ($fields as $field) {
107+
$this->resolveCurrentPage()->fillField(trim($field), $this->randomStringGenerator->generate($length));
108+
sleep(5);
109+
}
110+
}
111+
112+
/**
113+
* @Then I should be notified that :fields fields cannot be blank
114+
*/
115+
public function iShouldBeNotifiedThatFieldsCannotBeBlank(string $fields): void
116+
{
117+
$fields = explode(',', $fields);
118+
119+
foreach ($fields as $field) {
120+
Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf(
121+
'%s cannot be blank.',
122+
trim($field),
123+
)));
124+
}
125+
}
126+
127+
/**
128+
* @Then I should be notified that :fields fields are too short
129+
*/
130+
public function iShouldBeNotifiedThatFieldsAreTooShort(string $fields): void
131+
{
132+
$fields = explode(',', $fields);
133+
134+
foreach ($fields as $field) {
135+
Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf(
136+
'%s must be at least %d characters long.',
137+
trim($field),
138+
2,
139+
)));
140+
}
141+
}
142+
143+
/**
144+
* @Then I should be notified that :fields fields are too long
145+
*/
146+
public function iShouldBeNotifiedThatFieldsAreTooLong(string $fields): void
147+
{
148+
$fields = explode(',', $fields);
149+
150+
foreach ($fields as $field) {
151+
Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(sprintf(
152+
'%s can not be longer than',
153+
trim($field),
154+
), false));
155+
}
156+
}
157+
158+
/**
159+
* @Then I should be notified that there is already an existing section with provided code
160+
*/
161+
public function iShouldBeNotifiedThatThereIsAlreadyAnExistingSectionWithCode(): void
162+
{
163+
Assert::true($this->resolveCurrentPage()->containsErrorWithMessage(
164+
'There is an existing section with this code.',
165+
false,
166+
));
167+
}
168+
169+
/**
170+
* @Then I should be notified that new section has been created
171+
*/
172+
public function iShouldBeNotifiedThatNewSectionHasBeenCreated(): void
173+
{
174+
$this->notificationChecker->checkNotification(
175+
'Section has been successfully created.',
176+
NotificationType::success(),
177+
);
178+
}
179+
180+
/**
181+
* @Then I should be notified that the section has been deleted
182+
*/
183+
public function iShouldBeNotifiedThatTheSectionHasBeenDeleted(): void
184+
{
185+
$this->notificationChecker->checkNotification(
186+
'Section has been successfully deleted.',
187+
NotificationType::success(),
188+
);
189+
}
190+
191+
/**
192+
* @Then the code field should be disabled
193+
*/
194+
public function theCodeFieldShouldBeDisabled(): void
195+
{
196+
Assert::true($this->resolveCurrentPage()->isCodeDisabled());
197+
}
198+
199+
/**
200+
* @Then I should see empty list of sections
201+
*/
202+
public function iShouldSeeEmptyListOfSections(): void
203+
{
204+
$this->resolveCurrentPage()->isEmpty();
205+
}
206+
207+
/**
208+
* @return IndexPageInterface|CreatePageInterface|UpdatePageInterface|SymfonyPageInterface
209+
*/
210+
private function resolveCurrentPage(): SymfonyPageInterface
211+
{
212+
return $this->currentPageResolver->getCurrentPageWithForm([
213+
$this->indexPage,
214+
$this->createPage,
215+
$this->updatePage,
216+
]);
217+
}
218+
}

0 commit comments

Comments
 (0)