Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WordPress embed block resolution #14658

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
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
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' );
} );
} );