$page->
pressButton('Add'
);
// assertWaitOnAjaxRequest() required for input "id" attributes to
// consistently match their label's "for" attribute.
$assert_session->
assertWaitOnAjaxRequest();
$this->
waitForText('The media item has been created but has not yet been saved.'
);
// There is no other selected media and this is not the advanced ui.
// Assert that the Additional selected media element does not appear.
$assert_session->
pageTextNotContains('Additional selected media'
);
$assert_session->
elementNotExists('css', '[data-drupal-selector="edit-selection"]'
);
// Assert the name field contains the remote video title.
$assert_session->
fieldValueEquals('Name',
$youtube_title);
$this->
pressSaveButton();
$this->
waitForText('Add Type Five via URL'
);
// Load the created media item.
$media_items = Media::
loadMultiple();
$added_media =
array_pop($media_items);
// Ensure the media item was saved to the library and automatically
// selected. The added media items should be in the first position of the
// add form.
$assert_session->
pageTextContains('Add or select media'
);
$assert_session->
pageTextContains($youtube_title);
$assert_session->
fieldValueEquals('media_library_select_form[0]',
$added_media->
id());