Skip to content
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

Sync: listen for status changes on Woo product reviews #13079

Merged
merged 5 commits into from
Jul 18, 2019

Conversation

roccotripaldi
Copy link
Member

@roccotripaldi roccotripaldi commented Jul 17, 2019

Fixes an issue where a product review status ( approved / unapproved ) appear incorrectly on Wordpress.com

Changes proposed in this Pull Request:

  • Makes the list of comment types filterable
  • WooCommerce sync module adds 'review' to filter

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • See: p99K0U-1mi-p2

Testing instructions:

  • Run this branch on a connected Woo commerce site
  • Add a product review to one of your products, and approve it
  • Check the cache site and ensure the status of the review/comment is approved
  • Unapprove the review/comment
  • Check the cache site and ensure the status of the review/comment is unapproved

Proposed changelog entry for your changes:

  • Fixes an issue where a product review status ( approved / unapproved ) appear incorrectly on Wordpress.com

@roccotripaldi roccotripaldi added [Type] Bug When a feature is broken and / or not performing as intended [Status] In Progress [Package] Sync labels Jul 17, 2019
@roccotripaldi roccotripaldi added this to the 7.6 milestone Jul 17, 2019
@roccotripaldi roccotripaldi requested a review from a team July 17, 2019 19:29
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello roccotripaldi! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D30542-code before merging this PR. Thank you!

@jetpackbot
Copy link

jetpackbot commented Jul 17, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: August 6, 2019.
Scheduled code freeze: July 30, 2019

Generated by 🚫 dangerJS against be275db

@roccotripaldi roccotripaldi added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] In Progress labels Jul 17, 2019
@roccotripaldi
Copy link
Member Author

I'd love to add a unit test or two here, but i cannot figure out how to run Woo tests on my docker setup.

@roccotripaldi roccotripaldi requested review from a team and timmyc July 17, 2019 20:43
@timmyc
Copy link
Contributor

timmyc commented Jul 18, 2019

@roccotripaldi I'll give this a test tomorrow, sorry I didn't get to it today.

@tyxla
Copy link
Member

tyxla commented Jul 18, 2019

I'd love to add a unit test or two here, but i cannot figure out how to run Woo tests on my docker setup.

I've added a simple test that makes sure that registering a custom comment type works from the point of view of the Comments sync module.

We could add another one for WooCommerce, but it doesn't seem that the current tests are working. I'll work on a fix for them, and add another test case afterwards.

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

This appears to be working great! I only have a suggestion regarding naming, which I'm just going to address directly, as I'm already touching the branch.

