Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions test/e2e/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ const {
*/
const MOD_KEY = process.platform === 'darwin' ? 'Meta' : 'Control';

/**
* Regular expression matching zero-width space characters.
*
* @type {RegExp}
*/
const REGEXP_ZWSP = /[\u200B\u200C\u200D\uFEFF]/;

function getUrl( WPPath, query = '' ) {
const url = new URL( WP_BASE_URL );

Expand Down Expand Up @@ -78,6 +85,12 @@ export async function getHTMLFromCodeEditor() {
await switchToEditor( 'Code' );
const textEditorContent = await page.$eval( '.editor-post-text-editor', ( element ) => element.value );
await switchToEditor( 'Visual' );

// Globally guard against zero-width characters.
if ( REGEXP_ZWSP.test( textEditorContent ) ) {
throw new Error( 'Unexpected zero-width space character in editor content.' );
}

return textEditorContent;
}

Expand Down