From bdce28d5a63e555a92a5bca496740e6ddaa3e131 Mon Sep 17 00:00:00 2001 From: Artemio Morales Date: Wed, 10 May 2023 09:55:14 +0200 Subject: [PATCH] Add test to verify image appears on frontend (#50472) * Add test to verify image appears on frontend * Add check for img and its src attribute --- test/e2e/specs/editor/blocks/image.spec.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index 513cdddb6aec45..eb5d9e2780b445 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -684,6 +684,42 @@ 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 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 ) + ); + } ); } ); class ImageBlockUtils {