Skip to content

Commit

Permalink
Migrate RichText e2e tests to Playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 9, 2023
1 parent a473122 commit 99103eb
Show file tree
Hide file tree
Showing 4 changed files with 845 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.

0 comments on commit 99103eb

Please sign in to comment.