$page->checkField('Always show the summary field');
$page->pressButton('Maxlength Settings');
// Assert the maxlength config form.
$this->assertSession()->fieldValueEquals('Summary maximum length',200);
$this->assertSession()->fieldValueEquals('Summary count down message','Summary content limited to @limit characters, remaining: <strong>@remaining</strong> and total @count');
$this->assertSession()->fieldValueEquals('Count down message','Content limited to @limit characters, remaining: <strong>@remaining</strong> and total @count');
// Fill the summary field with more characters than the limit.
$page->fillField('Summary','<strong>Leave blank</strong> to use <u>trimmed value</u> of full text as the summary. Leave blank to use trimmed value of full text as the summary. Extra characters');
// The counter now should show "-17" for the extra characters.
$this->assertSession()->pageTextContainsOnce('Summary content limited to 123 characters, remaining: -17 and total 140');
// Fill the body field with more characters than the limit.
$page->fillField('Body','<b>Lorem ipsum</b> dolor sit amet, <u>consectetur adipiscing</u> elit. Ut accumsan justo non interdum fermentum. Phasellus semper risus eu arcu eleifend dignissim. Class aptent taciti sociosqu ad litora erat curae. Extra characters');
// The counter now should show "-17" for the extra characters.
$this->assertSession()->pageTextContainsOnce('Content limited to 200 characters, remaining: -17 and total 217');
// Fill in the title and assert we can save the node with the extra
// characters, and they are not truncated on edit.
$page->fillField('Title','Article');
$page->pressButton('Save');
// Assert the counters in the form again.
$this->drupalGet('node/1/edit');
$this->assertSession()->pageTextContainsOnce('Summary content limited to 123 characters, remaining: -17 and total 140');
$this->assertSession()->pageTextContainsOnce('Content limited to 200 characters, remaining: -17 and total 217');
// Now set the "Hard limit" option for both of the fields and assert the
// extra characters are truncated and "Extra characters" string is gone.
$this->assertSession()->pageTextContains('Content limited to 123 characters, remaining: 0');
$this->assertSession()->pageTextContains('Content limited to 200 characters, remaining: 0');
$this->assertSession()->pageTextContainsOnce('Summary content limited to 123 characters, remaining: 0 and total 123');
$this->assertSession()->pageTextContainsOnce('Content limited to 200 characters, remaining: 0 and total 200');
$this->assertTrue($page->findField('Summary')->getValue()==='<strong>Leave blank</strong> to use <u>trimmed value</u> of full text as the summary. Leave blank to use trimmed value of full text as the summary.');
$this->assertTrue($page->findField('Body')->getValue()==='<b>Lorem ipsum</b> dolor sit amet, <u>consectetur adipiscing</u> elit. Ut accumsan justo non interdum fermentum. Phasellus semper risus eu arcu eleifend dignissim. Class aptent taciti sociosqu ad litora erat curae.');