MediaBrowserEmbedCodeWidgetTest.php in Lightning Media 8.3
File
tests/src/FunctionalJavascript/MediaBrowserEmbedCodeWidgetTest.php
View source
<?php
namespace Drupal\Tests\lightning_media\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class MediaBrowserEmbedCodeWidgetTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'lightning_media_video',
];
public function testErrorMessages() {
$account = $this
->drupalCreateUser([
'access media_browser entity browser pages',
'create media',
]);
$this
->drupalLogin($account);
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('/entity-browser/modal/media_browser');
$page
->clickLink('Create embed');
$page
->fillField('input', 'Foo');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->fieldNotExists('Bundle');
$page
->fillField('input', '');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->fieldNotExists('Bundle');
$assert_session
->elementNotExists('css', '[role="alert"]');
$page
->fillField('input', 'https://www.youtube.com/watch?v=zQ1_IbFFbzA');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->fieldNotExists('Bundle');
$assert_session
->elementNotExists('css', '[role="alert"]');
$page
->fillField('input', 'Bar');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->fieldNotExists('Bundle');
$assert_session
->elementTextContains('css', '[role="alert"]', "Input did not match any media types: 'Bar'");
}
public function assertSession($name = NULL) {
return new WebDriverWebAssert($this
->getSession($name), $this->baseUrl);
}
}