3 namespace Drupal\FunctionalJavascriptTests\Dialog;
5 use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
8 * Tests the JavaScript functionality of the dialog position.
12 class DialogPositionTest extends JavascriptTestBase {
17 public static $modules = ['block'];
20 * Tests if the dialog UI works properly with block layout page.
22 public function testDialogOpenAndClose() {
23 $admin_user = $this->drupalCreateUser(['administer blocks']);
24 $this->drupalLogin($admin_user);
25 $this->drupalGet('admin/structure/block');
26 $session = $this->getSession();
27 $assert_session = $this->assertSession();
28 $page = $session->getPage();
30 // Open the dialog using the place block link.
31 $placeBlockLink = $page->findLink('Place block');
32 $this->assertTrue($placeBlockLink->isVisible(), 'Place block button exists.');
33 $placeBlockLink->click();
34 $assert_session->assertWaitOnAjaxRequest();
35 $dialog = $page->find('css', '.ui-dialog');
36 $this->assertTrue($dialog->isVisible(), 'Dialog is opened after clicking the Place block button.');
38 // Close the dialog again.
39 $closeButton = $page->find('css', '.ui-dialog-titlebar-close');
40 $closeButton->click();
41 $assert_session->assertWaitOnAjaxRequest();
42 $dialog = $page->find('css', '.ui-dialog');
43 $this->assertNull($dialog, 'Dialog is closed after clicking the close button.');
45 // Resize the window. The test should pass after waiting for Javascript to
46 // finish as no Javascript errors should have been triggered. If there were
47 // javascript errors the test will fail on that.
48 $session->resizeWindow(625, 625);
49 $assert_session->assertWaitOnAjaxRequest();