-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
E2E Tests: Add gallery caption coverage #29127
Conversation
Size Change: 0 B Total Size: 1.38 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @rafaelgalani! I've left some notes but definitely good work! 👍
const galleryCaption = 'Tested gallery caption'; | ||
|
||
await insertBlock( 'Gallery' ); | ||
const filename = await upload( '.wp-block-gallery input[type="file"]' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this tests the whole gallery caption there is no need to get the returned uploaded filename
and no reason to call getUploadedFileFigure
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy/paste. Sorry... 😅
await insertBlock( 'Gallery' ); | ||
const filename = await upload( '.wp-block-gallery input[type="file"]' ); | ||
|
||
const figureElement = await getUploadedFileFigure( filename ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're uploading just one image here, the test can be really simplified by removing the getUploadedFileFigure
function completely and replace it with:
const figureElement = await page.waitForSelector(
'.blocks-gallery-item figure'
);
Also no need to use the returned filename
, just upload.
expect( | ||
await figureElement.evaluate( ( element ) => | ||
element.classList.contains( 'is-selected' ) | ||
) | ||
).toBeTruthy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really... I just wanted to check if the element was being correctly selected, but I guess this can be checked in the last assertion anyway.
2518f2b
to
c177028
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Rafael! Looking great now! 🚢
Description
Add an E2E test for the gallery's figure caption, making sure it's clickable and editable. I also included a test for the gallery caption.
Fixes #29001.
How has this been tested?
npm run test-e2e "packages/e2e-tests/specs/editor/blocks/gallery.test.js"
git revert eabd210 npm run build npm run test-e2e "packages/e2e-tests/specs/editor/blocks/gallery.test.js"
Since eabd210 fixed the gallery's figure caption, only the test for the figures' caption will fail, and not the one for the gallery's.