addNewTextFormat example

'ckeditor5',
    'ckeditor5_test',
  ];

  /** * Tests if CKEditor is properly styled inside an off-canvas dialog. */
  public function testOffCanvasStyles() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    $this->addNewTextFormat($page$assert_session);

    $this->drupalGet('/ckeditor5_test/off_canvas');

    // The "Add Node" link triggers an off-canvas dialog with an add node form     // that includes CKEditor.     $page->clickLink('Add Node');
    $assert_session->waitForElementVisible('css', '#drupal-off-canvas-wrapper');
    $assert_session->assertWaitOnAjaxRequest();

    $styles = $assert_session->elementExists('css', 'style#ckeditor5-off-canvas-reset');
    $this->stringContains('#drupal-off-canvas-wrapper [data-drupal-ck-style-fence]', $styles->getText());

    
$page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    // Add a node with text rendered via the Plain Text format.     $this->drupalGet('node/add');
    $page->fillField('title[0][value]', 'My test content');
    $page->fillField('body[0][value]', '<p>This is test content</p>');
    $page->pressButton('Save');
    $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);

    // Change the node to use the new text format.     $this->drupalGet('node/1/edit');

    $page->selectFieldOption('body[0][format]', 'ckeditor5');
    $this->assertNotEmpty($assert_session->waitForText('Change text format?'));
    $page->pressButton('Continue');
    // Ensure the editor is loaded.     $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
    $page->pressButton('Save');

    
\Drupal::service('theme_handler')->refreshInfo();
  }

  /** * Test the ckeditor_stylesheets warning in the filter UI. * * @dataProvider providerTestWarningFilterUI */
  public function testWarningFilterUi($theme$expected_warning) {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();
    $this->addNewTextFormat($page$assert_session);
    $this->drupalGet('admin/config/content/formats/manage/ckeditor5');

    $assert_session->pageTextNotContains($expected_warning);
    $this->installThemeThatTriggersWarning($theme);
    $this->drupalGet('admin/config/content/formats/manage/ckeditor5');
    $this->assertTrue($assert_session->waitForText($expected_warning));
  }

  /** * Data provider for testWarningFilterUI(). * * @return string[][] * An array with the theme to enable and the warning message to check. */
'media_library',
    'editor_test',
    'ckeditor5_incompatible_filter_test',
  ];

  /** * Confirm settings only trigger AJAX when select value is CKEditor 5. */
  public function testSettingsOnlyFireAjaxWithCkeditor5() {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();
    $this->addNewTextFormat($page$assert_session);
    $this->addNewTextFormat($page$assert_session, 'unicorn');

    $this->drupalGet('admin/config/content/formats/manage/ckeditor5');

    // Enable media embed to trigger an AJAX rebuild.     $this->assertTrue($page->hasUncheckedField('filters[media_embed][status]'));
    $this->assertSame(0, $this->getAjaxResponseCount());
    $page->checkField('filters[media_embed][status]');
    $assert_session->assertWaitOnAjaxRequest();
    $this->assertSame(1, $this->getAjaxResponseCount());

    
Home | Imprint | This part of the site doesn't use cookies.