.../QuickEditIntegrationTest.php | 67 +++++++++++++++++++++- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/core/modules/quickedit/tests/src/FunctionalJavaScript/QuickEditIntegrationTest.php b/core/modules/quickedit/tests/src/FunctionalJavaScript/QuickEditIntegrationTest.php index a990f02..9841503 100644 --- a/core/modules/quickedit/tests/src/FunctionalJavaScript/QuickEditIntegrationTest.php +++ b/core/modules/quickedit/tests/src/FunctionalJavaScript/QuickEditIntegrationTest.php @@ -2,11 +2,12 @@ namespace Drupal\Tests\quickedit\FunctionalJavascript; +use Drupal\block_content\Entity\BlockContent; +use Drupal\block_content\Entity\BlockContentType; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\editor\Entity\Editor; use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait; use Drupal\filter\Entity\FilterFormat; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; @@ -20,7 +21,7 @@ class QuickEditIntegrationTest extends QuickEditJavaScriptTestBase { /** * {@inheritdoc} */ - public static $modules = ['node', 'editor', 'ckeditor', 'taxonomy']; + public static $modules = ['node', 'editor', 'ckeditor', 'taxonomy', 'block', 'block_content']; /** * A user with permissions to edit Articles and use Quick Edit. @@ -82,6 +83,9 @@ protected function setUp() { ->setComponent($field_name, ['type' => 'entity_reference_label']) ->save(); + $this->drupalPlaceBlock('page_title_block'); + $this->drupalPlaceBlock('system_main_block'); + // Log in as a content author who can use Quick Edit and edit Articles. $this->contentAuthorUser = $this->drupalCreateUser([ 'access contextual links', @@ -92,6 +96,7 @@ protected function setUp() { 'edit any article content', 'use text format some_format', 'edit terms in tags', + 'administer blocks', ]); $this->drupalLogin($this->contentAuthorUser); } @@ -250,6 +255,62 @@ public function testArticleNode() { ]); } - // @todo test custom block + /** + * Tests if a custom can be in-place edited with Quick Edit. + */ + public function testCustomBlock() { + $block_content_type = BlockContentType::create(array( + 'id' => 'basic', + 'label' => 'basic', + 'revision' => FALSE + )); + $block_content_type->save(); + block_content_add_body_field($block_content_type->id()); + + $block_content = BlockContent::create([ + 'info' => 'Llama', + 'type' => 'basic', + 'body' => [ + 'value' => 'The name "llama" was adopted by European settlers from native Peruvians.', + 'format' => 'some_format', + ], + ]); + $block_content->save(); + $this->drupalPlaceBlock('block_content:' . $block_content->uuid(), [ + 'label' => 'My custom block!', + ]); + + $this->drupalGet(''); + + // Initial state. + $this->awaitQuickEditForEntity('block_content', 1); + $this->assertEntityInstanceStates([ + 'block_content/1[0]' => 'closed', + ]); + + // Start in-place editing of the article node. + $this->startQuickEditViaToolbar('block_content', 1, 0); + $this->assertEntityInstanceStates([ + 'block_content/1[0]' => 'opened', + ]); + $this->assertQuickEditEntityToolbar((string) $block_content->label(), NULL); + $this->assertEntityInstanceFieldStates('block_content', 1, 0, [ + 'block_content/1/body/en/full' => 'candidate', + ]); + + // Click the body field. + $this->click('[data-quickedit-entity-id="block_content/1"] .field--name-body'); + $this->assertQuickEditEntityToolbar((string) $block_content->label(), 'Body'); + $this->assertEntityInstanceFieldStates('block_content', 1, 0, [ + 'block_content/1/body/en/full' => 'active', + ]); + + // Wait for CKEditor to load, then verify it has. + $this->assertJsCondition('CKEDITOR.status === "loaded"'); + $this->assertEntityInstanceFieldMarkup('block_content', 1, 0, [ + 'block_content/1/body/en/full' => '.cke_editable_inline', + ]); + $this->assertSession()->elementExists('css', '#quickedit-entity-toolbar .quickedit-toolgroup.wysiwyg-main > .cke_chrome .cke_top[role="presentation"] .cke_toolbar[role="toolbar"] .cke_toolgroup[role="presentation"] > .cke_button[title="Bold"][role="button"]'); + } }