public function EntityReferenceWidgetTest::testAddAfterReordering in Drupal 10
Tests that order is correct after re-order and adding another item.
File
- core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ EntityReferenceWidgetTest.php, line 540
Class
- EntityReferenceWidgetTest
- Tests the Media library entity reference widget.
Namespace
Drupal\Tests\media_library\FunctionalJavascriptCode
public function testAddAfterReordering() : void {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalGet('node/add/basic_page');
$page
->fillField('Title', 'My page');
$this
->openMediaLibraryForField('field_unlimited_media');
$page
->checkField('Select Dog');
$page
->checkField('Select Cat');
// Order: Dog - Cat.
$this
->pressInsertSelected('Added 2 media items.');
// Change positions.
// Order: Cat - Dog.
$this
->sortableAfter('[data-media-library-item-delta="0"]', '[data-media-library-item-delta="1"]', '.js-media-library-selection');
$this
->openMediaLibraryForField('field_unlimited_media');
$this
->selectMediaItem(2);
// Order: Cat - Dog - Bear.
$this
->pressInsertSelected('Added one media item.');
$page
->pressButton('Save');
$assert_session
->elementTextContains('css', '.field--name-field-unlimited-media > .field__items > .field__item:first-child', 'Cat');
$assert_session
->elementTextContains('css', '.field--name-field-unlimited-media > .field__items > .field__item:last-child', 'Bear');
}