-
Notifications
You must be signed in to change notification settings - Fork 798
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
Post by Email: Refactoring and Unit Tests #15139
Conversation
* Deprecate the WP-AJAX endpoints (`jetpack_post_by_email_enable`, `jetpack_post_by_email_regenerate`, `jetpack_post_by_email_disable`) * Switch the "User Profile -> Post by Email" UI from WP-AJAX to REST API * Moving REST requests proxying from `Jetpack_Core_API_Data` to the `post-by-email` module (as suggested by the @todo tag)
Currently class `WP_Test_Post_By_Email_API` tests one API method: `post_by_email_address => create`. In the future tests for `regenerate` and `delete` will be added. REST API authentication mocking code is mostly copied form `WP_Test_Jetpack_REST_API_Authentication`. Test API requests are not being sent to the Jetpack API, instead the Jetpack API request is verified, and the response is mocked. This allows us to test the functionality internally.
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: April 7, 2020. |
The commit adds two unit tests for the “post-by-email” module: - `jetpack.regeneratePostByEmailAddress` - `jetpack.deletePostByEmailAddress` I also made some minor refactoring in the test class `WP_Test_Post_By_Email_API`.
d894bab
to
ddc47ea
Compare
Rewriting the jQuery AJAX request on VanillaJS.
c084200
to
84a2f3b
Compare
While we were in the file, I brought it up to PHPCS compliance. |
@sergeymitr Could you give a glance/test for acb25a9? It tests fine for me, but want to be sure. If you're happy, merge when you're ready. |
…tribute. - Files `post-by-email.js` and `post-by-email.css` were enqueued incorrectly. Since the class was moved into the module directory, they got additional `post-by-email/` in the path, fixed now. - Escaping `style` attributes in the "User Profile" form leads to quotes being converted to HTML entities. I refactored this tiny piece of code to make the attribute escaping work.
@kraftbj |
Description
Post by Email module has two UI widgets:
These two interfaces utilize different API endpoints, and that leads to duplicated code.
The goal of this PR is to minimize the code duplication, deprecate the older WP-AJAX endpoints in favor of the REST API, improve the test coverage of the module, and refactor the module to improve the code quality.
Nonetheless, the PR does not modify the module behavior in any way, and all deprecated functionality is still available (although it does throw "doing it wrong" warnings).
No issue was created.
Changes proposed in this Pull Request:
jetpack_post_by_email_enable
,jetpack_post_by_email_regenerate
,jetpack_post_by_email_disable
).Jetpack_Core_API_Data
to thepost-by-email
module (as suggested by the @todo tag).Testing instructions:
yarn docker:phpunit
).Proposed changelog entry for your changes:
WP-AJAX
endpoints are deprecated in favor of the REST API.