-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 for post comments form placeholder #40396
e2e tests for post comments form placeholder #40396
Conversation
Size Change: 0 B Total Size: 1.23 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.
Really nice work @ribaricplusplus 👍 I left some comments for you below
); | ||
|
||
// Compare the structures | ||
expect( editorBlockStructure ).toEqual( frontendBlockStructure ); |
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.
I think we could improve this part a bit. I think that comparing the whole structure here is not the best pattern:
- If there is a single error inside of that assertion, the whole assertion fails without giving the information about which particular of the 3 selectors failed. (PS. I haven't tested that this is the case, perhaps playwright is smart about it, but I'm not so intimately familiar with it)
- In general, we should not assume that the structure of the frontend and the editor is going to be the same in any way. It just so happens incidentally to be the case here but it might change in the future.
- Simple selectors are more readable and because this is test code we probably should not build abstractions too quickly. Without them it's easier to change or delete tests.
Could we turn this getStructureFromHandle
abstraction into a list of simpler selectors + specific assertions about what is expected instead of comparing it with the content in the frontend? So something like:
await expect(page.$('.wp-block-post-comments-form .comment-form input[type="submit"]').not.toBeNull();
Thank you for taking a look!
Oh, alright - I incorrectly assumed otherwise. In that case, i don't think there is much benefit to having the second test at all so I removed it. |
All right, let's merge it 👍 Thanks a lot for helping out @ribaricplusplus ! |
* Tests * Change tests directory * Remove second test * Fix test
Added some e2e tests for #40368.
@michalczaplinski could we merge this into your PR?