You are here

public function AutosaveFormTest::testAutosaveInExistingEntity in Thunder 6.1.x

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/Integration/AutosaveFormTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutosaveFormTest::testAutosaveInExistingEntity()
  2. 8.3 tests/src/FunctionalJavascript/Integration/AutosaveFormTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutosaveFormTest::testAutosaveInExistingEntity()
  3. 8.4 tests/src/FunctionalJavascript/Integration/AutosaveFormTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutosaveFormTest::testAutosaveInExistingEntity()
  4. 6.2.x tests/src/FunctionalJavascript/Integration/AutosaveFormTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutosaveFormTest::testAutosaveInExistingEntity()
  5. 6.0.x tests/src/FunctionalJavascript/Integration/AutosaveFormTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutosaveFormTest::testAutosaveInExistingEntity()

Tests the autosave functionality in an existing article.

File

tests/src/FunctionalJavascript/Integration/AutosaveFormTest.php, line 34

Class

AutosaveFormTest
Tests the autosave support for nodes in Thunder.

Namespace

Drupal\Tests\thunder\FunctionalJavascript\Integration

Code

public function testAutosaveInExistingEntity() {
  $node = $this
    ->loadNodeByUuid('36b2e2b2-3df0-43eb-a282-d792b0999c07');
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $page = $this
    ->getSession()
    ->getPage();

  // Make some changes.
  $this
    ->makeFormChanges();

  // Reload the page.
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));

  // Reject the changes.
  $this
    ->pressRejectButton();
  $term = $this
    ->loadTermByUuid('35bdba6e-9b45-472a-8fda-11e7e69de71b');
  $this
    ->assertEquals([
    $term
      ->id(),
  ], $page
    ->findField('field_tags[]')
    ->getValue());
  $this
    ->assertEquals('Come to DrupalCon New Orleans', $page
    ->findField('title[0][value]')
    ->getValue());
  $this
    ->assertEmpty($page
    ->find('css', '.form-item-field-paragraphs-3-subform-field-text-0-value'));

  // Make changes again.
  $this
    ->makeFormChanges();

  // Reload the page.
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $this
    ->pressRestoreButton();
  $this
    ->assertEquals([
    $term
      ->id(),
    '$ID:Tag2',
  ], $page
    ->findField('field_tags[]')
    ->getValue());
  $this
    ->assertEquals('New title', $page
    ->findField('title[0][value]')
    ->getValue());
  $this
    ->assertNotEmpty($page
    ->find('css', '.form-item-field-paragraphs-5-subform-field-text-0-value'));

  // Save the article.
  $this
    ->clickSave();

  // Check some things.
  $this
    ->assertSession()
    ->pageTextContains('New title is scheduled to be published');
  $this
    ->assertSession()
    ->pageTextContains('Awesome quote');
}