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
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,34 @@ describe( 'WP Editor Meta Boxes', () => {
await deactivatePlugin( 'gutenberg-test-plugin-wp-editor-meta-box' );
} );

// Wait for the meta box's TinyMCE instance to finish initializing.
const waitForTinyMCE = () =>
page.waitForFunction( () => {
const editor =
window.tinyMCE && window.tinyMCE.get( 'test_tinymce_id' );
return editor && editor.initialized;
} );

it( 'Should save the changes', async () => {
// Add title to enable valid non-empty post save.
await page.type( '.editor-post-title__input', 'Hello Meta' );

// Type something
/*
* Switch TinyMCE to Text mode, first waiting for it to initialize,
* because otherwise it will flip back to Visual mode once initialized.
*/
await waitForTinyMCE();
await expect( page ).toClick( '#test_tinymce_id-html' );

// Type something in the TinyMCE Text mode textarea.
await page.type( '#test_tinymce_id', 'Typing in a metabox' );

/*
* Switch TinyMCE back to Visual mode, waiting for it to re-initialize
* so the editor has settled before the post is published.
*/
await page.click( '#test_tinymce_id-tmce' );
await waitForTinyMCE();

await publishPost();

Expand Down
Loading