You are here

public function TableDragTest::testRowWeightSwitch in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::testRowWeightSwitch()

Tests row weight switch.

File

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

Class

TableDragTest
Tests draggable table.

Namespace

Drupal\FunctionalJavascriptTests\TableDrag

Code

public function testRowWeightSwitch() {
  $this->state
    ->set('tabledrag_test_table', array_flip(range(1, 3)));
  $this
    ->drupalGet('tabledrag_test');
  $session = $this
    ->getSession();
  $page = $session
    ->getPage();
  $weight_select1 = $page
    ->findField("table[1][weight]");
  $weight_select2 = $page
    ->findField("table[2][weight]");
  $weight_select3 = $page
    ->findField("table[3][weight]");

  // Check that rows weight selects are hidden.
  $this
    ->assertFalse($weight_select1
    ->isVisible());
  $this
    ->assertFalse($weight_select2
    ->isVisible());
  $this
    ->assertFalse($weight_select3
    ->isVisible());

  // Toggle row weight selects as visible.
  $this
    ->findWeightsToggle('Show row weights')
    ->click();

  // Check that rows weight selects are visible.
  $this
    ->assertTrue($weight_select1
    ->isVisible());
  $this
    ->assertTrue($weight_select2
    ->isVisible());
  $this
    ->assertTrue($weight_select3
    ->isVisible());

  // Toggle row weight selects back to hidden.
  $this
    ->findWeightsToggle('Hide row weights')
    ->click();

  // Check that rows weight selects are hidden again.
  $this
    ->assertFalse($weight_select1
    ->isVisible());
  $this
    ->assertFalse($weight_select2
    ->isVisible());
  $this
    ->assertFalse($weight_select3
    ->isVisible());
}