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
19 changes: 13 additions & 6 deletions test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,25 @@ test.describe( 'WP Editor Meta Boxes', () => {
await page
.getByRole( 'button', { name: 'Meta Boxes' } )
.click( { position: { x: 0, y: 0 } } );

// Switch to Visual mode and wait for TinyMCE to fully initialize.
// This ensures getSelection() won't return null when TinyMCE tries
// to restore cursor position during subsequent mode switches.
await page.locator( 'role=button[name="Visual"i]' ).click();
// Switch tinymce to Text mode, first waiting for it to initialize
// because otherwise it will flip back to Visual mode once initialized.
await page.locator( '#test_tinymce_id_ifr' ).waitFor();
await page.locator( 'role=button[name="Code"i]' ).click();
await page.waitForFunction(
() => window.tinyMCE?.get( 'test_tinymce_id' )?.initialized
);

// Type something in the tinymce Text mode textarea.
// Switch to Code mode and type into the textarea.
await page.locator( 'role=button[name="Code"i]' ).click();
const metaBoxField = page.locator( '#test_tinymce_id' );
await metaBoxField.type( 'Typing in a metabox' );

// Switch tinymce back to Visual mode.
// Switch back to Visual mode and wait for re-initialization.
await page.locator( 'role=button[name="Visual"i]' ).click();
await page.waitForFunction(
() => window.tinyMCE?.get( 'test_tinymce_id' )?.initialized
);

await editor.publishPost();
await page.reload();
Expand Down
Loading