// Assert the same has been added twice and remove the items again.
$this->
waitForElementsCount('css', '.field--name-field-twin-media [data-media-library-item-delta]', 2
);
$assert_session->
hiddenFieldValueEquals('field_twin_media[selection][0][target_id]', 4
);
$assert_session->
hiddenFieldValueEquals('field_twin_media[selection][1][target_id]', 4
);
$wrapper->
pressButton('Remove'
);
$this->
waitForText('Dog has been removed.'
);
$wrapper->
pressButton('Remove'
);
$this->
waitForText('Dog has been removed.'
);
$result =
$wrapper->
waitFor(10,
function D
$wrapper) { /** @var \Behat\Mink\Element\NodeElement $wrapper */
return $wrapper->
findButton('Remove'
) == NULL;
});
$this->
assertTrue($result);
// Assert the selection is persistent in the media library modal, and
// the number of selected items is displayed correctly.
$this->
openMediaLibraryForField('field_twin_media'
);
// Assert the number of selected items is displayed correctly.
$this->
assertSelectedMediaCount('0 of 2 items selected'
);
// Select a media item, assert the hidden selection field contains the ID of
// the selected item.
$checkboxes =
$this->
getCheckboxes();