DialogPositionTest.php 1.8 KB

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