function EntityReferenceWidgetTest::testFocusNotAppliedWithoutSelectionChange
Same name in other branches
- 9 core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EntityReferenceWidgetTest::testFocusNotAppliedWithoutSelectionChange()
- 8.9.x core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EntityReferenceWidgetTest::testFocusNotAppliedWithoutSelectionChange()
- 10 core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EntityReferenceWidgetTest::testFocusNotAppliedWithoutSelectionChange()
Tests that disabled media items don't capture focus on page load.
File
-
core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ EntityReferenceWidgetTest.php, line 77
Class
- EntityReferenceWidgetTest
- Tests the Media library entity reference widget.
Namespace
Drupal\Tests\media_library\FunctionalJavascriptCode
public function testFocusNotAppliedWithoutSelectionChange() : void {
// Create a node with the maximum number of values for the field_twin_media
// field.
$node = $this->drupalCreateNode([
'type' => 'basic_page',
'field_twin_media' => [
$this->mediaItems['Horse'],
$this->mediaItems['Bear'],
],
]);
$this->drupalGet($node->toUrl('edit-form'));
$open_button = $this->assertElementExistsAfterWait('css', '.js-media-library-open-button[name^="field_twin_media"]');
// The open button should be disabled, but not have the
// 'data-disabled-focus' attribute.
$this->assertFalse($open_button->hasAttribute('data-disabled-focus'));
$this->assertTrue($open_button->hasAttribute('disabled'));
// The button should be disabled.
$this->assertJsCondition('jQuery("#field_twin_media-media-library-wrapper .js-media-library-open-button").is(":disabled")');
// The button should not have focus.
$this->assertJsCondition('jQuery("#field_twin_media-media-library-wrapper .js-media-library-open-button").not(":focus")');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.