$this->
assertNotEmpty($assert_session->
waitForElementVisible('css', '.ck-widget.drupal-media img'
));
$assert_session->
elementExists('css', '[data-drupal-media-preview][aria-label="Screaming hairy armadillo"]'
);
$assert_session->
elementContains('css', 'figcaption', ''
);
$assert_session->
elementAttributeContains('css', 'figcaption', 'data-placeholder', 'Enter media caption'
);
// Test if you leave the caption blank, but change another attribute,
// such as the alt text, the editable caption is still there and the edit
// button still exists.
$this->
click('.ck-widget.drupal-media'
);
$this->
assertVisibleBalloon('[aria-label="Drupal Media toolbar"]'
);
// Click the "Override media image alternative text" button.
$this->
getBalloonButton('Override media image alternative text'
)->
click();
$this->
assertVisibleBalloon('.ck-media-alternative-text-form'
);
$alt_override_input =
$page->
find('css', '.ck-balloon-panel .ck-media-alternative-text-form input[type=text]'
);
// Fill in the alt field and submit.
$alt_override_input->
setValue('Gold star for robot boy.'
);
$this->
getBalloonButton('Save'
)->
click();
$this->
assertNotEmpty($assert_session->
waitForElementVisible('css', '.drupal-media img[alt*="Gold star for robot boy."]'
));
$this->
assertEquals('',
$assert_session->
waitForElement('css', '.drupal-media figcaption'
)->
getText());
$assert_session->
elementAttributeContains('css', '.drupal-media figcaption', 'data-placeholder', 'Enter media caption'
);
// Restore caption in saved body value.