-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Migrate post-editor-template-mode
to Playwright
#40175
Migrate post-editor-template-mode
to Playwright
#40175
Conversation
910a059
to
39fb260
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.
I noticed something weird in the original test file. @talldan Do you know why?
wp.data | ||
.select( 'core/edit-post' ) | ||
.isFeatureActive( 'welcomeGuideTemplate' ) |
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.
Here we're accessing the feature flag from the core/edit-post
store (1/2)
!! wp.data | ||
.select( 'core/preferences' ) | ||
.get( 'core/edit-post', 'welcomeGuide' ) |
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.
But here we're accessing the feature flag from the core/preferences
store. (2/2)
Size Change: +169 B (0%) Total Size: 1.22 MB
ℹ️ View Unchanged
|
@kevin940726 Both do the same thing, the first one is an older API kept for backwards compatibility, but the implementation will now also select from the preferences store. The first API will probably be deprecated over the coming weeks. |
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.
Looks good, nice work!
} ); | ||
} ); | ||
|
||
class PostEditorTemplateMode { |
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.
The only thing I wonder about is whether a class is the right option here. This seems like a set of loosely defined utility functions while a class is usually strictly modelled around a particular object. Maybe this is idiomatic playwrighting. I don't know it well enough to say for sure 😄
It is just test code and it works well and is organised very nicely, so it's still a thumbs up 👍
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.
Yeah, it's debatable.
The idea is to follow the POM convention to create utility helpers for tests for a specific page. We could just create utility functions as we did in e2e-test-utils
, but that would mean remembering to pass all those previously global variables like page
and browser
to each function. Using classes allows us to implicitly bind those variables to the helpers via the this
keyword.
Another good idea will be to just define these functions as fixture functions. I just default to POM to try to make them consistent 😅 . There's still room for improvements, though, so ideas are welcome!
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 see, sounds like this is a recommended approach. I think it's ok as a convention, and for anyone contributing familiar with playwright, they'll probably find it helpful that we've followed this pattern.
It also seems a bit simpler than the fixture example.
Thanks for linking to the docs. 👍
* Migrate post-editor-template-mode to Playwright * Use core/preferences store
What?
Part of #38851. Migrate
post-editor-template-mode.test.js
to Playwright.Hopefully fixes #34805, fixes #39120, fixes #39121, fixes #38594, fixes #38595.
Why?
See this post for an overview of the migration.
How?
By following the migration guide.
Testing Instructions