You are here

public function SoftLengthLimitJavascriptTest::testSoftLengthLimitWithoutStyleSelect in Soft Length Limit 8

Tests that the soft length limit widget works.

File

tests/src/FunctionalJavascript/SoftLengthLimitJavascriptTest.php, line 53

Class

SoftLengthLimitJavascriptTest
Tests soft length limit JavaScript behavior for text fields.

Namespace

Drupal\Tests\soft_length_limit\FunctionalJavascript

Code

public function testSoftLengthLimitWithoutStyleSelect() {
  $this
    ->setupContentType(FALSE);
  $entity = EntityTest::create([
    'type' => 'entity_test',
    'name' => 'Test Soft Length Limit.',
  ]);
  $entity
    ->save();
  $admin = $this
    ->drupalCreateUser([
    'administer entity_test content',
  ]);
  $this
    ->drupalLogin($admin);
  $this
    ->drupalGet($entity
    ->toUrl('edit-form'));
  $page = $this
    ->getSession()
    ->getPage();
  $foo_field = $page
    ->findField('Foo');
  $foo_field
    ->focus();
  $foo_field
    ->setValue('text');
  $tooltip_text = $page
    ->find('css', '.soft-length-limit-tooltip')
    ->getText();
  $foo_field
    ->focus();
  $this
    ->assertEquals('Suggested minimum number of characters is 10, current count is 4. Content limited to 20 characters. Remaining: 16.', $tooltip_text);
}