Skip to content

Commit

Permalink
Fix e2e tests in dev mode (#62642)
Browse files Browse the repository at this point in the history
* Fix e2e tests in dev mode

* Fix package-lock.json

Co-authored-by: kevin940726 <kevin940726@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
  • Loading branch information
3 people committed Jun 19, 2024
1 parent d86ecdb commit 46a5bde
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 24 deletions.
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions packages/e2e-test-utils-playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
"main": "./build/index.js",
"types": "./build-types",
"dependencies": {
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/url": "file:../url",
"change-case": "^4.1.2",
"form-data": "^4.0.0",
"get-port": "^5.1.1",
Expand Down
48 changes: 48 additions & 0 deletions packages/e2e-test-utils-playwright/src/page-utils/keycodes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* This filed is partially copied from @wordpress/keycodes to keep the package
* (internal-)dependencies free.
*/

/**
* Keycode for ALT key.
*/
export const ALT = 'alt';

/**
* Keycode for CTRL key.
*/
export const CTRL = 'ctrl';

/**
* Keycode for COMMAND key.
*/
export const COMMAND = 'meta';

/**
* Keycode for SHIFT key.
*/
export const SHIFT = 'shift';

/**
* Object that contains functions that return the available modifier
* depending on platform.
*/
export const modifiers: Record<
string,
( _isApple: () => boolean ) => string[]
> = {
primary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),
primaryShift: ( _isApple ) =>
_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],
primaryAlt: ( _isApple ) =>
_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],
secondary: ( _isApple ) =>
_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],
access: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),
ctrl: () => [ CTRL ],
alt: () => [ ALT ],
ctrlShift: () => [ CTRL, SHIFT ],
shift: () => [ SHIFT ],
shiftAlt: () => [ SHIFT, ALT ],
undefined: () => [],
};
11 changes: 1 addition & 10 deletions packages/e2e-test-utils-playwright/src/page-utils/press-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ import type { Page } from '@playwright/test';
* Internal dependencies
*/
import type { PageUtils } from './';

/**
* WordPress dependencies
*/
import {
modifiers as baseModifiers,
SHIFT,
ALT,
CTRL,
} from '@wordpress/keycodes';
import { modifiers as baseModifiers, SHIFT, ALT, CTRL } from './keycodes';

let clipboardDataHolder: {
'text/plain': string;
Expand Down
5 changes: 0 additions & 5 deletions packages/e2e-test-utils-playwright/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,5 @@
"allowJs": true,
"checkJs": false
},
"references": [
{ "path": "../api-fetch" },
{ "path": "../keycodes" },
{ "path": "../url" }
],
"include": [ "src/**/*" ]
}

1 comment on commit 46a5bde

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 46a5bde.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9579119437
📝 Reported issues:

Please sign in to comment.