Skip to content
Snippets Groups Projects
Verified Commit 9c5eccee authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3467853 by catch, smustgrave: Use API methods to create filter/editor...

Issue #3467853 by catch, smustgrave: Use API methods to create filter/editor in CKEditor5Test when not explicitly testing the UI

(cherry picked from commit ec27dec3)
parent 66a26058
No related branches found
No related tags found
10 merge requests!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #254220 failed
......@@ -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');
......@@ -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.
......@@ -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.
......
......@@ -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');
......
......@@ -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');
......
......@@ -53,7 +53,7 @@ public function testExistingContent(): void {
$assert_session->responseNotContains('<p>This is test content</p>');
$assert_session->responseContains('&lt;p&gt;This is test content&lt;/p&gt;');
$this->addNewTextFormat($page, $assert_session);
$this->addNewTextFormat();
// Change the node to use the new text format.
$this->drupalGet('node/1/edit');
......@@ -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>');
......@@ -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');
......@@ -740,8 +739,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');
......
......@@ -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
......@@ -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();
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment