From d5a35c81b0f70e16855005c3c6511b48d338e2ef Mon Sep 17 00:00:00 2001 From: Ricardo Artemio Morales Date: Tue, 9 May 2023 17:07:35 +0200 Subject: [PATCH 1/2] Add test to verify image appears on frontend --- test/e2e/specs/editor/blocks/image.spec.js | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index 513cdddb6aec4..de01508607489 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -684,6 +684,35 @@ test.describe( 'Image', () => { url ); } ); + + test( 'should appear in the frontend published post content', async ( { + editor, + imageBlockUtils, + page, + } ) => { + await editor.insertBlock( { name: 'core/image' } ); + const imageBlock = page.locator( + 'role=document[name="Block: Image"i]' + ); + await expect( imageBlock ).toBeVisible(); + + const filename = await imageBlockUtils.upload( + imageBlock.locator( 'data-testid=form-file-upload-input' ) + ); + + const imageInEditor = imageBlock.locator( 'role=img' ); + await expect( imageInEditor ).toBeVisible(); + await expect( imageInEditor ).toHaveAttribute( + 'src', + new RegExp( filename ) + ); + + const postId = await editor.publishPost(); + await page.goto( `/?p=${ postId }` ); + + const imageInFrontend = page.getByRole( 'figure' ); + await expect( imageInFrontend ).toBeVisible(); + } ); } ); class ImageBlockUtils { From d61df7c6c88ca9aca18b5806dec46b8583f08ac6 Mon Sep 17 00:00:00 2001 From: Ricardo Artemio Morales Date: Wed, 10 May 2023 06:22:06 +0200 Subject: [PATCH 2/2] Add check for img and its src attribute --- test/e2e/specs/editor/blocks/image.spec.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index de01508607489..eb5d9e2780b44 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -710,8 +710,15 @@ test.describe( 'Image', () => { const postId = await editor.publishPost(); await page.goto( `/?p=${ postId }` ); - const imageInFrontend = page.getByRole( 'figure' ); - await expect( imageInFrontend ).toBeVisible(); + const figureDom = page.getByRole( 'figure' ); + await expect( figureDom ).toBeVisible(); + + const imageDom = figureDom.locator( 'img' ); + await expect( imageDom ).toBeVisible(); + await expect( imageDom ).toHaveAttribute( + 'src', + new RegExp( filename ) + ); } ); } );