public function ColorbuttonTest::testColorbutton in CKEditor Color Button 8
Tests colorbutton.
File
- tests/
src/ FunctionalJavascript/ ColorbuttonTest.php, line 85
Class
- ColorbuttonTest
- Colorbutton tests.
Namespace
Drupal\Tests\colorbutton\FunctionalJavascriptCode
public function testColorbutton() {
// Verify that article are displayed.
$this
->drupalGet('/node/1');
$this
->assertSession()
->pageTextContains('Article colorbutton');
// Verify that the textcolor button is loaded in CKEditor.
$this
->drupalGet('/admin/config/content/formats/manage/full_html');
$this
->assertSession()
->elementExists('css', '.ckeditor-button');
$json_encode = function ($html) {
return trim(Json::encode($html), '"');
};
$markup = $json_encode(file_url_transform_relative(file_create_url('libraries/colorbutton/icons/textcolor.png')));
$this
->assertSession()
->responseContains($markup);
// Asserts color buttons is present in the toolbar.
$this
->drupalGet('/node/1/edit');
$this
->assertSession()
->elementExists('css', '#cke_edit-body-0-value .cke_button__textcolor');
$this
->assertSession()
->elementExists('css', '#cke_edit-body-0-value .cke_button__bgcolor');
// Asserts the cke panel opens when clicking the color button.
$this
->assertSession()
->elementNotExists('css', '.cke_panel');
$this
->click('.cke_button__textcolor');
$this
->assertNotNull($this
->assertSession()
->waitForElement('css', '.cke_panel'));
$this
->assertJsCondition("jQuery('.cke_panel').length > 0");
$this
->assertJsCondition("jQuery('.cke_panel').height() > 100");
$this
->click('.cke_button__bgcolor');
$this
->assertNotNull($this
->assertSession()
->waitForElement('css', '.cke_panel'));
}