Skip to content
Snippets Groups Projects

Issue #3296289: Only show Summary maxlength options if Summary input is enabled

Open juancec requested to merge issue/maxlength-3296289:3296289-only-show-summary into 2.0.x
Files
2
<?php
namespace Drupal\Tests\maxlength\FunctionalJavascript;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Tests the custom widget support.
*
* @group maxlength
*/
class MaxLenghtSummaryStatusTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'field',
'field_ui',
'maxlength',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
EntityFormDisplay::load('node.article.default')
->setComponent('body', [
'type' => 'text_textarea_with_summary',
'third_party_settings' => [
'maxlength' => ['maxlength_js' => 123, 'maxlength_js_summary' => 123],
],
])
->save();
}
/**
* Tests that a if summary gets enabled.
*/
public function testMaxlengthIfSummaryIsEnabled() {
$this->drupalLogin($this->drupalCreateUser(['administer users',
'administer permissions',
'administer node form display',
'administer node fields',
]));
// Setting up the url to edit the field.
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.body');
$page = $this->getSession()->getPage();
$this->getSession()->wait(1000);
// Uncheck the summary display.
$page->findField('edit-settings-display-summary')->check();
$this->assertSession()->checkboxChecked('edit-settings-display-summary');
$page->pressButton('Save');
// Verify the if fields are there.
$this->drupalGet('admin/structure/types/manage/article/form-display');
$page->pressButton('edit-fields-body-settings-edit');
$this->getSession()->wait(1000);
$this->assertSession()->fieldExists('Summary count down message');
$this->assertSession()->fieldExists('Summary maximum length');
$page->pressButton('Update');
$this->getSession()->wait(1000);
$this->assertSession()->responseContains('Maximum length: 123');
$this->assertSession()->responseContains('Maximum summary length: 123');
}
/**
* Tests that a if summary gets disabled.
*/
public function testMaxlengthIfSummaryIsDisabled() {
$this->drupalLogin($this->drupalCreateUser(['administer users',
'administer permissions',
'administer node form display',
'administer node fields',
]));
// Setting up the url to edit the field.
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.body');
$page = $this->getSession()->getPage();
$this->getSession()->wait(1000);
// Uncheck the summary display.
$page->findField('edit-settings-display-summary')->uncheck();
$this->assertSession()->checkboxNotChecked('edit-settings-display-summary');
$page->pressButton('Save');
// Verify the fields.
$this->drupalGet('admin/structure/types/manage/article/form-display');
$page->pressButton('edit-fields-body-settings-edit');
$this->getSession()->wait(1000);
$this->assertSession()->fieldNotExists('Summary count down message');
$this->assertSession()->fieldNotExists('Summary maximum length');
$page->pressButton('Update');
$this->getSession()->wait(1000);
$this->assertSession()->responseNotContains('Maximum summary length: 123');
}
/**
* Tests that check the widget summary.
*/
public function testMaxlengthIfWidgetSummaryIsDisabled() {
$this->drupalLogin($this->drupalCreateUser(['administer users',
'administer permissions',
'administer node form display',
'administer node fields',
]));
// This test still unfinished the idea is simple when it press update.
// field plugin summary shouldnt have Maximum summary length: 123.
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.body');
$page = $this->getSession()->getPage();
$this->getSession()->wait(1000);
$page->findField('edit-settings-display-summary')->check();
$this->assertSession()->checkboxChecked('edit-settings-display-summary');
$page->pressButton('Save');
$this->drupalGet('admin/structure/types/manage/article/form-display');
$page->pressButton('edit-fields-body-settings-edit');
$this->getSession()->wait(1000);
$this->assertSession()->fieldExists('Summary count down message');
$this->assertSession()->fieldExists('Summary maximum length');
$page->pressButton('Update');
$this->getSession()->wait(1000);
$this->assertSession()->responseContains('Maximum summary length: 123');
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.body');
$page->findField('edit-settings-display-summary')->uncheck();
$this->assertSession()->checkboxNotChecked('edit-settings-display-summary');
$page->pressButton('Save');
$this->drupalGet('admin/structure/types/manage/article/form-display');
$page->pressButton('edit-fields-body-settings-edit');
$this->getSession()->wait(1000);
$this->assertSession()->fieldNotExists('Summary count down message');
$this->assertSession()->fieldNotExists('Summary maximum length');
$page->pressButton('Update');
$this->getSession()->wait(1000);
$this->assertSession()->responseNotContains('Maximum summary length: 123');
}
}
Loading