diff --git a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php index 9f10db4..b815be3 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php +++ b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php @@ -6,7 +6,6 @@ use Drupal\Core\Ajax\AlertCommand; use Drupal\Core\Ajax\CloseDialogCommand; use Drupal\Core\Ajax\HtmlCommand; -use Drupal\Core\EventSubscriber\MainContentViewSubscriber; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\Request; diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxThemeTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxThemeTest.php index c7b125b..565fbb7 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxThemeTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxThemeTest.php @@ -2,14 +2,14 @@ namespace Drupal\FunctionalJavascriptTests\Ajax; -use Drupal\Tests\BrowserTestBase; +use Drupal\FunctionalJavascriptTests\JavascriptTestBase; /** - * Ensures that ajax themes are rendered in the frontend theme. + * Tests that AJAX responses use the current theme. * * @group Ajax */ -class AjaxThemeTest extends BrowserTestBase { +class AjaxThemeTest extends JavascriptTestBase { /** * {@inheritdoc} @@ -17,9 +17,10 @@ class AjaxThemeTest extends BrowserTestBase { public static $modules = ['ajax_test']; public function testAjaxWithAdminRoute() { - \Drupal::service('theme_installer')->install(['seven']); + \Drupal::service('theme_installer')->install(['stable', 'seven']); $theme_config = \Drupal::configFactory()->getEditable('system.theme'); $theme_config->set('admin', 'seven'); + $theme_config->set('default', 'stable'); $theme_config->save(); $account = $this->drupalCreateUser(['view the administration theme']); @@ -27,19 +28,28 @@ public function testAjaxWithAdminRoute() { // First visit the site directly via the URL. This should render it in the // admin theme. - $this->drupalGet('/admin/ajax-test/theme'); + $this->drupalGet('admin/ajax-test/theme'); $assert = $this->assertSession(); $assert->pageTextContains('Current theme: seven'); // Now - $this->drupalGet('/ajax-test/dialog'); + $this->drupalGet('ajax-test/dialog'); $assert->pageTextNotContains('Current theme: stable'); $this->clickLink('Link 8 (ajax)'); + $this->waitForAjaxToFinish(); + file_put_contents('/tmp/foo.png', $this->getSession()->getScreenshot()); + file_put_contents('/tmp/foo.html', $this->getSession()->getPage()->getHtml()); $assert->pageTextContains('Current theme: stable'); $assert->pageTextNotContains('Current theme: seven'); - $this->clickLink('Link 8 (ajax)'); } - + + /** + * Waits for jQuery to become active and animations to complete. + */ + protected function waitForAjaxToFinish() { + $condition = "(0 === jQuery.active && 0 === jQuery(':animated').length)"; + $this->assertJsCondition($condition, 10000); + } }