diff --git a/packages/e2e-tests/specs/editor/blocks/image.test.js b/packages/e2e-tests/specs/editor/blocks/image.test.js index b254413a141df9..0eace350f08f2e 100644 --- a/packages/e2e-tests/specs/editor/blocks/image.test.js +++ b/packages/e2e-tests/specs/editor/blocks/image.test.js @@ -288,4 +288,49 @@ describe( 'Image', () => { expect( initialImageDataURL ).not.toEqual( updatedImageDataURL ); expect( updatedImageDataURL ).toMatchSnapshot(); } ); + + it( 'Should reset dimensions on change URL', async () => { + const imageUrl = '/wp-includes/images/w-logo-blue.png'; + + await insertBlock( 'Image' ); + + // Upload an initial image. + const filename = await upload( '.wp-block-image input[type="file"]' ); + + // Resize the Uploaded Image. + await openDocumentSettingsSidebar(); + await page.click( + '[aria-label="Image size presets"] button:first-child' + ); + + const regexBefore = new RegExp( + `\\s*
<\\/figure>\\s*` + ); + + // Check if dimensions are changed. + expect( await getEditedPostContent() ).toMatch( regexBefore ); + + // Replace uploaded image with an URL. + await clickButton( 'Replace' ); + await clickButton( 'Edit' ); + + await page.waitForSelector( '.block-editor-url-input__input' ); + await page.evaluate( + () => + ( document.querySelector( + '.block-editor-url-input__input' + ).value = '' ) + ); + + await page.focus( '.block-editor-url-input__input' ); + await page.keyboard.type( imageUrl ); + await page.click( '.block-editor-link-control__search-submit' ); + + const regexAfter = new RegExp( + `\\s*
\\s*` + ); + + // Check if dimensions are reset. + expect( await getEditedPostContent() ).toMatch( regexAfter ); + } ); } );