Skip to content

Commit

Permalink
Migrate RichText e2e tests to Playwright (#53493)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 31, 2023
1 parent 0ecfa2b commit 1170a38
Show file tree
Hide file tree
Showing 6 changed files with 924 additions and 812 deletions.
30 changes: 19 additions & 11 deletions packages/e2e-test-utils-playwright/src/page-utils/press-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import {
} from '@wordpress/keycodes';

let clipboardDataHolder: {
plainText: string;
html: string;
'text/plain': string;
'text/html': string;
'rich-text': string;
} = {
plainText: '',
html: '',
'text/plain': '',
'text/html': '',
'rich-text': '',
};

/**
Expand All @@ -38,11 +40,12 @@ let clipboardDataHolder: {
*/
export function setClipboardData(
this: PageUtils,
{ plainText = '', html = '' }: typeof clipboardDataHolder
{ plainText = '', html = '' }
) {
clipboardDataHolder = {
plainText,
html,
'text/plain': plainText,
'text/html': html,
'rich-text': '',
};
}

Expand All @@ -57,11 +60,15 @@ async function emulateClipboard( page: Page, type: 'copy' | 'cut' | 'paste' ) {
if ( _type === 'paste' ) {
clipboardDataTransfer.setData(
'text/plain',
_clipboardData.plainText
_clipboardData[ 'text/plain' ]
);
clipboardDataTransfer.setData(
'text/html',
_clipboardData.html
_clipboardData[ 'text/html' ]
);
clipboardDataTransfer.setData(
'rich-text',
_clipboardData[ 'rich-text' ]
);
} else {
const selection = canvasDoc.defaultView.getSelection()!;
Expand Down Expand Up @@ -91,8 +98,9 @@ async function emulateClipboard( page: Page, type: 'copy' | 'cut' | 'paste' ) {
);

return {
plainText: clipboardDataTransfer.getData( 'text/plain' ),
html: clipboardDataTransfer.getData( 'text/html' ),
'text/plain': clipboardDataTransfer.getData( 'text/plain' ),
'text/html': clipboardDataTransfer.getData( 'text/html' ),
'rich-text': clipboardDataTransfer.getData( 'rich-text' ),
};
},
[ type, clipboardDataHolder ] as const
Expand Down

This file was deleted.

1 comment on commit 1170a38

@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 1170a38.
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/6041985865
📝 Reported issues:

Please sign in to comment.