You are here

public function TableDragTest::testTableDragChangedWarning in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::testTableDragChangedWarning()
  2. 9 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 299

Class

TableDragTest
Tests draggable table.

Namespace

Drupal\FunctionalJavascriptTests\TableDrag

Code

public function testTableDragChangedWarning() {
  $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.');
}