public function MediaGalleryModifyTest::testOrderChange in Thunder 8.3
Same name and namespace in other branches
- 8.5 tests/src/FunctionalJavascript/MediaGalleryModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaGalleryModifyTest::testOrderChange()
- 8.2 tests/src/FunctionalJavascript/MediaGalleryModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaGalleryModifyTest::testOrderChange()
- 8.4 tests/src/FunctionalJavascript/MediaGalleryModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaGalleryModifyTest::testOrderChange()
- 6.2.x tests/src/FunctionalJavascript/MediaGalleryModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaGalleryModifyTest::testOrderChange()
- 6.0.x tests/src/FunctionalJavascript/MediaGalleryModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaGalleryModifyTest::testOrderChange()
- 6.1.x tests/src/FunctionalJavascript/MediaGalleryModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaGalleryModifyTest::testOrderChange()
Test order change for Gallery.
Throws
\Exception
File
- tests/
src/ FunctionalJavascript/ MediaGalleryModifyTest.php, line 20
Class
- MediaGalleryModifyTest
- Tests the Gallery media modification.
Namespace
Drupal\Tests\thunder\FunctionalJavascriptCode
public function testOrderChange() {
$this
->drupalGet("node/7/edit");
$page = $this
->getSession()
->getPage();
$this
->editParagraph($page, 'field_paragraphs', 0);
// Wait for all images to be displayed properly.
$this
->getSession()
->wait(10000, "jQuery('[data-drupal-selector=\"edit-field-paragraphs-0-subform-field-media-0-inline-entity-form-field-media-images-current\"] .media-form__item-widget--image').filter(function() {return jQuery(this).width() === 182;}).length === 5");
$cssSelector = 'div[data-drupal-selector="edit-field-paragraphs-0-subform-field-media-0-inline-entity-form-field-media-images-current"]';
$this
->scrollElementInView($cssSelector . ' > *:nth-child(2)');
$dragElement = $this
->xpath("//div[@data-entity-id='media:8']")[0];
$this
->dragDropElement($dragElement, 300, 0);
$this
->createScreenshot($this
->getScreenshotFolder() . '/MediaGalleryModifyTest_AfterOrderChange_' . date('Ymd_His') . '.png');
$secondElement = $page
->find('xpath', '//div[@data-drupal-selector="edit-field-paragraphs-0-subform-field-media-0-inline-entity-form-field-media-images-current"]/div[2]');
if (empty($secondElement)) {
throw new \Exception('Second element in Gallery is not found');
}
$this
->assertSame('media:8', $secondElement
->getAttribute('data-entity-id'));
$this
->clickSave();
$this
->clickButtonCssSelector($page, '#slick-media-gallery-media-images-default-13-1 button.slick-next');
// Check that, 2nd image is file: 26357237683_0891e46ba5_k.jpg.
$fileNamePosition = $this
->getSession()
->evaluateScript('jQuery(\'#slick-media-gallery-media-images-default-13-1 div.slick-slide:not(.slick-cloned):nth(1) img\').attr(\'src\').indexOf("26357237683_0891e46ba5_k.jpg")');
$this
->assertNotEquals(-1, $fileNamePosition, 'For 2nd image in gallery, used file should be "26357237683_0891e46ba5_k.jpg".');
}