woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
47 stars 21 forks source link

[API PULL] Fix tests for Notifying delete products #2626

Closed puntope closed 1 month ago

puntope commented 1 month ago

Changes proposed in this Pull Request:

There is a test failing in regards

Automattic\WooCommerce\GoogleListingsAndAds\Tests\Unit\Product\SyncerHooksTest::test_delete_created_product_calls_notify_directly
Expectation failed for method name is "notify" when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.

This seems to happen because the metadata is empty after the code calls the delete hook. To solve it. I moved the notifications to the pre-delete.

Screenshots:

Detailed test instructions:

  1. Tests are passing
  2. Create a simple product. It will schedule a create notification. See it works as expected and shows in the logs after the action is completed.
  3. Trash the simple product. See directly the delete notification in the logs.

Additional details:

Changelog entry

Tweak - Logic for Delete notifications.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 65.3%. Comparing base (1c6a902) to head (5b6924f). Report is 18 commits behind head on develop.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2626/graphs/tree.svg?width=650&height=150&src=pr&token=UROWUPF1LX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2626?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) ```diff @@ Coverage Diff @@ ## develop #2626 +/- ## ========================================= Coverage 65.3% 65.3% Complexity 4596 4596 ========================================= Files 474 474 Lines 17893 17896 +3 ========================================= + Hits 11685 11688 +3 Misses 6208 6208 ``` | [Flag](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2626/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [php-unit-tests](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2626/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | `65.3% <100.0%> (+<0.1%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2626?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [src/Product/SyncerHooks.php](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2626?src=pr&el=tree&filepath=src%2FProduct%2FSyncerHooks.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-c3JjL1Byb2R1Y3QvU3luY2VySG9va3MucGhw) | `90.0% <100.0%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2626/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)