diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index c4c725e083625..43527b48fbf70 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -708,13 +708,14 @@ test.describe( 'Image', () => { await editor.clickBlockToolbarButton( 'Upload to Media Library' ); - const imageBlock = editor.canvas.locator( - 'role=document[name="Block: Image"i]' + await expect( + editor.canvas + .locator( 'role=document[name="Block: Image"i]' ) + .locator( 'img[src^="http"]' ) + ).toHaveAttribute( + 'src', + expect.stringMatching( /\/wp-content\/uploads\// ) ); - const image = imageBlock.locator( 'img[src^="http"]' ); - const src = await image.getAttribute( 'src' ); - - expect( src ).toMatch( /\/wp-content\/uploads\// ); } ); test( 'should upload through prepublish panel', async ( { @@ -736,14 +737,45 @@ test.describe( 'Image', () => { .click(); await expect( page.locator( '.components-spinner' ) ).toHaveCount( 0 ); - - const imageBlock = editor.canvas.locator( - 'role=document[name="Block: Image"i]' + await expect( + editor.canvas + .locator( 'role=document[name="Block: Image"i]' ) + .locator( 'img[src^="http"]' ) + ).toHaveAttribute( + 'src', + expect.stringMatching( /\/wp-content\/uploads\// ) ); - const image = imageBlock.locator( 'img[src^="http"]' ); - const src = await image.getAttribute( 'src' ); + } ); - expect( src ).toMatch( /\/wp-content\/uploads\// ); + test( 'uploads data url through blobs from raw handling', async ( { + editor, + page, + pageUtils, + } ) => { + const blobUrl = await page.evaluate( async () => { + const canvas = document.createElement( 'canvas' ); + canvas.width = 20; + canvas.height = 20; + + const ctx = canvas.getContext( '2d' ); + ctx.fillStyle = 'red'; + ctx.fillRect( 0, 0, 20, 20 ); + + return canvas.toDataURL( 'image/png' ); + } ); + + pageUtils.setClipboardData( { html: `` } ); + + await pageUtils.pressKeys( 'primary+v' ); + + await expect( + editor.canvas + .locator( 'role=document[name="Block: Image"i]' ) + .locator( 'img[src^="http"]' ) + ).toHaveAttribute( + 'src', + expect.stringMatching( /\/wp-content\/uploads\// ) + ); } ); test( 'should have keyboard navigable link UI popover', async ( {