DialogPositionTest.php 1.7 KB

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