diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/css/layout_builder_test_css_transitions.test.css b/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/css/layout_builder_test_css_transitions.test.css deleted file mode 100644 index e36e7235277d6b0ab25deb1e4d91209fe71702bf..0000000000000000000000000000000000000000 --- a/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/css/layout_builder_test_css_transitions.test.css +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Remove all transitions for testing. - */ -* { - /* CSS transitions. */ - transition: none !important; -} diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.info.yml b/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.info.yml deleted file mode 100644 index 9bce43b41d91cc9f3e432af231c6b82f1115ce05..0000000000000000000000000000000000000000 --- a/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.info.yml +++ /dev/null @@ -1,7 +0,0 @@ -# @todo Remove this module & its usages in https://www.drupal.org/node/2901792. -name: 'Layout Builder Test Disable Animations' -type: module -description: 'Disables CSS animations for tests ' -package: Testing -version: VERSION -core: 8.x diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.libraries.yml b/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.libraries.yml deleted file mode 100644 index f010cdfb7342227405955dbeadfc6b995d711c5f..0000000000000000000000000000000000000000 --- a/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.libraries.yml +++ /dev/null @@ -1,4 +0,0 @@ -layout_builder.disable_css_transitions: - css: - component: - css/layout_builder_test_css_transitions.test.css: {} diff --git a/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.module b/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.module deleted file mode 100644 index 293910f6d0c325faa758325ceb402ad3b8528403..0000000000000000000000000000000000000000 --- a/core/modules/layout_builder/tests/modules/layout_builder_test_css_transitions/layout_builder_test_css_transitions.module +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -/** - * @file - * Attaches CSS to disable animations. - * - * CSS animations cause intermittent errors in some tests. - */ - -/** - * Implements hook_page_attachments(). - */ -function layout_builder_test_css_transitions_page_attachments(array &$attachments) { - // Unconditionally attach an asset to the page. - $attachments['#attached']['library'][] = 'layout_builder_test_css_transitions/layout_builder.disable_css_transitions'; -} diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFormMessagesTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFormMessagesTest.php index f8e01d2af98c906385eee7ddf8c40af168e04fb2..6c977c34e39ef840c78240efc86fba03c54b937c 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFormMessagesTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFormMessagesTest.php @@ -38,6 +38,9 @@ protected function setUp() { * Tests that validation messages are shown on the block form. */ public function testValidationMessage() { + // @todo Work out why this fixes random fails in this test. + // https://www.drupal.org/project/drupal/issues/3055982 + $this->getSession()->resizeWindow(800, 1000); $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); @@ -67,6 +70,7 @@ public function testValidationMessage() { $page->pressButton('Add block'); $block_css_locator = '#layout-builder .block-system-powered-by-block'; $this->assertNotEmpty($assert_session->waitForElementVisible('css', $block_css_locator)); + $this->waitForNoElement('#drupal-off-canvas'); $assert_session->assertWaitOnAjaxRequest(); $this->drupalGet($this->getUrl()); diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php index b6fe178b7967cd7ea908e7a0693c79c22699b885..859805b354580fe73724bc2011970d19f3a7cef0 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php @@ -23,7 +23,6 @@ class ContextualLinksTest extends WebDriverTestBase { 'layout_builder', 'layout_builder_views_test', 'layout_test', - 'layout_builder_test_css_transitions', 'block', 'node', 'contextual', diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php index f18ff580c4c7940071b1be4e34513405bb96b968..a0c14e19a4bad56ac5c9917ed3ac3f7610cb8d5f 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockPrivateFilesTest.php @@ -81,6 +81,9 @@ public function testPrivateFiles() { 'create and edit custom blocks', ])); $this->drupalGet('node/1/layout'); + // @todo Occasionally SQLite has database locks here. Waiting seems to + // resolve it. https://www.drupal.org/project/drupal/issues/3055983 + $assert_session->assertWaitOnAjaxRequest(); $file = $this->createPrivateFile('drupal.txt'); $file_real_path = $this->fileSystem->realpath($file->getFileUri()); diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php index eb06364b3fee9f4c8ba31ade208cef0b70452c37..d7a05a7c70156d8fc61bf92b089a468378a38d9d 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php @@ -31,7 +31,6 @@ class LayoutBuilderDisableInteractionsTest extends WebDriverTestBase { 'node', 'search', 'contextual', - 'layout_builder_test_css_transitions', ]; /** @@ -313,13 +312,8 @@ protected function movePointerTo($selector) { * @todo: Remove after https://www.drupal.org/project/drupal/issues/2892440 */ public function assertNoElementAfterWait($selector, $timeout = 10000, $message = '') { - $page = $this->getSession()->getPage(); - if ($message === '') { - $message = "Element '$selector' was not on the page after wait."; - } - $this->assertTrue($page->waitFor($timeout / 1000, function () use ($page, $selector) { - return empty($page->find('css', $selector)); - }), $message); + $condition = "(typeof jQuery !== 'undefined' && jQuery('$selector').length === 0)"; + $this->assertJsCondition($condition, $timeout, $message); } } diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php index 4609aa4d661bcc1db1be0b3242ca36b35bb350ca..0f85fcc5b4897a2d718e00ed8c9a8bdd8ea3efd1 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php @@ -26,7 +26,6 @@ class LayoutBuilderQuickEditTest extends QuickEditJavascriptTestBase { public static $modules = [ 'node', 'layout_builder', - 'layout_builder_test_css_transitions', ]; /** diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php index 0540296540754c70899ae584614ab6308be10728..d2f94920a2fc1ac7b39bbd475a2ef3530ddf6735 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php @@ -29,7 +29,6 @@ class LayoutBuilderUiTest extends WebDriverTestBase { 'block_content', 'contextual', 'views', - 'layout_builder_test_css_transitions', ]; /** diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/TestMultiWidthLayoutsTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/TestMultiWidthLayoutsTest.php index 86b3e3de866f82e3dbb661e55b458c23d3bda3ae..996170128ad631c308af891397b1ff86310a34d4 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/TestMultiWidthLayoutsTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/TestMultiWidthLayoutsTest.php @@ -20,7 +20,6 @@ class TestMultiWidthLayoutsTest extends WebDriverTestBase { public static $modules = [ 'layout_builder', - 'layout_builder_test_css_transitions', 'block', 'node', ]; diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php index 6f79ed965e4c953b575b84808d6a13c99366ba30..64c957df04bbb6564bf8dd14afe20da9322a79a6 100644 --- a/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php +++ b/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php @@ -1052,6 +1052,10 @@ public function testWidgetUpload() { $page->uncheckField("Select $existing_media_name"); $page->fillField('Alternative text', $this->randomString()); $assert_session->hiddenFieldValueEquals('current_selection', ''); + // Close the details element so that clicking the Save and select works. + // @todo Fix dialog or test so this is not necessary to prevent random + // fails. https://www.drupal.org/project/drupal/issues/3055648 + $this->click('details.media-library-add-form__selected-media summary'); $assert_session->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Save and select'); $assert_session->assertWaitOnAjaxRequest(); $media_items = Media::loadMultiple(); @@ -1325,6 +1329,10 @@ public function testWidgetOEmbed() { $assert_session->checkboxChecked("Select $vimeo_title", $selection_area); $page->uncheckField("Select $vimeo_title"); $assert_session->hiddenFieldValueEquals('current_selection', ''); + // Close the details element so that clicking the Save and select works. + // @todo Fix dialog or test so this is not necessary to prevent random + // fails. https://www.drupal.org/project/drupal/issues/3055648 + $this->click('details.media-library-add-form__selected-media summary'); $assert_session->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Save and select'); $assert_session->assertWaitOnAjaxRequest(); $media_items = Media::loadMultiple(); diff --git a/core/modules/settings_tray/tests/modules/settings_tray_test_css/css/css_fix.theme.css b/core/modules/settings_tray/tests/modules/settings_tray_test_css/css/css_fix.theme.css index e07c95194e7b5ac71b1397032e256cd5f57eccf6..58ef85ec6a9e70ccf3e28374e505f7b02a96143d 100644 --- a/core/modules/settings_tray/tests/modules/settings_tray_test_css/css/css_fix.theme.css +++ b/core/modules/settings_tray/tests/modules/settings_tray_test_css/css/css_fix.theme.css @@ -2,26 +2,3 @@ .dialog-off-canvas-main-canvas.js-settings-tray-edit-mode input { pointer-events: inherit !important; } -/** - * Remove all transitions for testing. - */ -* { - /* CSS transitions. */ - -o-transition-property: none !important; - -moz-transition-property: none !important; - -ms-transition-property: none !important; - -webkit-transition-property: none !important; - transition-property: none !important; - /* CSS transforms. */ - -o-transform: none !important; - -moz-transform: none !important; - -ms-transform: none !important; - -webkit-transform: none !important; - transform: none !important; - /* CSS animations. */ - -webkit-animation: none !important; - -moz-animation: none !important; - -o-animation: none !important; - -ms-animation: none !important; - animation: none !important; -} diff --git a/core/modules/system/tests/modules/css_disable_transitions_test/css/disable_transitions.theme.css b/core/modules/system/tests/modules/css_disable_transitions_test/css/disable_transitions.theme.css new file mode 100644 index 0000000000000000000000000000000000000000..9307437a87f513730bab71dd19787534578be3b0 --- /dev/null +++ b/core/modules/system/tests/modules/css_disable_transitions_test/css/disable_transitions.theme.css @@ -0,0 +1,36 @@ +/** + * Remove CSS animation effects that can cause random test failures. + */ +* { + /* CSS transitions. */ + -o-transition: none !important; + -moz-transition: none !important; + -ms-transition: none !important; + -webkit-transition: none !important; + transition: none !important; + -o-transition-property: none !important; + -moz-transition-property: none !important; + -ms-transition-property: none !important; + -webkit-transition-property: none !important; + transition-property: none !important; + /* CSS transforms. */ + -o-transform: none !important; + -moz-transform: none !important; + -ms-transform: none !important; + -webkit-transform: none !important; + transform: none !important; + /* CSS animations. */ + -webkit-animation: none !important; + -moz-animation: none !important; + -o-animation: none !important; + -ms-animation: none !important; + animation: none !important; +} + +/** + * Prevent youtube and third party content in iFrames from affecting tests. + */ +iframe.media-oembed-content { + width: 0 !important; + height: 0 !important; +} diff --git a/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.info.yml b/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..436b022dba48da6f538b6f9f1a915499afb0be88 --- /dev/null +++ b/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.info.yml @@ -0,0 +1,6 @@ +name: 'Test disable CSS animations' +type: module +description: 'Disables CSS animations for tests.' +package: Testing +version: VERSION +core: 8.x diff --git a/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.libraries.yml b/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.libraries.yml new file mode 100644 index 0000000000000000000000000000000000000000..b1cb9f56e0df2bc8e6827c6a85d48ac31bf03c4e --- /dev/null +++ b/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.libraries.yml @@ -0,0 +1,7 @@ +testing.css_disable_transitions_test: + version: VERSION + css: + theme: + css/disable_transitions.theme.css: { weight: 100 } + js: + js/disable_transitions.theme.js: {} diff --git a/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.module b/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.module new file mode 100644 index 0000000000000000000000000000000000000000..4b915f3f345c91603fe599ac47b8c74a2e6e266e --- /dev/null +++ b/core/modules/system/tests/modules/css_disable_transitions_test/css_disable_transitions_test.module @@ -0,0 +1,14 @@ +<?php + +/** + * @file + * Helper module for disabling animations in tests. + */ + +/** + * Implements hook_page_attachments(). + */ +function css_disable_transitions_test_page_attachments(array &$attachments) { + // Unconditionally attach an asset to the page. + $attachments['#attached']['library'][] = 'css_disable_transitions_test/testing.css_disable_transitions_test'; +} diff --git a/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.es6.js b/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.es6.js new file mode 100644 index 0000000000000000000000000000000000000000..c496f53d1ad8ddac89d746ccd66a39ee05fe784a --- /dev/null +++ b/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.es6.js @@ -0,0 +1,3 @@ +if (window.jQuery) { + jQuery.fx.off = true; +} diff --git a/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.js b/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.js new file mode 100644 index 0000000000000000000000000000000000000000..d8040df5b02f8c43d20d9e34feb1acaaa7229f78 --- /dev/null +++ b/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.js @@ -0,0 +1,10 @@ +/** +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ + +if (window.jQuery) { + jQuery.fx.off = true; +} \ No newline at end of file diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php index 8a9065168fb2275f2c30b54ce008cac4b79ab506..ebb87f8d30c7d5f8c1abcd97858a9c9819435d6e 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php @@ -4,6 +4,7 @@ use Behat\Mink\Exception\DriverException; use Drupal\Tests\BrowserTestBase; +use Symfony\Component\DependencyInjection\ContainerInterface; use Zumba\GastonJS\Exception\DeadClient; use Zumba\Mink\Driver\PhantomJSDriver; @@ -16,6 +17,16 @@ */ abstract class WebDriverTestBase extends BrowserTestBase { + /** + * Disables CSS animations in tests for more reliable testing. + * + * CSS animations are disabled by installing the css_disable_transitions_test + * module. Set to FALSE to test CSS animations. + * + * @var bool + */ + protected $disableCssAnimations = TRUE; + /** * {@inheritdoc} * @@ -61,6 +72,16 @@ protected function initMink() { } } + /** + * {@inheritdoc} + */ + protected function installModulesFromClassProperty(ContainerInterface $container) { + if ($this->disableCssAnimations) { + self::$modules = ['css_disable_transitions_test']; + } + parent::installModulesFromClassProperty($container); + } + /** * {@inheritdoc} */