diff --git a/packages/block-library/src/embed/util.js b/packages/block-library/src/embed/util.js index 085ea4b22ff8c..9cba9f5036474 100644 --- a/packages/block-library/src/embed/util.js +++ b/packages/block-library/src/embed/util.js @@ -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 ) => { diff --git a/packages/e2e-tests/specs/embedding.test.js b/packages/e2e-tests/specs/embedding.test.js index 3ea51358b14b2..4433531316109 100644 --- a/packages/e2e-tests/specs/embedding.test.js +++ b/packages/e2e-tests/specs/embedding.test.js @@ -9,6 +9,8 @@ import { createJSONResponse, getEditedPostContent, clickButton, + insertBlock, + publishPost, } from '@wordpress/e2e-test-utils'; const MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE = { @@ -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' ); + } ); } );