Chris@17: 'filtered_html', Chris@17: 'name' => 'Filtered HTML', Chris@17: 'weight' => 0, Chris@17: ]); Chris@17: $filtered_html_format->save(); Chris@17: Chris@17: Editor::create([ Chris@17: 'format' => 'filtered_html', Chris@17: 'editor' => 'ckeditor', Chris@17: ])->save(); Chris@17: Chris@17: // Create note type with body field. Chris@17: $node_type = NodeType::create(['type' => 'page', 'name' => 'Page']); Chris@17: $node_type->save(); Chris@17: node_add_body_field($node_type); Chris@17: Chris@17: $account = $this->drupalCreateUser([ Chris@17: 'access content', Chris@17: 'administer nodes', Chris@17: 'edit any page content', Chris@17: 'use text format filtered_html', Chris@17: 'access contextual links', Chris@17: 'access in-place editing', Chris@17: ]); Chris@17: $this->drupalLogin($account); Chris@17: Chris@17: } Chris@17: Chris@17: /** Chris@17: * Tests that quickeditor works correctly for field with CKEditor. Chris@17: */ Chris@17: public function testFieldWithCkeditor() { Chris@17: $body_value = '

Sapere aude

'; Chris@17: $node = Node::create([ Chris@17: 'type' => 'page', Chris@17: 'title' => 'Page node', Chris@17: 'body' => [['value' => $body_value, 'format' => 'filtered_html']], Chris@17: ]); Chris@17: $node->save(); Chris@17: Chris@17: $page = $this->getSession()->getPage(); Chris@17: $assert = $this->assertSession(); Chris@17: Chris@17: $this->drupalGet('node/' . $node->id()); Chris@17: Chris@17: // Wait "Quick edit" button for node. Chris@17: $this->assertSession()->waitForElement('css', '[data-quickedit-entity-id="node/' . $node->id() . '"] .contextual .quickedit'); Chris@17: // Click by "Quick edit". Chris@17: $this->clickContextualLink('[data-quickedit-entity-id="node/' . $node->id() . '"]', 'Quick edit'); Chris@17: // Switch to body field. Chris@17: $page->find('css', '[data-quickedit-field-id="node/' . $node->id() . '/body/en/full"]')->click(); Chris@17: // Wait and click by "Blockquote" button from editor for body field. Chris@17: $this->assertSession()->waitForElementVisible('css', '.cke_button.cke_button__blockquote')->click(); Chris@17: // Wait and click by "Save" button after body field was changed. Chris@17: $this->assertSession()->waitForElementVisible('css', '.quickedit-toolgroup.ops [type="submit"][aria-hidden="false"]')->click(); Chris@17: // Wait until the save occurs and the editor UI disappears. Chris@17: $this->waitForNoElement('.cke_button.cke_button__blockquote'); Chris@17: // Ensure that the changes take effect. Chris@17: $assert->responseMatches("|
\s*$body_value\s*
|"); Chris@17: } Chris@17: Chris@17: /** Chris@17: * Waits for an element to be removed from the page. Chris@17: * Chris@17: * @param string $selector Chris@17: * CSS selector. Chris@17: * @param int $timeout Chris@17: * (optional) Timeout in milliseconds, defaults to 10000. Chris@17: */ Chris@17: protected function waitForNoElement($selector, $timeout = 10000) { Chris@17: $condition = "(typeof jQuery !== 'undefined' && jQuery('$selector').length === 0)"; Chris@17: $this->assertJsCondition($condition, $timeout); Chris@17: } Chris@17: Chris@17: }