You are here

public function AutofillTest::testAutofill in Thunder 8.5

Same name and namespace in other branches
  1. 8.4 tests/src/FunctionalJavascript/Integration/AutofillTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutofillTest::testAutofill()
  2. 6.2.x tests/src/FunctionalJavascript/Integration/AutofillTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutofillTest::testAutofill()
  3. 6.0.x tests/src/FunctionalJavascript/Integration/AutofillTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutofillTest::testAutofill()
  4. 6.1.x tests/src/FunctionalJavascript/Integration/AutofillTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutofillTest::testAutofill()

Tests the autofill of a new field based on the node title.

File

tests/src/FunctionalJavascript/Integration/AutofillTest.php, line 22

Class

AutofillTest
Tests the autofill support for nodes in Thunder.

Namespace

Drupal\Tests\thunder\FunctionalJavascript\Integration

Code

public function testAutofill() {
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->drupalGet('node/add/article');
  $page
    ->fillField('field_channel', 1);
  $page
    ->fillField('title[0][value]', 'Autofill test title');

  // The autofill field should have the same value as the title.
  $this
    ->assertSession()
    ->fieldValueEquals('field_seo_title[0][value]', 'Autofill test title');
  $page
    ->findButton('Save')
    ->click();

  // After reload meta title should be same as seo_title.
  $this
    ->assertSession()
    ->elementContains('xpath', '//head/title', 'Autofill test title');
  $node = $this
    ->getNodeByTitle('Autofill test title');
  $edit_url = $node
    ->toUrl('edit-form');

  // Open the created node again. When changing the title, the autofill
  // field should change since values are identical.
  $this
    ->drupalGet($edit_url);
  $page
    ->fillField('title[0][value]', 'My adjusted autofill test title');
  $this
    ->assertSession()
    ->fieldValueEquals('field_seo_title[0][value]', 'My adjusted autofill test title');

  // If the autofilled field was manipulated once it should not be autofilled
  // anymore.
  $page
    ->fillField('field_seo_title[0][value]', 'Override seo title');
  $page
    ->fillField('title[0][value]', 'Change title');
  $this
    ->assertSession()
    ->fieldValueEquals('field_seo_title[0][value]', 'Override seo title');
}