Skip to content

Add test to verify image appears on frontend#50472

Merged
artemiomorales merged 2 commits into
WordPress:trunkfrom
artemiomorales:update/image-frontend-test
May 10, 2023
Merged

Add test to verify image appears on frontend#50472
artemiomorales merged 2 commits into
WordPress:trunkfrom
artemiomorales:update/image-frontend-test

Conversation

@artemiomorales

Copy link
Copy Markdown
Contributor

What?

This PR adds a test to confirm that the image block actually outputs the expected element in the frontend published post content.

Why?

While we've done a good job of testing to make sure the image behaves as expected in the editor, this adds extra verification so we can catch if the image block ever breaks.

This will be especially important as we look to extend the image functionality with a lightbox #50373

How?

It adds to a test to the image.spec.js

Testing Instructions

Run npm run test:e2e:playwright -- image.spec.js to test the single test file locally.

Testing Instructions for Keyboard

N/A

Screenshots or screencast

@artemiomorales artemiomorales requested a review from gziolo May 9, 2023 15:18

@gziolo gziolo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, this is a good start before we start covering other use cases with the lightbox enabled 😀

Comment thread test/e2e/specs/editor/blocks/image.spec.js Outdated
@gziolo gziolo added [Block] Image Affects the Image Block [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. labels May 9, 2023
@artemiomorales

Copy link
Copy Markdown
Contributor Author

@gziolo Thanks for the review! I added a check for the child img of the figure element and verified that its src attribute is correct. Note: For some reason, getByRole doesn't work when called on the figure element, so I used the locator instead.

gziolo

This comment was marked as duplicate.

@gziolo gziolo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good to start with.

It’s very likely that you need to set an alt attribute on the image for the licator to be able to find it. The img without the alt is not accessible.

@gziolo gziolo marked this pull request as ready for review May 10, 2023 07:15
@gziolo gziolo requested a review from kevin940726 as a code owner May 10, 2023 07:15
@artemiomorales artemiomorales merged commit bdce28d into WordPress:trunk May 10, 2023
@github-actions github-actions Bot added this to the Gutenberg 15.8 milestone May 10, 2023

@kevin940726 kevin940726 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@kevin940726

Copy link
Copy Markdown
Member

It’s very likely that you need to set an alt attribute on the image for the licator to be able to find it.

I wonder why we don't automatically set an empty alt attribute if the user doesn't specify it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Image Affects the Image Block [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants