JS;
$this->
getSession()->
executeScript($javascript);
// The CKEditor 5 module should refuse to specify styles on tags that cannot
// (yet) be created.
// @see \Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator::checkAllHtmlTagsAreCreatable()
$assert_session->
waitForElement('css', '[role=alert][data-drupal-message-type="error"]:contains("The Style plugin needs another plugin to create <s>, for it to be able to create the following attributes: <s class="redacted">. Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.")'
);
// The entire vertical tab for "Style" settings should be marked up as the
// cause of the error, which means the "Styles" text area in there is marked
// too.
$assert_session->
elementExists('css', '.vertical-tabs__pane[data-ckeditor5-plugin-id="ckeditor5_style"][aria-invalid="true"]'
);
$assert_session->
elementExists('css', '.vertical-tabs__pane[data-ckeditor5-plugin-id="ckeditor5_style"] textarea[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-style-styles"][aria-invalid="true"]'
);
// Attempt to save anyway: the warning should become an error.
$page->
pressButton('Save configuration'
);
$assert_session->
pageTextNotContains('Added text format'
);
$assert_session->
elementExists('css', '[aria-label="Error message"]:contains("The Style plugin needs another plugin to create <s>, for it to be able to create the following attributes: <s class="redacted">. Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.")'
);
// Now, attempt to use a supported non-HTML5 tag.
// @see \Drupal\ckeditor5\Plugin\Validation\Constraint\StyleSensibleElementConstraintValidator
$javascript = <<<JS
const allowedTags = document.querySelector('[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-style-styles"]');
allowedTags.value = 'drupal-media.sensational|Sensational media';
allowedTags.dispatchEvent(new Event('change'));