Skip to content

Commit 696d07c

Browse files
committed
Add a plugin to disable the CSS animation for more stable e2e tests (#13769)
1 parent ffdf9d5 commit 696d07c

19 files changed

+24
-83
lines changed

packages/e2e-test-utils/src/activate-plugin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import { visitAdminPage } from './visit-admin-page';
1313
export async function activatePlugin( slug ) {
1414
await switchUserToAdmin();
1515
await visitAdminPage( 'plugins.php' );
16+
const disableLink = await page.$( `tr[data-slug="${ slug }"] .deactivate a` );
17+
if ( disableLink ) {
18+
return;
19+
}
1620
await page.click( `tr[data-slug="${ slug }"] .activate a` );
1721
await page.waitForSelector( `tr[data-slug="${ slug }"] .deactivate a` );
1822
await switchUserToTest();

packages/e2e-test-utils/src/click-on-more-menu-item.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
*/
44
import { first } from 'lodash';
55

6-
/**
7-
* Internal dependencies
8-
*/
9-
import { waitForAnimation } from './wait-for-animation';
10-
116
/**
127
* Clicks on More Menu item, searches for the button with the text provided and clicks it.
138
*
@@ -17,7 +12,6 @@ export async function clickOnMoreMenuItem( buttonLabel ) {
1712
await expect( page ).toClick(
1813
'.edit-post-more-menu [aria-label="Show more tools & options"]'
1914
);
20-
await waitForAnimation();
2115
const moreMenuContainerSelector =
2216
'//*[contains(concat(" ", @class, " "), " edit-post-more-menu__content ")]';
2317
let elementToClick = first( await page.$x(

packages/e2e-test-utils/src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export { toggleScreenOption } from './toggle-screen-option';
4040
export { transformBlockTo } from './transform-block-to';
4141
export { uninstallPlugin } from './uninstall-plugin';
4242
export { visitAdminPage } from './visit-admin-page';
43-
export { waitForAnimation } from './wait-for-animation';
4443
export { waitForWindowDimensions } from './wait-for-window-dimensions';
4544

4645
export * from './mocks';

packages/e2e-test-utils/src/search-for-block.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
/**
2-
* Internal dependencies
3-
*/
4-
import { waitForAnimation } from './wait-for-animation';
5-
61
/**
72
* Search for block in the global inserter
83
*
94
* @param {string} searchTerm The text to search the inserter for.
105
*/
116
export async function searchForBlock( searchTerm ) {
127
await page.click( '.edit-post-header [aria-label="Add block"]' );
13-
await waitForAnimation();
148
// Waiting here is necessary because sometimes the inserter takes more time to
159
// render than Puppeteer takes to complete the 'click' action
1610
await page.waitForSelector( '.editor-inserter__menu' );

packages/e2e-test-utils/src/switch-editor-mode-to.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* Internal dependencies
3-
*/
4-
import { waitForAnimation } from './wait-for-animation';
5-
61
/**
72
* Switches editor mode.
83
*
@@ -12,7 +7,6 @@ export async function switchEditorModeTo( mode ) {
127
await page.click(
138
'.edit-post-more-menu [aria-label="Show more tools & options"]'
149
);
15-
await waitForAnimation();
1610
const [ button ] = await page.$x(
1711
`//button[contains(text(), '${ mode } Editor')]`
1812
);
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* Internal dependencies
3-
*/
4-
import { waitForAnimation } from './wait-for-animation';
5-
61
/**
72
* Converts editor's block type.
83
*
@@ -12,7 +7,6 @@ export async function transformBlockTo( name ) {
127
await page.mouse.move( 200, 300, { steps: 10 } );
138
await page.mouse.move( 250, 350, { steps: 10 } );
149
await page.click( '.editor-block-switcher__toggle' );
15-
await waitForAnimation();
1610
await page.waitForSelector( `.editor-block-types-list__item[aria-label="${ name }"]` );
1711
await page.click( `.editor-block-types-list__item[aria-label="${ name }"]` );
1812
}

packages/e2e-test-utils/src/wait-for-animation.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/e2e-tests/config/setup-test-framework.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
enablePageDialogAccept,
1414
setBrowserViewport,
1515
visitAdminPage,
16+
activatePlugin,
1617
} from '@wordpress/e2e-test-utils';
1718

1819
/**
@@ -154,6 +155,7 @@ beforeAll( async () => {
154155

155156
await trashExistingPosts();
156157
await setupBrowser();
158+
await activatePlugin( 'gutenberg-test-plugin-disables-the-css-animations' );
157159
} );
158160

159161
afterEach( async () => {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Plugin Name: Gutenberg Test Plugin, Disables the CSS animations
4+
* Plugin URI: https://github.com/WordPress/gutenberg
5+
* Author: Gutenberg Team
6+
*
7+
* @package gutenberg-test-disable-animations
8+
*/
9+
10+
/**
11+
* Enqueue CSS stylesheet disabling animations.
12+
*/
13+
function enqueue_disable_animations_stylesheet() {
14+
$custom_css = '* { animation-duration: 1ms !important; }';
15+
wp_add_inline_style( 'wp-components', $custom_css );
16+
}
17+
18+
add_action( 'enqueue_block_editor_assets', 'enqueue_disable_animations_stylesheet' );

packages/e2e-tests/specs/block-deletion.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
getEditedPostContent,
77
createNewPost,
88
pressKeyWithModifier,
9-
waitForAnimation,
109
} from '@wordpress/e2e-test-utils';
1110

1211
const addThreeParagraphsToNewPost = async () => {
@@ -22,7 +21,6 @@ const addThreeParagraphsToNewPost = async () => {
2221

2322
const clickOnBlockSettingsMenuItem = async ( buttonLabel ) => {
2423
await expect( page ).toClick( '.editor-block-settings-menu__toggle' );
25-
await waitForAnimation();
2624
const itemButton = ( await page.$x( `//*[contains(@class, "editor-block-settings-menu__popover")]//button[contains(text(), '${ buttonLabel }')]` ) )[ 0 ];
2725
await itemButton.click();
2826
};

0 commit comments

Comments
 (0)