$weight_select1 =
$page->
findField("table[book-admin-{
$page1->
id()}][weight]"
);
$weight_select2 =
$page->
findField("table[book-admin-{
$page2->
id()}][weight]"
);
// Check that rows weight selects are hidden.
$this->
assertFalse($weight_select1->
isVisible());
$this->
assertFalse($weight_select2->
isVisible());
// Check that '2nd page' row is heavier than '1st page' row.
$this->
assertGreaterThan($weight_select1->
getValue(),
$weight_select2->
getValue());
// Check that '1st page' precedes the '2nd page'.
$this->
assertOrderInPage(['1st page', '2nd page'
]);
// Check that the 'unsaved changes' text is not present in the message area.
$this->
assertSession()->
pageTextNotContains('You have unsaved changes.'
);
// Drag and drop the '1st page' row over the '2nd page' row.
// @todo Test also the reverse, '2nd page' over '1st page', when
// https://www.drupal.org/node/2769825 is fixed.
// @see https://www.drupal.org/node/2769825
$dragged =
$this->
xpath("//tr[@data-drupal-selector='edit-table-book-admin-{
$page1->
id()}']//a[@class='tabledrag-handle']"
)[0
];
$target =
$this->
xpath("//tr[@data-drupal-selector='edit-table-book-admin-{
$page2->
id()}']//a[@class='tabledrag-handle']"
)[0
];
$dragged->
dragTo($target);