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

Test transform from media to embed blocks #13997

Merged
merged 3 commits into from
Apr 18, 2019
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
55 changes: 55 additions & 0 deletions packages/e2e-tests/specs/embedding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ const MOCK_EMBED_VIDEO_SUCCESS_RESPONSE = {
version: '1.0',
};

const MOCK_EMBED_AUDIO_SUCCESS_RESPONSE = {
url: 'https://soundcloud.com/a-boogie-wit-da-hoodie/swervin',
html: '<iframe width="16" height="9"></iframe>',
type: 'audio',
provider_name: 'SoundCloud',
provider_url: 'https://soundcloud.com',
version: '1.0',
};

const MOCK_EMBED_IMAGE_SUCCESS_RESPONSE = {
url: 'https://www.instagram.com/p/Bvl97o2AK6x/',
html: '<iframe width="16" height="9"></iframe>',
type: 'video',
provider_name: 'Instagram',
provider_url: 'https://www.instagram.com',
version: '1.0',
};

const MOCK_BAD_EMBED_PROVIDER_RESPONSE = {
url: 'https://twitter.com/thatbunty',
html: false,
Expand Down Expand Up @@ -74,6 +92,14 @@ const MOCK_RESPONSES = [
match: createEmbeddingMatcher( 'https://www.youtube.com/watch?v=lXMskKTw3Bc' ),
onRequestMatch: createJSONResponse( MOCK_EMBED_VIDEO_SUCCESS_RESPONSE ),
},
{
match: createEmbeddingMatcher( 'https://soundcloud.com/a-boogie-wit-da-hoodie/swervin' ),
onRequestMatch: createJSONResponse( MOCK_EMBED_AUDIO_SUCCESS_RESPONSE ),
},
{
match: createEmbeddingMatcher( 'https://www.instagram.com/p/Bvl97o2AK6x/' ),
onRequestMatch: createJSONResponse( MOCK_EMBED_IMAGE_SUCCESS_RESPONSE ),
},
{
match: createEmbeddingMatcher( 'https://cloudup.com/cQFlxqtY4ob' ),
onRequestMatch: createJSONResponse( MOCK_EMBED_RICH_SUCCESS_RESPONSE ),
Expand Down Expand Up @@ -217,4 +243,33 @@ describe( 'Embedding content', () => {
// Check the block has become a WordPress block.
await page.waitForSelector( '.wp-block-embed-wordpress' );
} );

it( 'should transform from video to embed block when YouTube URL is pasted', async () => {
await clickBlockAppender();
await insertBlock( 'Video' );
await page.click( '.editor-media-placeholder__url-input-container button' );
await page.keyboard.type( 'https://www.youtube.com/watch?v=lXMskKTw3Bc' );
draganescu marked this conversation as resolved.
Show resolved Hide resolved
await page.keyboard.press( 'Enter' );
await page.waitForSelector( '.wp-block-embed-youtube' );
} );

it( 'should transform from image to embed block when Instagram URL is pasted', async () => {
await clickBlockAppender();
await page.keyboard.type( '/image' );
await page.keyboard.press( 'Enter' );
await page.click( '.editor-media-placeholder__url-input-container button' );
await page.keyboard.type( 'https://www.instagram.com/p/Bvl97o2AK6x/' );
await page.keyboard.press( 'Enter' );
await page.waitForSelector( '.wp-block-embed-instagram' );
} );

it( 'should transform from audio to embed block when Soundcloud URL is pasted', async () => {
await clickBlockAppender();
await page.keyboard.type( '/audio' );
await page.keyboard.press( 'Enter' );
await page.click( '.editor-media-placeholder__url-input-container button' );
await page.keyboard.type( 'https://soundcloud.com/a-boogie-wit-da-hoodie/swervin' );
await page.keyboard.press( 'Enter' );
await page.waitForSelector( '.wp-block-embed-soundcloud' );
} );
} );