function TableDragTest::testTableDragChangedWarning

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::testTableDragChangedWarning()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::testTableDragChangedWarning()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::testTableDragChangedWarning()

Tests the warning that appears upon making changes to a tabledrag table.

File

core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php, line 301

Class

TableDragTest
Tests draggable table.

Namespace

Drupal\FunctionalJavascriptTests\TableDrag

Code

public function testTableDragChangedWarning() : void {
  $this->drupalGet('tabledrag_test');
  // By default no text is visible.
  $this->assertSession()
    ->pageTextNotContains('You have unsaved changes.');
  // Try to make a non-allowed action, like moving further down the last row.
  // No changes happen, so no message should be shown.
  $this->moveRowWithKeyboard($this->findRowById(5), 'down');
  $this->assertSession()
    ->pageTextNotContains('You have unsaved changes.');
  // Make a change. The message will appear.
  $this->moveRowWithKeyboard($this->findRowById(5), 'right');
  $this->assertSession()
    ->pageTextContainsOnce('You have unsaved changes.');
  // Make another change, the text will stay visible and appear only once.
  $this->moveRowWithKeyboard($this->findRowById(2), 'up');
  $this->assertSession()
    ->pageTextContainsOnce('You have unsaved changes.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.