public function MediaImageFieldTest::test in Lightning Media 8.2
Tests clearing an image field on an existing media item.
File
- tests/
src/ ExistingSiteJavascript/ MediaImageFieldTest.php, line 61
Class
- MediaImageFieldTest
- @group lightning @group lightning_media
Namespace
Drupal\Tests\lightning_media\ExistingSiteJavascriptCode
public function test() {
$account = $this
->createUser([
'create media',
'update media',
]);
$this
->assertNotEmpty($account->passRaw);
$this
->visit('/user/login');
$assert = new JSWebAssert($this
->getSession());
$assert
->fieldExists('name')
->setValue($account
->getAccountName());
$assert
->fieldExists('pass')
->setValue($account->passRaw);
$assert
->buttonExists('Log in')
->press();
$this->name = $this
->randomString();
$this
->visit('/media/add/video');
$assert
->fieldExists('Name')
->setValue($this->name);
$assert
->fieldExists('Video URL')
->setValue('https://www.youtube.com/watch?v=z9qY4VUZzcY');
$assert
->assertWaitOnAjaxRequest();
$assert
->fieldExists('Image')
->attachFile('/Users/phen/lightning-media/tests/files/test.jpg');
$assert
->assertWaitOnAjaxRequest();
$assert
->fieldExists('Alternative text')
->setValue('This is a beauty.');
$assert
->buttonExists('Save')
->press();
$assert
->elementExists('named', [
'link',
'Edit',
])
->click();
$assert
->buttonExists('field_image_0_remove_button')
->press();
$assert
->assertWaitOnAjaxRequest();
// Ensure that the widget has actually been cleared. This test was written
// because the AJAX operation would fail due to a 500 error at the server,
// which would prevent the widget from being cleared.
$assert
->buttonNotExists('field_image_0_remove_button');
}