Skip to content

Commit

Permalink
Add test to verify image appears on frontend (#50472)
Browse files Browse the repository at this point in the history
* Add test to verify image appears on frontend

* Add check for img and its src attribute
  • Loading branch information
artemiomorales authored May 10, 2023
1 parent 15d0927 commit bdce28d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/e2e/specs/editor/blocks/image.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

1 comment on commit bdce28d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in bdce28d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4934511018
📝 Reported issues:

Please sign in to comment.