Skip to content

Commit

Permalink
Fix WordPress embed block resolution (#14658)
Browse files Browse the repository at this point in the history
  • Loading branch information
notnownikki authored Mar 29, 2019
1 parent 4b503ac commit 3214cb4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/block-library/src/embed/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const findBlock = ( url ) => {
};

export const isFromWordPress = ( html ) => {
return includes( html, 'class="wp-embedded-content" data-secret' );
return includes( html, 'class="wp-embedded-content"' );
};

export const getPhotoHtml = ( photo ) => {
Expand Down
25 changes: 25 additions & 0 deletions packages/e2e-tests/specs/embedding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
createJSONResponse,
getEditedPostContent,
clickButton,
insertBlock,
publishPost,
} from '@wordpress/e2e-test-utils';

const MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE = {
Expand Down Expand Up @@ -192,4 +194,27 @@ describe( 'Embedding content', () => {
await clickButton( 'Try again' );
await page.waitForSelector( 'figure.wp-block-embed-twitter' );
} );

it( 'should switch to the WordPress block correctly', async () => {
// This test is to make sure that WordPress embeds are detected correctly,
// because the HTML can vary, and the block is detected by looking for
// classes in the HTML, so we need to flag up if the HTML changes.

// Publish a post to embed.
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Hello there!' );
await publishPost();
const postUrl = await page.$eval( '#inspector-text-control-0', ( el ) => el.value );

// Start a new post, embed the previous post.
await createNewPost();
await clickBlockAppender();
await page.keyboard.type( '/embed' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( postUrl );
await page.keyboard.press( 'Enter' );

// Check the block has become a WordPress block.
await page.waitForSelector( '.wp-block-embed-wordpress' );
} );
} );

0 comments on commit 3214cb4

Please sign in to comment.