function QuickEditIntegrationTest::testCustomBlock
Tests if a custom can be in-place edited with Quick Edit.
File
-
core/
modules/ quickedit/ tests/ src/ FunctionalJavascript/ QuickEditIntegrationTest.php, line 273
Class
- QuickEditIntegrationTest
- @group quickedit
Namespace
Drupal\Tests\quickedit\FunctionalJavascriptCode
public function testCustomBlock() {
$block_content_type = BlockContentType::create([
'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(), 'Body');
$this->assertEntityInstanceFieldStates('block_content', 1, 0, [
'block_content/1/body/en/full' => 'highlighted',
]);
// Click the body field.
$this->click('[data-quickedit-entity-id="block_content/1"] .field--name-body');
$assert_session = $this->assertSession();
$assert_session->waitForElement('css', '.quickedit-toolbar-field div[id*="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"]');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.