$session->
executeScript("jQuery('[data-media-library-widget-value=\"field_unlimited_media\"]').val('1,2,{
$unpublished_media->
id()}')"
);
$session->
executeScript("jQuery('[data-media-library-widget-update=\"field_unlimited_media\"]').trigger('mousedown')"
);
$this->
assertElementExistsAfterWait('css', '.js-media-library-item'
);
// Assert the published items are selected and the unpublished item is not
// selected.
$assert_session->
pageTextContains('Horse'
);
$assert_session->
pageTextContains('Bear'
);
$assert_session->
pageTextNotContains('Mosquito'
);
$this->
drupalLogout();
$role = Role::
load(RoleInterface::ANONYMOUS_ID
);
$role->
revokePermission('view media'
);
$role->
save();
// Create a working state.
$allowed_types =
['type_one', 'type_two', 'type_three', 'type_four'
];
// The opener parameters are not relevant to the test, but the opener
// expects them to be there or it will deny access.
$state = MediaLibraryState::
create('media_library.opener.field_widget',
$allowed_types, 'type_three', 2,
[ 'entity_type_id' => 'node',
'bundle' => 'basic_page',
'field_name' => 'field_unlimited_media',
]);