packages/sync/src/modules/Comments.php Outdated Show resolved Hide resolved
* return array The list of comment types with 'review' added.
*/
public function add_review_comment_types( $comment_types ) {
if ( is_array( $comment_types ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this check necessary? I've noticed we don't do these on other filters that work in a similar way.

packages/sync/src/modules/Comments.php Outdated Show resolved Hide resolved
packages/sync/src/modules/Comments.php Outdated Show resolved Hide resolved
packages/sync/src/modules/Comments.php Outdated Show resolved Hide resolved
tests/php/sync/test_class.jetpack-sync-comments.php Outdated Show resolved Hide resolved
tests/php/sync/test_class.jetpack-sync-comments.php Outdated Show resolved Hide resolved
tests/php/sync/test_class.jetpack-sync-comments.php Outdated Show resolved Hide resolved
tests/php/sync/test_class.jetpack-sync-comments.php Outdated Show resolved Hide resolved
tests/php/sync/test_class.jetpack-sync-comments.php Outdated Show resolved Hide resolved
@tyxla
Copy link
Member

tyxla commented Jul 18, 2019

I've suggested a fix for fixing the WooCommerce tests in #13080. Cherrypicked it here in b376c36

Going to work on adding another test now.

@tyxla
Copy link
Member

tyxla commented Jul 18, 2019

Also, @roccotripaldi in case you were wondering how to run the Woo tests, considering they're fixed (in this branch or in #13080):

  • Make sure you have the latest WooCommerce git repo checked out in /docker/wp-content/plugins/woocommerce, and WooCommerce is built (composer install, npm install, npm run build in the woo dir does the job).
  • Navigate to the Jetpack repo root.
  • Run yarn docker:sh
  • While in the shell, run cd wp-content/plugins/jetpack
  • Run JETPACK_TEST_WOOCOMMERCE=1 phpunit --filter WP_Test_Jetpack_Sync_WooCommerce

Also documented in the testing instructions of #13080.

@tyxla
Copy link
Member

tyxla commented Jul 18, 2019

@roccotripaldi @timmyc in 46ca0c6 I've just added a couple of test cases that verify that approving and unapproving a review is being synced as expected.

@tyxla
Copy link
Member

tyxla commented Jul 18, 2019

This is looking good from my perspective 👍 But since I touched the branch quite a bit, let's get someone else from Crew/Poseidon to review it.

@tyxla tyxla requested review from a team July 18, 2019 09:27
jeherve
jeherve previously approved these changes Jul 18, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

I like it. This will actually fix #12830 as well, since the Action Scheduler comments use a custom comment type, action_log. Here is an example:

+----------------------+---------------------+
| Field                | Value               |
+----------------------+---------------------+
| comment_ID           | 139                 |
| comment_post_ID      | 702                 |
| comment_author       | ActionScheduler     |
| comment_author_email |                     |
| comment_author_url   |                     |
| comment_author_IP    |                     |
| comment_date         | 2019-07-17 22:53:21 |
| comment_date_gmt     | 2019-07-17 20:53:21 |
| comment_content      | action created      |
| comment_karma        | 0                   |
| comment_approved     | 1                   |
| comment_agent        | ActionScheduler     |
| comment_type         | action_log          |
| comment_parent       | 0                   |
| user_id              | 0                   |
+----------------------+---------------------+

I'll update that other PR to only include the CPT blacklist.

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jul 18, 2019
jeherve added a commit that referenced this pull request Jul 18, 2019
…eduler"

This reverts commit f481a2b.

No need for this exception once #13079 will be merged.
@roccotripaldi roccotripaldi force-pushed the fix/woo-commerce-sync-comment-status branch from 46ca0c6 to be275db Compare July 18, 2019 15:32
@roccotripaldi
Copy link
Member Author

Rebasing after merging #13080, i am able to run the new unit tests, and they pass!
This still works as described with smoke testing too.

I think it's ready!

@roccotripaldi roccotripaldi merged commit 4924b0f into master Jul 18, 2019
Copy link
Contributor

@gititon gititon left a comment

Choose a reason for hiding this comment

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

Looks good!

@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Jul 18, 2019
@roccotripaldi roccotripaldi deleted the fix/woo-commerce-sync-comment-status branch July 18, 2019 15:58
jeherve added a commit that referenced this pull request Jul 19, 2019
jeherve added a commit that referenced this pull request Jul 24, 2019
* Sync: sort blacklisted post types alphabetically

* Sync: add Action Scheduler to the list of blacklisted post types

Fixes #12714

Those events do not need to be synced with WordPress.com.

* [not verified] Sync: do not sync comments made via Action Scheduler

* Revert "[not verified] Sync: do not sync comments made via Action Scheduler"

This reverts commit f481a2b.

No need for this exception once #13079 will be merged.
jeherve added a commit that referenced this pull request Jul 30, 2019
* Add initial changelog / testing list changes for 7.6

* Update stable tag to 7.5.3

* changelog: add #12957

* Changelog: add #12932

* Changelog: add #12867

* Changelog: add #12823

* changelog: add #12969

* changelog: add #13012

* changelog: add #12974

* Changelog: add #13059

* Changelog: add #13079

* Changelog: add #12924

* changelog: add #12954

* Changelog: add #12959

* Changelog: add #12977

* Changelog: add #12830

* Changelog: add #12926

* Changelog: add #12958

* Changelog: add #12999

* Changelog: add #13077

* Changelog: add #13083

* Changelog: add #13087

* Changelog: add #13110

* Changelog: add #13116

* Changelog: add #13117

* Changelog: add #12821

* Changelog: add #13120

* changelog: add #13139

* Changelog: add #13143

* Changelog: add #13147

* Testing list: add section about sync
jeherve added a commit that referenced this pull request Jul 30, 2019
* Add initial changelog / testing list changes for 7.6

* Update stable tag to 7.5.3

* changelog: add #12957

* Changelog: add #12932

* Changelog: add #12867

* Changelog: add #12823

* changelog: add #12969

* changelog: add #13012

* changelog: add #12974

* Changelog: add #13059

* Changelog: add #13079

* Changelog: add #12924

* changelog: add #12954

* Changelog: add #12959

* Changelog: add #12977

* Changelog: add #12830

* Changelog: add #12926

* Changelog: add #12958

* Changelog: add #12999

* Changelog: add #13077

* Changelog: add #13083

* Changelog: add #13087

* Changelog: add #13110

* Changelog: add #13116

* Changelog: add #13117

* Changelog: add #12821

* Changelog: add #13120

* changelog: add #13139

* Changelog: add #13143

* Changelog: add #13147

* Testing list: add section about sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Sync [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants