Chris@16: drupalCreateContentType(['type' => 'page']); Chris@16: Chris@16: $account = $this->drupalCreateUser(['create page content', 'edit own page content']); Chris@16: $this->drupalLogin($account); Chris@16: } Chris@16: Chris@16: /** Chris@16: * Helper to test toggling the summary area. Chris@16: */ Chris@16: protected function assertSummaryToggle() { Chris@16: $this->drupalGet('node/add/page'); Chris@16: $widget = $this->getSession()->getPage()->findById('edit-body-wrapper'); Chris@16: $summary_field = $widget->findField('edit-body-0-summary'); Chris@16: Chris@16: $this->assertEquals(FALSE, $summary_field->isVisible(), 'Summary field is hidden by default.'); Chris@16: $this->assertEquals(FALSE, $widget->hasButton('Hide summary'), 'No Hide summary link by default.'); Chris@16: Chris@16: $widget->pressButton('Edit summary'); Chris@16: $this->assertEquals(FALSE, $widget->hasButton('Edit summary'), 'Edit summary link is removed after clicking.'); Chris@16: $this->assertEquals(TRUE, $summary_field->isVisible(), 'Summary field is shown.'); Chris@16: Chris@16: $widget->pressButton('Hide summary'); Chris@16: $this->assertEquals(FALSE, $widget->hasButton('Hide summary'), 'Hide summary link is removed after clicking.'); Chris@16: $this->assertEquals(FALSE, $summary_field->isVisible(), 'Summary field is hidden again.'); Chris@16: $this->assertEquals(TRUE, $widget->hasButton('Edit summary'), 'Edit summary link is visible again.'); Chris@16: } Chris@16: Chris@16: /** Chris@16: * Tests the textSummary javascript behavior. Chris@16: */ Chris@16: public function testTextSummaryBehavior() { Chris@16: // Test with field defaults. Chris@16: $this->assertSummaryToggle(); Chris@16: Chris@16: // Repeat test with non-empty field description. Chris@16: $body_field = FieldConfig::loadByName('node', 'page', 'body'); Chris@16: $body_field->set('description', 'Text with Summary field description.'); Chris@16: $body_field->save(); Chris@16: Chris@16: $this->assertSummaryToggle(); Chris@16: Chris@16: // Test summary is shown when non-empty. Chris@16: $node = $this->createNode([ Chris@16: 'body' => [ Chris@16: [ Chris@16: 'value' => $this->randomMachineName(32), Chris@16: 'summary' => $this->randomMachineName(32), Chris@16: 'format' => filter_default_format(), Chris@16: ], Chris@16: ], Chris@16: ]); Chris@16: Chris@16: $this->drupalGet('node/' . $node->id() . '/edit'); Chris@16: $page = $this->getSession()->getPage(); Chris@16: $summary_field = $page->findField('edit-body-0-summary'); Chris@16: Chris@16: $this->assertEquals(TRUE, $summary_field->isVisible(), 'Non-empty summary field is shown by default.'); Chris@16: } Chris@16: Chris@16: }