...sValidationTest.php => ConfigurationUiTest.php} | 65 +++++----------------- 1 file changed, 13 insertions(+), 52 deletions(-) diff --git a/tests/src/FunctionalJavascript/FormatsValidationTest.php b/tests/src/FunctionalJavascript/ConfigurationUiTest.php similarity index 53% rename from tests/src/FunctionalJavascript/FormatsValidationTest.php rename to tests/src/FunctionalJavascript/ConfigurationUiTest.php index 65d8c78..2244a60 100644 --- a/tests/src/FunctionalJavascript/FormatsValidationTest.php +++ b/tests/src/FunctionalJavascript/ConfigurationUiTest.php @@ -6,31 +6,20 @@ use Drupal\editor\Entity\Editor; use Drupal\filter\Entity\FilterFormat; /** - * Tests ckeditor integration. + * Tests text format & text editor configuration UI validation. * * @group entity_embed */ -class FormatsValidationTest extends EntityEmbedTestBase { +class ConfigurationUiTest extends EntityEmbedTestBase { /** * {@inheritdoc} */ protected static $modules = [ - 'field_ui', - 'node', 'ckeditor', - 'views', 'entity_embed', - 'entity_embed_test', ]; - /** - * The test button. - * - * @var Drupal\embed\Entity\EmbedButton - */ - protected $button; - /** * The test administrative user. * @@ -38,79 +27,51 @@ class FormatsValidationTest extends EntityEmbedTestBase { */ protected $adminUser; - /** - * A test node to be used for embedding. - * - * @var \Drupal\node\NodeInterface - */ - protected $node; - /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - // Create a page content type. - $this->drupalCreateContentType([ - 'type' => 'page', - 'name' => 'Basic page', - ]); - $this->adminUser = $this->drupalCreateUser([ - 'access administration pages', 'administer filters', - 'administer display modes', - 'administer embed buttons', - 'administer site configuration', - 'administer display modes', - 'administer content types', - 'administer node display', - 'access content', - 'create page content', - 'edit own page content', ]); $this->drupalLogin($this->adminUser); } /** - * Test integration with Filter and Editor form validation. + * Test integration with Filter and Text Editor form validation. */ - public function testFormatsValidation() { + public function testValidationWhenAdding() { $this->drupalGet('admin/config/content/formats/add'); + // Enable the `filter_html` and `entity_embed` filters, and select CKEditor + // as the text editor. $page = $this->getSession()->getPage(); - $page->fillField('name', 'Test Format'); - - $page->checkField('filters[filter_html][status]'); $page->checkField('filters[entity_embed][status]'); $page->selectFieldOption('editor[editor]', 'ckeditor'); - $page->waitFor(10, function () use ($page) { - return $page->hasField('filters[filter_html][status]'); - }); - $page->checkField('filters[filter_html][status]'); - $page->checkField('filters[entity_embed][status]'); + // Verify that after dragging the Entity Embed CKEditor plugin button into + // the active toolbar, the tag is allowed, as well as some + // attributes. $target = $this->assertSession()->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'); - $buttonElement = $this->assertSession()->elementExists('xpath', '//li[@data-drupal-ckeditor-button-name="test_media_entity_embed"]'); - $buttonElement->dragTo($target); + $button_element = $this->assertSession()->elementExists('xpath', '//li[@data-drupal-ckeditor-button-name="test_media_entity_embed"]'); + $button_element->dragTo($target); - // Verify the tag is not yet allowed. + // Unfortunately the tag is not yet allowed due to + // https://www.drupal.org/project/drupal/issues/2763075. $allowed_html = $this->assertSession()->fieldExists('filters[filter_html][settings][allowed_html]')->getValue(); $this->assertNotContains('drupal-entity', $allowed_html); $this->assertSession()->buttonExists('Save configuration')->press(); - $page->fillField('format', 'test_format'); - $this->assertSession()->buttonExists('Save configuration')->press(); $this->assertSession()->pageTextNotContains('Added text format Test Format.'); $this->assertSession()->pageTextContains('The Media Entity Embed button requires among the allowed HTML tags.'); - } }