Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -29,8 +29,8 @@ class AdminUiTest extends CKEditor5TestBase { public function testSettingsOnlyFireAjaxWithCkeditor5(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat($page, $assert_session, 'unicorn'); $this->addNewTextFormat(); $this->addNewTextFormat('unicorn'); $this->drupalGet('admin/config/content/formats/manage/ckeditor5'); Loading Loading @@ -184,7 +184,7 @@ public function testImageUploadSettingsAreValidated(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('admin/config/content/formats/manage/ckeditor5'); // Add the image plugin to the CKEditor 5 toolbar. Loading Loading @@ -233,7 +233,7 @@ public function testMessagesDoNotAccumulate(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('admin/config/content/formats/manage/ckeditor5'); // Add the source editing plugin to the CKEditor 5 toolbar. Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5OffCanvasTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ public function testOffCanvasStyles(): void { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('/ckeditor5_test/off_canvas'); Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ReadOnlyModeTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ protected function setUp(): void { public function testReadOnlyMode(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); // Check that both CKEditor 5 fields are editable. $this->drupalGet('node/add'); Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php +4 −6 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ public function testExistingContent(): void { $assert_session->responseNotContains('<p>This is test content</p>'); $assert_session->responseContains('<p>This is test content</p>'); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); // Change the node to use the new text format. $this->drupalGet('node/1/edit'); Loading Loading @@ -152,7 +152,7 @@ public function testHeadingsPlugin(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('admin/config/content/formats/manage/ckeditor5'); $this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', '<br> <p> <h2> <h3> <h4> <h5> <h6> <strong> <em>'); Loading Loading @@ -612,8 +612,7 @@ public function testEmphasis(): void { $page->fillField('body[0][value]', '<p>This is a <em>test!</em></p>'); $page->pressButton('Save'); $this->createNewTextFormat($page, $assert_session); $this->saveNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('node/1/edit'); $page->selectFieldOption('body[0][format]', 'ckeditor5'); Loading Loading @@ -743,8 +742,7 @@ public function testFilterHtmlAllowedGlobalAttributes(): void { $page->fillField('body[0][value]', '<p dir="ltr" lang="en">Hello World</p><p dir="rtl" lang="ar">مرحبا بالعالم</p>'); $page->pressButton('Save'); $this->createNewTextFormat($page, $assert_session); $this->saveNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('node/1/edit'); $page->selectFieldOption('body[0][format]', 'ckeditor5'); Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php +27 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,10 @@ namespace Drupal\Tests\ckeditor5\FunctionalJavascript; use Behat\Mink\Element\TraversableElement; use Drupal\editor\Entity\Editor; use Drupal\filter\Entity\FilterFormat; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\user\RoleInterface; // cspell:ignore esque Loading Loading @@ -48,9 +51,30 @@ protected function setUp(): void { /** * Add and save a new text format using CKEditor 5. */ public function addNewTextFormat($page, $assert_session, $name = 'ckeditor5') { $this->createNewTextFormat($page, $assert_session, $name); $this->saveNewTextFormat($page, $assert_session); protected function addNewTextFormat($name = 'ckeditor5'): void { FilterFormat::create([ 'format' => $name, 'roles' => [RoleInterface::AUTHENTICATED_ID], 'name' => $name, 'filters' => [ 'filter_html' => [ 'status' => TRUE, 'settings' => [ 'allowed_html' => '<br> <p> <h2> <h3> <h4> <h5> <h6> <strong> <em>', ], ], 'filter_align' => ['status' => TRUE], 'filter_caption' => ['status' => TRUE], ], ])->save(); Editor::create([ 'editor' => $name, 'format' => $name, 'image_upload' => [ 'status' => FALSE, ], ])->save(); } /** Loading Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -29,8 +29,8 @@ class AdminUiTest extends CKEditor5TestBase { public function testSettingsOnlyFireAjaxWithCkeditor5(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat($page, $assert_session, 'unicorn'); $this->addNewTextFormat(); $this->addNewTextFormat('unicorn'); $this->drupalGet('admin/config/content/formats/manage/ckeditor5'); Loading Loading @@ -184,7 +184,7 @@ public function testImageUploadSettingsAreValidated(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('admin/config/content/formats/manage/ckeditor5'); // Add the image plugin to the CKEditor 5 toolbar. Loading Loading @@ -233,7 +233,7 @@ public function testMessagesDoNotAccumulate(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('admin/config/content/formats/manage/ckeditor5'); // Add the source editing plugin to the CKEditor 5 toolbar. Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5OffCanvasTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ public function testOffCanvasStyles(): void { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('/ckeditor5_test/off_canvas'); Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5ReadOnlyModeTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ protected function setUp(): void { public function testReadOnlyMode(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); // Check that both CKEditor 5 fields are editable. $this->drupalGet('node/add'); Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php +4 −6 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ public function testExistingContent(): void { $assert_session->responseNotContains('<p>This is test content</p>'); $assert_session->responseContains('<p>This is test content</p>'); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); // Change the node to use the new text format. $this->drupalGet('node/1/edit'); Loading Loading @@ -152,7 +152,7 @@ public function testHeadingsPlugin(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->addNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('admin/config/content/formats/manage/ckeditor5'); $this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', '<br> <p> <h2> <h3> <h4> <h5> <h6> <strong> <em>'); Loading Loading @@ -612,8 +612,7 @@ public function testEmphasis(): void { $page->fillField('body[0][value]', '<p>This is a <em>test!</em></p>'); $page->pressButton('Save'); $this->createNewTextFormat($page, $assert_session); $this->saveNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('node/1/edit'); $page->selectFieldOption('body[0][format]', 'ckeditor5'); Loading Loading @@ -743,8 +742,7 @@ public function testFilterHtmlAllowedGlobalAttributes(): void { $page->fillField('body[0][value]', '<p dir="ltr" lang="en">Hello World</p><p dir="rtl" lang="ar">مرحبا بالعالم</p>'); $page->pressButton('Save'); $this->createNewTextFormat($page, $assert_session); $this->saveNewTextFormat($page, $assert_session); $this->addNewTextFormat(); $this->drupalGet('node/1/edit'); $page->selectFieldOption('body[0][format]', 'ckeditor5'); Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php +27 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,10 @@ namespace Drupal\Tests\ckeditor5\FunctionalJavascript; use Behat\Mink\Element\TraversableElement; use Drupal\editor\Entity\Editor; use Drupal\filter\Entity\FilterFormat; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\user\RoleInterface; // cspell:ignore esque Loading Loading @@ -48,9 +51,30 @@ protected function setUp(): void { /** * Add and save a new text format using CKEditor 5. */ public function addNewTextFormat($page, $assert_session, $name = 'ckeditor5') { $this->createNewTextFormat($page, $assert_session, $name); $this->saveNewTextFormat($page, $assert_session); protected function addNewTextFormat($name = 'ckeditor5'): void { FilterFormat::create([ 'format' => $name, 'roles' => [RoleInterface::AUTHENTICATED_ID], 'name' => $name, 'filters' => [ 'filter_html' => [ 'status' => TRUE, 'settings' => [ 'allowed_html' => '<br> <p> <h2> <h3> <h4> <h5> <h6> <strong> <em>', ], ], 'filter_align' => ['status' => TRUE], 'filter_caption' => ['status' => TRUE], ], ])->save(); Editor::create([ 'editor' => $name, 'format' => $name, 'image_upload' => [ 'status' => FALSE, ], ])->save(); } /** Loading