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