function DialogPositionTest::testDialogOpenAndClose

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php \Drupal\FunctionalJavascriptTests\Dialog\DialogPositionTest::testDialogOpenAndClose()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php \Drupal\FunctionalJavascriptTests\Dialog\DialogPositionTest::testDialogOpenAndClose()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php \Drupal\FunctionalJavascriptTests\Dialog\DialogPositionTest::testDialogOpenAndClose()

Tests if the dialog UI works properly with block layout page.

File

core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php, line 29

Class

DialogPositionTest
Tests the JavaScript functionality of the dialog position.

Namespace

Drupal\FunctionalJavascriptTests\Dialog

Code

public function testDialogOpenAndClose() : void {
    $admin_user = $this->drupalCreateUser([
        'administer blocks',
    ]);
    $this->drupalLogin($admin_user);
    $this->drupalGet('admin/structure/block');
    $session = $this->getSession();
    $assert_session = $this->assertSession();
    $page = $session->getPage();
    // Open the dialog using the place block link.
    $placeBlockLink = $page->findLink('Place block');
    $this->assertTrue($placeBlockLink->isVisible(), 'Place block button exists.');
    $placeBlockLink->click();
    $assert_session->assertWaitOnAjaxRequest();
    $dialog = $page->find('css', '.ui-dialog');
    $this->assertTrue($dialog->isVisible(), 'Dialog is opened after clicking the Place block button.');
    // Close the dialog again.
    $closeButton = $page->find('css', '.ui-dialog-titlebar-close');
    $closeButton->click();
    $dialog = $page->find('css', '.ui-dialog');
    $this->assertNull($dialog, 'Dialog is closed after clicking the close button.');
    // Resize the window. The test should pass after waiting for JavaScript to
    // finish as no Javascript errors should have been triggered. If there were
    // javascript errors the test will fail on that.
    $session->resizeWindow(625, 625);
    usleep(5000);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.