You are here

public function AutosaveFormTest::testAutosaveInExistingEntity in Thunder 8.4

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. 6.2.x tests/src/FunctionalJavascript/Integration/AutosaveFormTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutosaveFormTest::testAutosaveInExistingEntity()
  4. 6.0.x tests/src/FunctionalJavascript/Integration/AutosaveFormTest.php \Drupal\Tests\thunder\FunctionalJavascript\Integration\AutosaveFormTest::testAutosaveInExistingEntity()
  5. 6.1.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 35

Class

AutosaveFormTest
Tests the autosave support for nodes in Thunder.

Namespace

Drupal\Tests\thunder\FunctionalJavascript\Integration

Code

public function testAutosaveInExistingEntity() {
  $this
    ->drupalGet('node/7/edit');
  $page = $this
    ->getSession()
    ->getPage();

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

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

  // Reject the changes.
  $this
    ->pressRejectButton();
  $this
    ->assertEquals([
    5,
  ], $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-4-subform-field-text-0-value'));

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

  // Reload the page.
  $this
    ->drupalGet('node/7/edit');
  $this
    ->pressRestoreButton();
  $this
    ->assertEquals([
    5,
    '$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-4-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');
}