Add unit tests for WhatsApp utility event handler to verify fix for #3841#3860
Add unit tests for WhatsApp utility event handler to verify fix for #3841#3860faisalahammad wants to merge 610 commits into
Conversation
Summary: ## Description This PR adds comprehensive unit test coverage for ProfilingLoggerProcess, which tracks memory and time usage for profiling operations. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add comprehensive unit tests for ProfilingLoggerProcess to improve code coverage Pull Request resolved: facebook#3412 Test Plan: 1. Run the unit tests with: `composer test-unit -- tests/Unit/Debug/ProfilingLoggerProcessTest.php` 2. All 8 tests should pass successfully (19 assertions) 3. The tests cover: - **Class instantiation**: Verifies the class exists and can be instantiated - **Constructor behavior**: Tests that start time and memory are properly initialized - **Stop method**: Verifies stop values are set correctly - **Memory tracking**: Tests memory usage calculation including positive and negative changes - **Time tracking**: Tests time measurement with various delays - **Edge cases**: Tests immediate stop and multiple stop calls ## Screenshots Not applicable - this PR only adds unit tests Reviewed By: jczhuoMeta Differential Revision: D76838388 Pulled By: sol-loup fbshipit-source-id: 352017557719a7e4d064455e4405d32e0f483cc2
Summary: ## Description This PR adds unit test coverage for `SettingsMoved` note class, which handles displaying admin notices to users about the Facebook menu being moved to the Marketing menu (for users upgrading from versions prior to 2.2.0). ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for SettingsMoved note class to improve code coverage Pull Request resolved: facebook#3428 Test Plan: 1. Run the unit tests with: `composer test-unit -- tests/Unit/Admin/Notes/SettingsMovedTest.php` 2. All 10 tests should pass successfully (23 assertions) 3. The tests cover: - **Class existence and constants**: Verifies the class and NOTE_NAME constant - **Version logic**: Tests `should_display()` with various upgrade scenarios and version comparisons - **Note generation**: Tests `get_note()` returns properly configured Note object with correct content - **Note actions**: Verifies the note includes the correct action button - **Add/Delete logic**: Tests `possibly_add_or_delete_note()` behavior based on conditions - **Content validation**: Ensures note content includes expected keywords ## Screenshots Not applicable - this PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/12947849019504252 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/8444249574475439 Reviewed By: jczhuoMeta Differential Revision: D76911293 Pulled By: sol-loup fbshipit-source-id: 0c5d65192a175146f8c5b6a240d82729809bb006
Summary: ## Description This PR adds comprehensive unit test coverage for `Commerce` class, which handles plugin-level Google product category settings for Facebook Commerce integration. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add comprehensive unit tests for Commerce class to improve code coverage Pull Request resolved: facebook#3425 Test Plan: 1. Run the unit tests with: `composer test-unit -- tests/Unit/CommerceTest.php` 2. All 13 tests should pass successfully (28 assertions) 3. The tests cover: - **Class instantiation**: Verifies the class exists and can be instantiated - **Constants**: Tests the option constant value - **Getter method**: Tests `get_default_google_product_category_id()` with various scenarios - **Setter method**: Tests `update_default_google_product_category_id()` with different data types - **Filter hooks**: Tests the `wc_facebook_commerce_default_google_product_category_id` filter - **Edge cases**: Tests empty strings, special characters, Unicode, and type coercion ## Screenshots Not applicable - this PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/5910974797527842 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/9007199346017035 Reviewed By: mradmeta Differential Revision: D76911274 Pulled By: sol-loup fbshipit-source-id: aac7af7a4936a0a5cbb0d427ee513d5b8490ed81
…book#3424) Summary: ## Description This PR adds comprehensive unit test coverage for `WC_Facebookcommerce_WarmConfig`, which stores pre-configured Facebook Pixel settings that can be used to initialize the Facebook Pixel when user settings are not yet available. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add comprehensive unit tests for WC_Facebookcommerce_WarmConfig to improve code coverage Pull Request resolved: facebook#3424 Test Plan: 1. Run the unit tests with: `composer test-unit -- tests/Unit/WCFacebookcommerceWarmConfigTest.php` 2. All 8 tests should pass successfully (16 assertions) 3. The tests cover: - **Class existence**: Verifies the class can be loaded and referenced - **Default values**: Tests all static properties default to null - **Property operations**: Tests setting/getting each property with various data types - **Property isolation**: Ensures properties are independent of each other - **Edge cases**: Tests empty strings, special characters, Unicode, and mixed data types ## Screenshots Not applicable - this PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/11540474135932672 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/17732923623553340 Reviewed By: mradmeta Differential Revision: D76911268 Pulled By: sol-loup fbshipit-source-id: 2ff21f66aebae97b4d016e64a09d2dda1cc78d83
…ebook#3427) Summary: ## Description This PR adds comprehensive unit test coverage for `Request_Limit_Reached` exception class, which is thrown in response to API rate limiting errors and includes functionality to track when the throttle will be lifted. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add comprehensive unit tests for Request_Limit_Reached exception to improve code coverage Pull Request resolved: facebook#3427 Test Plan: 1. Run the unit tests with: `composer test-unit -- tests/Unit/Api/Exceptions/Request_Limit_ReachedTest.php` 2. All 12 tests should pass successfully (26 assertions) 3. The tests cover: - **Class existence and inheritance**: Verifies the class exists and extends ApiException - **Constructor variations**: Tests with message, code, and default values - **Throttle end getter/setter**: Tests `get_throttle_end()` and `set_throttle_end()` methods - **DateTime handling**: Tests various DateTime scenarios including timezones - **Exception behavior**: Tests throwing and catching the exception - **Instance isolation**: Ensures throttle_end values are isolated between instances - **Edge cases**: Tests DateTime immutability and multiple setter calls ## Screenshots Not applicable - this PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/5348024845661462 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/7036874692075377 Reviewed By: mradmeta Differential Revision: D76911290 Pulled By: sol-loup fbshipit-source-id: 454cfde620a95dddaa86b2beec61d32b56138d18
Summary: This PR adds comprehensive unit tests for the ProductCatalog ProductSets Delete Request class, which previously had 0% test coverage. Added 10 test methods covering: class existence and inheritance, constructor with live deletion flag, path construction with query parameters, DELETE method verification, edge cases, and multiple instance configurations. Tests verify both default behavior and live deletion mode. Pull Request resolved: facebook#3417 Test Plan: Imported from GitHub, without a `Test Plan:` line. **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/12947849019256254 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/10414574229130777 Reviewed By: mradmeta Differential Revision: D76863182 Pulled By: sol-loup fbshipit-source-id: 6ca4cb430dc451221a93fef4bd609a4e04571d28
) Summary: ## Description This PR adds comprehensive unit test coverage for `Product_Categories` class, which provides utility methods for getting and setting Google product category values on WooCommerce product categories. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add comprehensive unit tests for Product_Categories class to improve code coverage Pull Request resolved: facebook#3426 Test Plan: 1. Run the unit tests with: `composer test-unit -- tests/Unit/Product_CategoriesTest.php` 2. All 14 tests should pass successfully (30 assertions) 3. The tests cover: - **Class existence**: Verifies the class can be loaded - **Getter method**: Tests `get_google_product_category_id()` with various scenarios - **Setter method**: Tests `update_google_product_category_id()` with different data types - **Invalid IDs**: Tests behavior with non-existent, zero, and negative category IDs - **Edge cases**: Tests empty strings, special characters, Unicode, long strings, and numeric values - **Integration**: Tests consistency between getter and setter methods ## Screenshots Not applicable - this PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/6192449722585687 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V2 https://internalfb.com/intern/testinfra/testrun/12103424089351728 Reviewed By: mradmeta Differential Revision: D76911283 Pulled By: sol-loup fbshipit-source-id: f61ef3765241c5c84142b584ed18260c7ae62acd
…acebook#3446) Summary: ## Description This PR adds comprehensive unit test coverage for the `Google_Product_Category_Field` class, which previously had no test coverage. The class is responsible for rendering JavaScript to handle Google product category selection in the admin interface. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add comprehensive unit tests for Google_Product_Category_Field class to improve code coverage Pull Request resolved: facebook#3446 Test Plan: 1. Run the unit tests with: `composer test-unit -- tests/Unit/Admin/Google_Product_Category_FieldTest.php` 2. All 5 tests should pass successfully 3. The tests cover: - **Class instantiation**: Verifies the class can be created - **JavaScript enqueuing**: Tests that render() properly enqueues JavaScript with correct parameters - **Security**: Tests input ID escaping to prevent XSS - **Edge cases**: Tests empty categories and special character handling - **Cleanup**: Proper tearDown to avoid test pollution ## Screenshots Not applicable - this PR only adds unit tests Reviewed By: mradmeta Differential Revision: D77048849 Pulled By: sol-loup fbshipit-source-id: 1a59b659d000b871bdbfc21534f1bcbf0778eb97
…ass (facebook#3449) Summary: ## Description This PR adds comprehensive unit tests for the Enhanced_Catalog_Attribute_Fields class, achieving 100% code coverage. This class handles the rendering and management of enhanced catalog attribute fields for Facebook product catalogs. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for Enhanced_Catalog_Attribute_Fields class Pull Request resolved: facebook#3449 Test Plan: 1. Run the unit tests: `composer test:unit -- tests/Unit/Admin/Enhanced_Catalog_Attribute_FieldsTest.php` 2. All 10 test methods should pass 3. Code coverage for Enhanced_Catalog_Attribute_Fields should be 100% ### Tests added: - test_magic_get_method (tests backward compatibility) - test_render_with_empty_category_id - test_render_with_valid_category_and_attributes - test_get_value_with_product - test_get_value_with_term - test_render_hidden_input_can_show_attributes - test_render_with_no_recommended_attributes - test_render_on_product_page - test_render_with_optional_selector_checked - test_get_value_with_invalid_attribute ### Key implementation details: - Properly mocks the Facebook plugin instance and category handler - Handles WordPress `_doing_it_wrong` notices correctly - Tests all render scenarios for different page types - Tests attribute value retrieval from both products and terms - Tests optional attribute visibility toggling ## Screenshots N/A - This PR only adds unit tests Reviewed By: mradmeta Differential Revision: D77048860 Pulled By: sol-loup fbshipit-source-id: 4811bbc6d7c32851c7e0cbfd13b7c3749e49af5b
…3447) Summary: ## Description This PR adds comprehensive unit tests for the AdminMessageHandler class, achieving 100% code coverage for this utility class that manages admin messages in the Facebook for WooCommerce plugin. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for AdminMessageHandler class Pull Request resolved: facebook#3447 Test Plan: 1. Run the unit tests: `composer test:unit -- tests/Unit/Framework/AdminMessageHandlerTest.php` 2. All 19 test methods should pass 3. Code coverage for AdminMessageHandler should be 100% ### Tests added: - test_constructor_hooks_actions - test_enqueue_message - test_enqueue_message_with_custom_notice_name - test_show_messages_with_no_messages - test_show_messages_with_messages - test_show_messages_without_admin_capability - test_get_message_count - test_get_message_count_with_notice_name - test_get_messages - test_get_messages_with_notice_name - test_set_messages - test_set_messages_with_notice_name - test_remove_messages - test_remove_messages_with_notice_name - test_maybe_connect_from_disconnect - test_maybe_connect_from_disconnect_with_other_error - test_maybe_display_facebook_api_messages - test_maybe_display_facebook_api_messages_with_non_api_exception - test_maybe_display_facebook_api_messages_with_non_10_code ## Screenshots N/A - This PR only adds unit tests Reviewed By: mradmeta Differential Revision: D77048853 Pulled By: sol-loup fbshipit-source-id: b27e2d3b8b7177572ec8e9daaa1c78b33cdccbd9
Summary: ## Description This PR adds comprehensive unit tests for the DebugTools utility class, achieving 100% code coverage. The DebugTools class provides various debugging utilities for the Facebook for WooCommerce plugin. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for DebugTools class Pull Request resolved: facebook#3448 Test Plan: 1. Run the unit tests: `composer test:unit -- tests/Unit/Utilities/DebugToolsTest.php` 2. All 15 test methods should pass 3. Code coverage for DebugTools should be 100% ### Tests added: - test_constructor_hooks_actions - test_ajax_debug_tools_action_without_nonce - test_ajax_debug_tools_action_with_invalid_nonce - test_ajax_debug_tools_action_without_user_capability - test_ajax_debug_tools_action_without_action - test_ajax_debug_tools_action_with_invalid_action - test_ajax_debug_tools_action_resync_products - test_ajax_debug_tools_action_resync_products_with_force - test_ajax_debug_tools_action_disconnect - test_ajax_debug_tools_action_reset_all_settings - test_ajax_debug_tools_action_reset_all_products - test_ajax_debug_tools_action_delete_logs - test_maybe_display - test_maybe_display_without_permission - test_render ## Screenshots N/A - This PR only adds unit tests Reviewed By: mradmeta Differential Revision: D77048857 Pulled By: sol-loup fbshipit-source-id: e6483a07fa99a047f9ecf71ffdefa1f341a2d223
…cebook#3450) Summary: ## Description This PR adds comprehensive unit tests for the FeedConfigurationDetection class, achieving 100% code coverage. This class is responsible for detecting and tracking feed configuration data for the Facebook for WooCommerce plugin. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for FeedConfigurationDetection class Pull Request resolved: facebook#3450 Test Plan: 1. Run the unit tests: `composer test:unit -- tests/Unit/Feed/FeedConfigurationDetectionTest.php` 2. All 11 test methods should pass 3. Code coverage for FeedConfigurationDetection should be 100% ### Tests added: - test_class_exists_and_can_be_instantiated - test_constructor_adds_action - test_track_data_source_feed_tracker_info_with_transient_set - test_track_data_source_feed_tracker_info_with_valid_data - test_track_data_source_feed_tracker_info_with_error - test_get_data_source_feed_tracker_info_no_catalog_id - test_get_data_source_feed_tracker_info_no_feed_nodes - test_get_data_source_feed_tracker_info_with_valid_feed - test_get_data_source_feed_tracker_info_with_multiple_feeds - test_get_feed_nodes_for_catalog_with_exception - test_get_feed_upload_metadata_with_exception ### Key implementation details: - Tests the heartbeat action registration - Tests transient-based rate limiting - Tests feed metadata collection and formatting - Tests error handling for missing catalog IDs and feed nodes - Tests API exception handling - Tests multiple feed selection logic (prioritizes matching feed ID) - Mocks all external dependencies (API, Integration, Tracker) ## Screenshots N/A - This PR only adds unit tests Reviewed By: mradmeta Differential Revision: D77048861 Pulled By: sol-loup fbshipit-source-id: 7cc285e3dae43e81492d6383579b7e3fa3dbdad3
) Summary: ## Description The whatsapp consent checkbox was not visible for classic checkout flow for certain woocommerce businesses. Thsi PR fixes this to enable consent checkbox even for classic checkout flows. ### Type of change - Fix (non-breaking change which fixes an issue) ## Changelog entry Fix whatsapp consent checkbox enable for classic checkout Pull Request resolved: facebook#3451 Test Plan: ## Screenshots ### Before  ### After  Able to receive message:  Reviewed By: woo-ardsouza Differential Revision: D77056614 Pulled By: sharunaanandraj fbshipit-source-id: 899b20d9d69a11f34358cb52baf7c2d4c0f3d536
Summary: ## Description A lot of redundant API calls were fired for no reason. All because of showing redundant information to the user like fbid. This fbid was then fetched every time a product was created or updated or even deleted. ### Type of change Improvement: A wide improvement in reducing the number of API calls while making CRUD operations. Removal of not required fbid get/fetch calls and deprecating functions that are not required. ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). Pull Request resolved: facebook#3356 Test Plan: The test is very simle: 1. Make a product and check the number of API calls should be 1. ## Screenshots No UI change Reviewed By: vinkmeta Differential Revision: D76659836 Pulled By: SayanPandey fbshipit-source-id: 42108fa955bbfba8a4dc6a110c826fa30e80a370
Summary: ## Description The change is made to reduce the number of batch API calls it makes to our backend. ### Type of change Fix : Reducing the number of API calls that bulk edit makes to our backend. ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry One liner entry to be surfaced in changelog.txt Pull Request resolved: facebook#3352 Test Plan: Before: 1. Do bulk edit 2. Check the number of API calls (should be equal to the number of products edited) After: 1. Do bulk edit 2. There should be single batch API call Reviewed By: vinkmeta Differential Revision: D76493279 Pulled By: SayanPandey fbshipit-source-id: 46d1f52173fab3d758871f504a0096bc020d5081
Summary: ## Description This PR introduces the Product Attribute Mapper functionality in the Facebook for WooCommerce plugin. The changes enhance the mapping system between WooCommerce product attributes and Facebook catalog fields, providing better support for custom attributes and improved attribute value normalization. Key improvements include: - Enhanced attribute mapping system with support for custom field mappings - Improved normalization of attribute values (gender, age_group, condition) - Better handling of unmapped attributes as custom_data - Optimized performance through caching of custom mappings - Added comprehensive unit tests for attribute mapping functionality ### Type of change - [x] New feature (non-breaking change which adds functionality) - [x] Syntax change (non-breaking change which fixes code modularity, linting or phpcs issues) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing to ensure it does not break existing functionality. - [x] I have updated plugin documentations with the new attribute mapping features. ## Changelog entry Enhanced product attribute mapping system with improved support for custom fields and value normalization. Pull Request resolved: facebook#3234 Test Plan: 1. **Custom Attribute Mapping Test** - Create products with various custom attributes - Map custom attributes to Facebook fields through the UI - Verify mappings are correctly saved and applied - Test attribute value normalization for gender, age_group, and condition 2. **Unit Tests** - Run all new unit tests for attribute mapping - Verify existing tests pass without regression - Check code coverage for new functionality ## Screenshots ### After <img width="1149" alt="Screenshot 2025-05-23 at 16 32 06" src="https://github.com/user-attachments/assets/0e9bf0b1-e460-432b-ada4-fd7c68da298b" /> <img width="1050" alt="Screenshot 2025-05-23 at 16 31 54" src="https://github.com/user-attachments/assets/78c761be-ce68-446e-927c-91f2b33cdd51" /> Reviewed By: vinkmeta Differential Revision: D75297109 Privacy Context Container: L1313315 Pulled By: devbodaghe fbshipit-source-id: 2f09afe64f7d57e18a144cfab7a9c79bf7d00832
Summary: * Tweak - Add comprehensive unit tests for Locale class by sol-loup in facebook#3362 * Tweak - Add unit tests for Idempotent_Request trait by sol-loup in facebook#3380 * Tweak - Add comprehensive unit tests for MetaLog Response by sol-loup in facebook#3376 * Tweak - Add comprehensive unit tests for ProductSets Delete Response class by sol-loup in facebook#3398 * Fix - Since tags by sol-loup in facebook#3397 * Tweak - Add comprehensive unit tests for Pages Read Response by sol-loup in facebook#3378 * Tweak - Add comprehensive unit tests for User Response to improve code coverage by sol-loup in facebook#3377 * Fix - Linter errors for ./includes/fbproductfeed.php by ajello-meta in facebook#3396 * Tweak - Add unit tests for Events AAMSettings class by sol-loup in facebook#3369 * Tweak - Improve CAPI event handling & add logging for Purchase events by iodic in facebook#3360 * Fix - Adding links to the updated banner by SayanPandey in facebook#3388 * Fix - Removing deprecated tag from Product Sync tab by SayanPandey in facebook#3387 * Fix - Transmit opted_out_woo_all_products timestamp by vinkmeta in facebook#3386 * Tweak - Product sync tab deprecation using Rollout Switches by SayanPandey in facebook#3364 * Tweak - Excluded categories and tags from Rollout Switches by SayanPandey in facebook#3382 * Tweak - Add unit tests for ProductExcludedException and ProductInvalidException by sol-loup in facebook#3357 * Tweak - Global sync check for Rollout Switches by SayanPandey in facebook#3367 * Fix - Limiting BatchLogHandler processing for performance reasons by vinkmeta in facebook#3381 * Tweak - Add unit tests for Framework Api Exception class by sol-loup in facebook#3370 * Tweak - Add unit tests for Framework Plugin Exception class by sol-loup in facebook#3371 * Fix - Updated since tags across a few files by sol-loup in facebook#3374 * Fix - Deprecated the concept of tip info by vinkmeta in facebook#3373 * Fix - Removed instance of deprecated logger by vinkmeta in facebook#3372 * Fix - the process to share ExternalVersionUpdate with Meta by vinkmeta in facebook#3365 * Fix - Failing tests by vinkmeta in facebook#3366 * Fix - Deprecated legacy logging apis by vinkmeta in facebook#3351 * Fix - Issue with productSetSyncTest causing warnings during PHPUnit by sol-loup in facebook#3355 * Tweak - Add comprehensive unit tests for Events\Normalizer class by sol-loup in facebook#3359 * Tweak - Add unit tests for API Response classes to improve code coverage by sol-loup in facebook#3358 * Fix - Deprecated the concept of fblog by vinkmeta in facebook#3354 * Fix - Deprecated tool tip event concepts by vinkmeta in facebook#3349 * Fix - Removed unnecessary logs being sent to Meta servers by vinkmeta in facebook#3347 * Fix - Clean up info Banner releated class and components by vinkmeta in facebook#3348 * Fix - Sending backgroung syncing jobs action logs to Meta by vinkmeta in facebook#3346 * Fix - Tracking error messages being displayed to Admins by vinkmeta in facebook#3345 * Tweak - Workflow for Releasing Plugin by tzahgr in facebook#3309 * Fix - Deleted wp_ajax_ajax_sync_all_fb_products action by vinkmeta in facebook#3343 * Fix - Deprecated log_with_debug_mode_enabled by vinkmeta in facebook#3342 * Fix - Removed unnecessary logs by vinkmeta in facebook#3341 * Fix - removing duplicate logging by vinkmeta in facebook#3337 * Fix - Updated exception logs to centralized logger by vinkmeta in facebook#3338 * Fix - Migrated Feed Logger by vinkmeta in facebook#3340 * Fix - Deprecated log_to_meta functionality by vinkmeta in facebook#3336 * Fix - Enabled fbproduct for code sniffing in facebook#3328 * Fix - Enabled phpcs for plugin banners by vinkmeta in facebook#3332 * Fix - Updated loggers for Feeds by vinkmeta in facebook#3335 * Fix - Updated loggers for checkout flow by vinkmeta in facebook#3334 * Fix - Logging background product syncing debug logs by vinkmeta in facebook#3329 * Fix - Enabled Pixel Normalizer for CS by vinkmeta in facebook#3333 * Fix - Update to Feed Loggers by vinkmeta in facebook#3330 * Fix - Debug logs for background product syncing by vinkmeta in facebook#3327 * Add - Sync all products if user has opted-in for Woo All Products by SayanPandey in facebook#3281 * Fix - PHPUnit warnings by renaming test files to match their class names by sol-loup in facebook#3311 * Tweak - Removing exclusion of sync of excluded categories and tags by SayanPandey in facebook#3244 * Fix - Lints and phpcs issues with fbproduct by vinkmeta in facebook#3324 * Fix - Code sniffing fixes for fbproduct by vinkmeta in facebook#3323 * Fix - Migrated Product Feed Progress Logging Mechanism by vinkmeta in facebook#3321 * Fix - Added critical log when user attempting non-permissible actions by vinkmeta in facebook#3322 * Fix - Handling edge case with BatchLogHandler in facebook#3320 * Fix - Product Group Logging by vinkmeta in facebook#3317 * Fix - PHPCBF for fbproduct by vinkmeta in facebook#3319 * Fix - Linting for WC_Facebookcommerce_Background_Process by vinkmeta in facebook#3318 * Tweak - Adding tags on excluded categories and tags by SayanPandey in facebook#3308 * Tweak - Removing unnecessary modal for excluded categories by SayanPandey in facebook#3307 * Tweak - Removing delete on stock check by SayanPandey in facebook#3306 * Add - Showing a banner to the user about the changes by SayanPandey in facebook#3256 * Fix - Updated location for Product Feeds by vinkmeta in facebook#3316 * Tweak - Removing internal wiki links by vinkmeta in facebook#3315 * Add - Introducing a centralized logger by vinkmeta in facebook#3313 * Fix - Update ratings and reviews query logic and fix tests by nrostrow-meta in facebook#3312 * Fix - Restoring the product sync tagging with integers by SayanPandey in facebook#3305 * Tweak - Removing Enable Sync checkbox by SayanPandey in facebook#3241 * Fix - Flush rewrite rules to ensure /fb-checkout endpoint is working correctly by ajello-meta in facebook#3301 * Tweak - Deprecating Product Sync tab by SayanPandey in facebook#3273 * Tweak - Updated GitHub PR template by vinkmeta in facebook#3304 * Fix - Changed json_encode to wp_json_encode to avoid phpcs issues by vinkmeta in facebook#3303 * Fix - Replaced json_encode with wp_json_encode by vinkmeta in facebook#3276 * Fix - Linting issues resolved for includes/ProductSets/Sync.phpby sol-loup in facebook#3188 * Fix - Linting issues resolved for includes/Utilities/Background_Remove_Duplicate_Visibility_Meta.php by sol-loup in facebook#3187 * Fix - Linting issues resolved for includes/Events/Event.php by sol-loup in facebook#3189 * Tweak - Enable Video sync at Variable Product Level by gurtejrehal in facebook#3291 * Fix - Revert facebook#3295 by vinkmeta in facebook#3299 Pull Request resolved: facebook#3444 Reviewed By: tzahgr Differential Revision: D77219857 Pulled By: vahidkay-meta fbshipit-source-id: 52148818ea2d6c1b937f3caa78e6071a258d17f3
…3453) Summary: ## Description - Update build-plugin-artifact workflow to execute on release branch push - Change node version to file package.json - Change 'Post build info comment on PR' step to run only on PR - Update release-plugin workflow to trigger on 'release/*/publish' branch ### Type of change Please delete options that are not relevant - Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) ## Checklist - [] I have commented my code, particularly in hard-to-understand areas, if any. - [] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Update build-plugin-artifact workflow to execute on release branch push Pull Request resolved: facebook#3453 Test Plan: See successful workflow run: https://github.com/facebook/facebook-for-woocommerce/actions/runs/15846147228 Reviewed By: akpurifb Differential Revision: D77220738 Pulled By: tzahgr fbshipit-source-id: 09eabfec472a52f64385d93ab877948e69a2716a
Summary: ## Description Fix filter not fully visible in Product Media Frame ### Type of change - Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) ## Checklist - [] I have commented my code, particularly in hard-to-understand areas, if any. - [] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Fix filter not fully visible in Product Media Frame Pull Request resolved: facebook#3459 Test Plan: 1. Run all tests : `npm run test:php` <img width="541" alt="image" src="https://github.com/user-attachments/assets/8456d111-9f7b-4e6a-9575-bf7ac5ff3b09" /> 2. Lint: `./vendor/bin/phpcs` 3. Run test `./vendor/bin/phpunit --filter test_prepare_product_videos` 4. **E2E Tests** - Single Product Update * Go to individual product. Upload a video using FB product video form field. * Click Publish->Update * Outcome : Video Synced to facebook - Batch API Update * Disconnect from facebook * Connect back and create a new catalog * Products are synced with batch API flow * Outcomes : New catalog created on facebook, with Videos synced at product level. ## Screenshots | **Before** | **After**| | -------- | ------- | |  | <img width="1267" alt="image" src="https://github.com/user-attachments/assets/99ffcd90-4ae5-4698-b650-beae87d5090d" /> | Reviewed By: SayanPandey, francorisso, devbodaghe Differential Revision: D77301128 Pulled By: gurtejrehal fbshipit-source-id: a240de2422bb19860f45acbea3a70598b1d7ff35
Summary: ## Description Fix age group normalisation error and updating supported FB fields for age group ### Type of change Please delete options that are not relevant - Fix (non-breaking change which fixes an issue) ## Checklist - [] I have commented my code, particularly in hard-to-understand areas, if any. - [] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Fix age group normalisation error and updating supported FB fields for age group Pull Request resolved: facebook#3460 Reviewed By: SayanPandey Differential Revision: D77302468 Pulled By: devbodaghe fbshipit-source-id: 2ba0f79a6e7be2acc3a5a93c5e2419b3138d326f
Summary: ## Description Add a workflow to set the readme.txt "Stable tag" to the version based on package.json version. The workflow: - Runs on "Deployment" environment - Validate the branch matches release/*/publish - Validate git tag for the new version exist - Validate svn tag for the new version exist - Updates "Stable tag" on readme.txt based on package.json version - Commits to SVN ### Type of change Please delete options that are not relevant - Add (non-breaking change which adds functionality) ## Changelog entry * Add - workflow to set the readme.txt "Stable tag" Pull Request resolved: facebook#3454 Test Plan: See successful workflow run: https://github.com/facebook/facebook-for-woocommerce/actions/runs/15858283545 Reviewed By: vahidkay-meta Differential Revision: D77303948 Pulled By: tzahgr fbshipit-source-id: 4e67c86021e1a742840d9321b85343d49d7df43e
Summary: ## Description This PR adds comprehensive unit tests for the `WebHook` handler class. The WebHook handler is responsible for managing incoming webhooks from Facebook, registering REST API endpoints, and processing webhook payloads. The tests ensure proper REST API integration, permission handling, and webhook data processing with various payload types. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for WebHook handler class Pull Request resolved: facebook#3456 Test Plan: 1. Run the unit tests: `composer test:unit tests/Unit/Handlers/WebHookTest.php` 2. Verify all tests pass 3. Run with code coverage to ensure comprehensive coverage of the WebHook class 4. Verify no existing tests are broken Test coverage includes: - REST API endpoint registration for `/wc-facebook/v1/webhook` - Permission callbacks for different user roles (admin, shop_manager, subscriber, guest) - Webhook callback processing with various JSON payloads: - Empty body - Null JSON - Valid JSON objects - Complex nested structures - Invalid JSON - Empty objects - JSON arrays - Verification that `fbe_webhook` action is fired with correct data - Response status codes (200 for valid data, 204 for empty/null) ## Screenshots N/A - This PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/14918173857523141 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/14355223904102541 Reviewed By: nrostrow-meta Differential Revision: D77259936 Pulled By: sol-loup fbshipit-source-id: 8bf19f1d37223cf65710bf6a87030a935ac5de8a
…es (facebook#3238) Summary: ## Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. ### Type of change Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Syntax change (non-breaking change which fixes code modularity, linting or phpcs issues) - Breaking change (fix or feature that would cause existing functionality to not work as expected) ## Checklist - [] I have commented my code, particularly in hard-to-understand areas. - [] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry One liner entry to be surfaced in changelog.txt Pull Request resolved: facebook#3238 Test Plan: Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. ## Screenshots Please provide screenshots or snapshots of the system/state both before and after implementing the changes, if appropriate ### Before ### After Reviewed By: nrostrow-meta, carterbuce Differential Revision: D75324380 Pulled By: mradmeta fbshipit-source-id: 80d6ba1cfd75f817cff981e4a806b830c0240859
Summary: ## Description This PR adds comprehensive unit tests for the `Setup` task class in the Admin namespace. The Setup task is responsible for managing the Facebook for WooCommerce setup process in the WooCommerce admin onboarding flow. The tests ensure proper functionality of all public methods and verify the task behaves correctly based on the connection status. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for Admin Setup task class Pull Request resolved: facebook#3455 Test Plan: 1. Run the unit tests: `composer test:unit tests/Unit/Admin/Tasks/SetupTest.php` 2. Verify all tests pass 3. Run with code coverage to ensure comprehensive coverage of the Setup class 4. Verify no existing tests are broken Test coverage includes: - Class instantiation and inheritance verification - All getter methods (ID, title, content, time, action URL) - Connection status checking (is_complete method) - Parent ID retrieval with fallback behavior - Method return type validation ## Screenshots N/A - This PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/5910974798679429 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/5629499823582427 Reviewed By: mradmeta Differential Revision: D77259939 Pulled By: sol-loup fbshipit-source-id: 9f7d711731005a828f1f44dfd4ebf2ac0aa7cad8
…butes settings (facebook#3462) Summary: ## Description Fixed a bug where the "attribute doesn't directly map to a Meta catalog field" banner would persist even after users mapped the attribute through the Facebook for WooCommerce attribute mapping interface. **Problem**: When users created a new WooCommerce attribute, a banner would appear prompting them to map it to a Meta catalog field. However, after mapping the attribute via the UI, the banner would continue to show until manually dismissed or expired (30 minutes), creating user confusion about whether the mapping was successful. **Root Cause**: The banner system used transients to store and display unmapped attribute notifications, but there was no mechanism to clear these transients when attribute mappings were updated. **Solution**: Added automatic banner clearing functionality that triggers when attribute mappings are saved. The system now checks if any currently displayed banner is for an attribute that has been mapped and automatically clears the banner transients. ### Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Fixed unmapped attribute banner persisting after attribute mapping is saved ## Test Plan **Test Scenario**: Verify banner automatically disappears after attribute mapping 1. **Setup**: - WordPress site with WooCommerce and Facebook for WooCommerce plugin active - Admin user with manage_woocommerce capability 2. **Steps to Reproduce**: - Go to WooCommerce → Products → Attributes - Create a new attribute with a custom name (e.g., "Test-Material") - Observe the banner appears: "Your new Test-Material attribute doesn't directly map to a Meta catalog field" - Go to Facebook for WooCommerce → Attribute Mapping - Map the "Test-Material" attribute to "Material" - Click "Save Changes" - Return to any admin page where the banner would display 3. **Expected Results**: - **Before Fix**: Banner continues to show despite successful mapping - **After Fix**: Banner automatically disappears after saving the mapping 4. **Additional Test Cases**: - Test with multiple attributes mapped simultaneously - Test banner dismissal still works manually - Test banner reappears for genuinely unmapped new attributes - Test edge case where banner exists but no ProductAttributeMapper class Pull Request resolved: facebook#3462 Test Plan: ## Test Plan **Test Scenario**: Verify banner automatically disappears after attribute mapping 1. **Setup**: - WordPress site with WooCommerce and Facebook for WooCommerce plugin active - Admin user with manage_woocommerce capability 2. **Steps to Reproduce**: - Go to WooCommerce → Products → Attributes - Create a new attribute with a custom name (e.g., "Test-Material") - Observe the banner appears: "Your new Test-Material attribute doesn't directly map to a Meta catalog field" - Go to Facebook for WooCommerce → Attribute Mapping - Map the "Test-Material" attribute to "Material" - Click "Save Changes" - Return to any admin page where the banner would display 3. **Expected Results**: - **Before Fix**: Banner continues to show despite successful mapping - **After Fix**: Banner automatically disappears after saving the mapping 4. **Additional Test Cases**: - Test with multiple attributes mapped simultaneously - Test banner dismissal still works manually - Test banner reappears for genuinely unmapped new attributes - Test edge case where banner exists but no ProductAttributeMapper class Reviewed By: vinkmeta Differential Revision: D77327822 Pulled By: devbodaghe fbshipit-source-id: 7829a1f1d886eb8b37d5453a1544f3f15f01dc82
Summary: ## Description This PR adds comprehensive unit tests for the `GoogleProductTaxonomy` class. The GoogleProductTaxonomy class contains the hierarchical taxonomy data structure used for categorizing products according to Google's Product Taxonomy standard. The tests validate the integrity and structure of the taxonomy data to ensure it maintains proper parent-child relationships and data consistency. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for GoogleProductTaxonomy class Pull Request resolved: facebook#3458 Test Plan: 1. Run the unit tests: `composer test:unit tests/Unit/Products/GoogleProductTaxonomyTest.php` 2. Verify all tests pass 3. Run with code coverage to ensure comprehensive coverage 4. Verify no existing tests are broken Test coverage includes: - Class instantiation and constant availability - Taxonomy structure validation: - Required fields (label, options, parent) exist - Field types are correct - Labels are non-empty strings - Parent-child relationship integrity: - Parents reference valid categories - Children appear in parent's options - No circular references - Data consistency: - Option IDs match taxonomy entries - Option labels match referenced category labels - No duplicate IDs - Hierarchy validation: - Root categories have empty parent - Maximum depth check (prevents infinite loops) - Leaf vs non-leaf category distribution - Known categories verification (Animals & Pet Supplies, Apparel & Accessories, etc.) - Label formatting (no HTML, proper trimming, reasonable length) - Special character handling - Reasonable taxonomy size (1000-10000 categories) ## Screenshots N/A - This PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/14073748927391840 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/5066549868754051 Reviewed By: nrostrow-meta Differential Revision: D77259930 Pulled By: sol-loup fbshipit-source-id: 15e7d03d660f775c78fb510d811d7118f6605cf5
Summary: ## Description This PR adds comprehensive unit tests for the `Bookings` integration class. The Bookings integration handles special pricing logic for WooCommerce Bookings products when syncing with Facebook. The tests ensure the integration properly detects the WooCommerce Bookings plugin and applies correct pricing filters only when needed. ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add unit tests for Bookings integration class Pull Request resolved: facebook#3457 Test Plan: 1. Run the unit tests: `composer test:unit tests/Unit/Integrations/BookingsTest.php` 2. Verify all tests pass 3. Run with code coverage to ensure comprehensive coverage of the Bookings class 4. Verify no existing tests are broken Test coverage includes: - Class instantiation and init action registration - Conditional hook registration based on WooCommerce Bookings plugin status - Product price filter behavior: - Non-bookable products (returns original price) - Products with Facebook price override (returns original price) - Edge cases (zero, negative, very large prices) - Private method testing via reflection (is_bookable_product) - Filter priority verification - Type preservation (integer prices remain integers) - Multiple instance handling ## Screenshots N/A - This PR only adds unit tests **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/12666374043850673 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/6473924740175542 Reviewed By: nrostrow-meta Differential Revision: D77259934 Pulled By: sol-loup fbshipit-source-id: 61fd69e82f80c6a2e164101a25646149587145cb
Summary: ## Description This PR creates unit tests for `./Jobs/AbstractChainedJob.php`. ### Type of change - [ ] Fix (non-breaking change which fixes an issue) - [ ] Add (non-breaking change which adds functionality) - [x] Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) - [ ] Break (fix or feature that would cause existing functionality to not work as expected) Pull Request resolved: facebook#3465 Test Plan: 1. Ensure all PHP and JS unit tests have passed. Reviewed By: sol-loup Differential Revision: D77407501 Pulled By: ajello-meta fbshipit-source-id: 84262c5f537412c5ef364f0892fe704755083f2f
…acebook#3467) Summary: ## Description This PR creates unit tests for `./Jobs/CleanupSkyvergeFrameworkJobOptions.php`. ### Type of change - [ ] Fix (non-breaking change which fixes an issue) - [ ] Add (non-breaking change which adds functionality) - [x] Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) - [ ] Break (fix or feature that would cause existing functionality to not work as expected) Pull Request resolved: facebook#3467 Test Plan: 1. Ensure all PHP and JS unit tests have passed. Reviewed By: sol-loup Differential Revision: D77407983 Pulled By: ajello-meta fbshipit-source-id: f11307c14bd283dd8b741a6a875b9ed4a59e0bcd
Summary: ## Description Fix release plugin workflow tag target from 'release/current' to current commit sha ### Type of change Please delete options that are not relevant - Fix (non-breaking change which fixes an issue) ## Changelog entry Fix - Release workflow tag target Pull Request resolved: facebook#3466 Test Plan: Workflow run: https://github.com/facebook/facebook-for-woocommerce/actions/runs/15911482022 Reviewed By: akpurifb Differential Revision: D77397154 Pulled By: tzahgr fbshipit-source-id: 4057089c4aac1be0a65ad7f4c5f7dd389f9fc5b0
…r-woocommerce/includes/API/ProductCatalog/ItemsBatch/Create (facebook#3797) Summary: Pull Request resolved: facebook#3797 Reviewed By: immadhavv Differential Revision: D89040255 fbshipit-source-id: 93d5a2aa452365e00a731d4073f3e045a337f701
…r-woocommerce/includes/API/Plugin/Settings/Uninstall (facebook#3801) Summary: Pull Request resolved: facebook#3801 Reviewed By: immadhavv Differential Revision: D89030314 fbshipit-source-id: 63a16dd96cbd3b80a0a9aeca6a47f0a149e10b8f
…r-woocommerce/includes/API/Exceptions (facebook#3802) Summary: Pull Request resolved: facebook#3802 Reviewed By: immadhavv Differential Revision: D89029171 fbshipit-source-id: 08bab1215460faf51d0b23291a41eaf522d9355c
…k#3809) Summary: ## Description make exactSearchSelect2Container E2E test helper more robust ### Type of change - Fix (non-breaking change which fixes an issue) ## Checklist - [X] I have commented my code, particularly in hard-to-understand areas, if any. - [X] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [X] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [X] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [X] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [X] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [X] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry make exactSearchSelect2Container E2E test helper more robust Pull Request resolved: facebook#3809 Test Plan: All GH actions checks should pass Reviewed By: immadhavv Differential Revision: D90110261 Pulled By: ashiqursuperfly fbshipit-source-id: 341301b5d731d8ae8302085618002e47c4cbc846
…er (facebook#3813) Summary: ## Description Added unit tests for Feed, Products , WC_Facebookcommerce_EventsTracker Improves code coverage from 36.6% to 37.4% ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [✔️] I have commented my code, particularly in hard-to-understand areas, if any. - [✔️] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [✔️] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [✔️] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [✔️] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [✔️] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [✔️] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Added unit tests for Feed, Products , WC_Facebookcommerce_EventsTracker Pull Request resolved: facebook#3813 Test Plan: PHP unit tests GH workflow should pass ## Screenshots ### Before NA ### After PHP unit tests GH workflow should pass Reviewed By: ashiqursuperfly Differential Revision: D90255293 Pulled By: immadhavv fbshipit-source-id: 4b03bd70af7cd316d68db6619762b1e74cc35d00
…ook#3816) Summary: ## Description Add unit tests for Admin.php and WCFacebookProductFeedTest.php Increases coverage from 37.4% to 40% ### Type of change Please delete options that are not relevant - Add (non-breaking change which adds functionality) ## Checklist - [✔️] I have commented my code, particularly in hard-to-understand areas, if any. - [✔️] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [✔️] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [✔️] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [✔️] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [✔️] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Add unit tests for Admin.php and WCFacebookProductFeedTest.php Pull Request resolved: facebook#3816 Test Plan: ## Screenshots ### Before ### After Php unit tests workflow to pass Reviewed By: ashiqursuperfly Differential Revision: D90260894 Pulled By: immadhavv fbshipit-source-id: 762d8d52863c8a1b4ab22ce45f3f430655f7783e
Summary: ## Description Add tests covering async product sync, meta change tracking, draft deletion, batch API operations, and AJAX handlers for facebook-commerce.php ### Type of change - Add (non-breaking change which adds functionality) ## Checklist - [X] I have commented my code, particularly in hard-to-understand areas, if any. - [X] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [X] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [X] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [X] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [X] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [X] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Add tests covering async product sync, meta change tracking, draft deletion, batch API operations, and AJAX handlers for facebook-commerce.php Pull Request resolved: facebook#3815 Test Plan: All GH Actions checks should PASS Reviewed By: immadhavv Differential Revision: D90264031 Pulled By: ashiqursuperfly fbshipit-source-id: 86da485dbc5e50c9b47ee15ac3e9d79989249268
Summary: Pull Request resolved: facebook#3795 Pull Request resolved: facebook#3790 ## Description Adds a test to validate the apply_filters change from 3.5.14 that ensures setcookie is only called in param_builder_server_setup when the facebook_for_woocommerce_integration_pixel_enabled filter returns true. The test uses a data provider to verify both enabled and disabled cases. ### Type of change Please delete options that are not relevant - Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Add additional test coverage for excluding cookies when pixel disabled ## Test Plan ``` $ ./vendor/bin/phpunit tests/Unit/Events/FacebookCommerceEventsTrackerTest.php Installing... Running as single site... To run multisite, use -c tests/phpunit/multisite.xml Loading Polylang for localization integration tests... Installing WooCommerce... Not running ajax tests. To execute these, use --group ajax. Not running ms-files tests. To execute these, use --group ms-files. Not running external-http tests. To execute these, use --group external-http. PHPUnit 9.6.28 by Sebastian Bergmann and contributors. ............ 12 / 12 (100%) Time: 00:00.761, Memory: 85.00 MB OK (12 tests, 13 assertions) ``` Differential Revision: D89679204 fbshipit-source-id: 83b9399dc9658e4b8fb2230706ad41021f002fa8
Summary: Pull Request resolved: facebook#3800 ## Description This change adds a secrets validation step before running E2E tests, preventing test failures on forks where secrets are not configured. When required secrets (`TEST_SITE_HOST` and `FB_TEST_META_BUSINESS_ASSETS`) are missing, a warning is displayed informing contributors that E2E tests will run daily after merge. Additionally, a daily scheduled run at 8am UTC ensures continuous validation of the plugin functionality. Scheduled runs on the facebook repository will fail if secrets are not properly configured. ### Type of change - Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). ## Changelog entry Add secrets validation for E2E tests and daily scheduled runs at 8am UTC. Reviewed By: devbodaghe, ryantobinmeta Differential Revision: D89731710 fbshipit-source-id: 0fe2137afdeb70a011cf855574c354ad347a4942
Summary: ## Description unused variable warning & bug fix The fix defines $should_use_billing_info based on whether the billing phone number is available. The logic is: If $billing_phone_number is not empty → use billing info (phone + country) Otherwise → use shipping info (phone + country) This ensures consistent behavior: whichever source provides the phone number also provides the country code for the phone number formatting. https://wordpress.org/support/topic/plugin-throws-a-warning/ https://wordpress.org/support/topic/error-in-log-report/ ### Type of change - Fix (non-breaking change which fixes an issue) ## Checklist - [] I have commented my code, particularly in hard-to-understand areas, if any. - [] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry One liner entry to be surfaced in changelog.txt Pull Request resolved: facebook#3776 Reviewed By: devbodaghe Differential Revision: D90691306 Pulled By: rithikb24 fbshipit-source-id: cac304af21c38c4debdfd76ec6cb065d307af0da
…, string given in fbproduct.php:1775 (facebook#3822) Summary: ## Description Fix TypeError: array_map(): Argument 2 must be of type array, string given in `fbproduct.php:1775`. #### Bug - The `get_product_category_ids()` method in fbutils.php was returning the string 'Invalid product ID' when a product doesn't exist, but the only caller in fbproduct.php passes this return value directly to array_map(), which expects an array. - Root cause: When E2E tests (or any code path) call `prepare_product()` on a deleted/non-existent product ID, the call chain reaches `get_product_category_ids()` which returned a string instead of an empty array. #### Fix Return `[]` instead of 'Invalid product ID' to match: - The method's docblock which specifies return Array - The sibling method `get_excluded_product_tags_ids()` which already returns `[]` for invalid products - The expectation of the only caller (`array_map()`) ### Type of change - Fix (non-breaking change which fixes an issue) ## Checklist - [X] I have commented my code, particularly in hard-to-understand areas, if any. - [X] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [X] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [X] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [X] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [X] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [X] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Fix TypeError: array_map(): Argument 2 must be of type array, string given in `fbproduct.php:1775`. Pull Request resolved: facebook#3822 Test Plan: All GH actions checks should PASS ### Before ``` Uncaught TypeError: array_map(): Argument 2 ($array) must be of type array, string given in /includes/fbproduct.php:1775 ``` ### After No error - method returns empty array for non-existent products, consistent with sibling method behavior. Reviewed By: mshymon Differential Revision: D91225933 Pulled By: ashiqursuperfly fbshipit-source-id: a18f38ebc612a5e15a80fe3e8128ec3d242f5b62
Summary: ## Description Update param builder library to 1.2.0 ### Type of change Please delete options that are not relevant - Add (non-breaking change which adds functionality) ## Checklist - [X] I have commented my code, particularly in hard-to-understand areas, if any. - [X] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [X] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [X] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [X] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [X] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [X] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry One liner entry to be surfaced in changelog.txt Pull Request resolved: facebook#3825 Test Plan: Manual test ## Screenshots Please provide screenshots or snapshots of the system/state both before and after implementing the changes, if appropriate ### Before <img width="1911" height="1071" alt="Screenshot 2026-01-21 at 12 12 51 PM" src="https://github.com/user-attachments/assets/73c40ac6-32f3-4ae2-8524-03126bd1851b" /> ### After <img width="1896" height="1055" alt="Screenshot 2026-01-21 at 1 09 22 PM" src="https://github.com/user-attachments/assets/5900fa49-045a-49a8-a190-96a23002c1bd" /> Reviewed By: jczhuoMeta, vahidkay-meta, hongj-src Differential Revision: D91144077 Pulled By: chc421 fbshipit-source-id: 953334276b450416dc4038c22b81db4b5d7ec3ef
Summary: ## Description ### Before: The E2E test suite had ~64 helpers written in JS and PHP: JS helpers lived in a single 1500+ line test-helpers.js file mixing unrelated concerns (auth, products, Facebook sync, CSV generation, plugins) PHP helpers were scattered in the root tests/e2e/ directory alongside JS test files This lack of structure made helpers difficult to find, understand, and reuse—slowing down iteration on the test suite. ### After: This PR reorganizes all helpers into a domain-based folder structure: ``` tests/e2e/helpers/ ├── js/ │ ├── auth/ │ ├── products/ │ ├── facebook/ │ ├── wordpress/ │ ├── events/ │ └── ... ├── php/ │ ├── sync-validator.php │ ├── product-creator.php │ └── ... ``` Helpers are now grouped by use-case (products, facebook, wordpress, etc.) and separated by language, making them easier to locate and maintain. A barrel export (helpers/js/index.js) provides clean imports for spec files. ### Type of change - Fix (non-breaking change which fixes an issue) ## Checklist - [X] I have commented my code, particularly in hard-to-understand areas, if any. - [X] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [X] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [X] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [X] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [X] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [X] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry reorganize E2E test suite helpers into domain-based folder structure Pull Request resolved: facebook#3821 Test Plan: All GH actions checks should PASS Reviewed By: immadhavv Differential Revision: D90678515 Pulled By: ashiqursuperfly fbshipit-source-id: 0313702b33854db929c13826cb248985247eb0bc
Summary: ## Description These files should have been added on this PR: facebook#3821 However, when the PR was merged and commited, this `helpers/js/facebook` folder is not showing up on `main`. We still have to investigate how this could happen. Further evidence it was on the original PR: - https://github.com/facebook/facebook-for-woocommerce/tree/5eec457b791d61255fe646de129988d24dad1dc1/tests/e2e/helpers/js/facebook - [D90678515](https://www.internalfb.com/diff/D90678515) This PR tries adding the folder back. ### Update 1: looks like these files got added correctly to fbcode as well, just didnt sync to GH: https://www.internalfb.com/code/fbsource/[5104aa841dd8]/fbcode/signals/opensource/facebook-for-woocommerce/tests/e2e/helpers/js/facebook/ ### Update 2: Judging by the export [preview](https://www.internalfb.com/intern/opensource/export/preview/D90678515/) of the diff that was landed, seems to me like there could be sth like a .export-ignore file that mentions folders named facebook wont be exported. Weird that the phab tests didn't catch this. ### Type of change - Fix (non-breaking change which fixes an issue) ## Checklist - [X] I have commented my code, particularly in hard-to-understand areas, if any. - [X] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [X] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [X] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [X] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [X] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [X] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry add helpers/js/plugin Pull Request resolved: facebook#3831 Test Plan: - The diff export preview should contain all 4 changed files: https://www.internalfb.com/intern/opensource/export/preview/D91255308/ - GH actions checks should pass Reviewed By: cshing-meta Differential Revision: D91255308 Pulled By: ashiqursuperfly fbshipit-source-id: 546e4cc689c94b3cf4ad6d9db8c64f3cc9a223dc
Summary: ## Description Fixed a latent infinite recursion bug in WC_Facebook_Product::get_post_data() where the method would call itself recursively when get_post is not callable, potentially leading to a stack overflow. Changes Changed the fallback return from $this->get_post_data() to null in includes/fbproduct.php. Returns null instead of recursively calling itself in the edge case Adds null checks in the two calling methods (get_fb_description() and get_fb_short_description()) to handle the null return gracefully by returning an empty string through the existing filters Risk: Minimal - only affects an edge case that would previously crash. ### Type of change Please delete options that are not relevant - Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) ## Checklist - [yes] I have commented my code, particularly in hard-to-understand areas, if any. - [yes] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [yes] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [yes] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [yes] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [yes] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [yes] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry fixed recursive function call for get_post_data() Pull Request resolved: facebook#3824 Test Plan: Tested description in scuba logs + e2e tests https://fburl.com/scuba/product_graph_api/fhva7v88 Reviewed By: devbodaghe Differential Revision: D91118216 Pulled By: rithikb24 fbshipit-source-id: 068b3460bc14e39dc7531857a8669f975a3f0b15
Summary:
## Description
1. **Fix unsafe domain check** in `capture.js`: Use proper URL parsing (`URL` API) instead of string matching to correctly validate Facebook pixel request domains, paths, and query parameters. This was producing a warning ("insecure domain check") on diffs.
2. **Add missing await** in `plugin/options.js`: Fix async/await issue.
### Type of change
- Fix (non-breaking change which fixes an issue)
## Checklist
- [x] I have commented my code, particularly in hard-to-understand areas, if any.
- [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors.
- [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors.
- [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)).
- [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes.
- [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality.
- [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)).
## Changelog entry
Fix unsafe domain matching and missing await in E2E test helpers.
Pull Request resolved: facebook#3829
Test Plan: GH actions checks should PASS
Reviewed By: rithikb24
Differential Revision: D91784120
Pulled By: ashiqursuperfly
fbshipit-source-id: 65d86ce7aedf5297e8737d27d05f547dcff5d28a
…3836) Summary: ## Description This change replaces the deprecated `wc_enqueue_js()` usage with a WordPress-native approach using `wp_register_script()`, `wp_enqueue_script()`, and `wp_add_inline_script()`. ### Type of change - Fix (non-breaking change which fixes an issue) ## Checklist - [X] I have commented my code, particularly in hard-to-understand areas, if any. - [X] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [X] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [X] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [X] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Fix: Replace deprecated wc_enqueue_js() with WordPress inline script API for WooCommerce 10.4+ compatibility. Pull Request resolved: facebook#3836 Reviewed By: rafael-curran Differential Revision: D91896525 Pulled By: vahidkay-meta fbshipit-source-id: 5720c07962c164de85974ea6be72690893d8770a
…tion page registration. (facebook#3834) Summary: ## Description Suppressed the composer autoload warnings, for the classes that violate psr-4 intentionally ( legacy reasons/tech debt ) Fixed the way Language override-related and fbcollection-related classes load. Also fixed a bug with how the rewrite-rules for registering a new endpoint were flushed. The new way ensures that flush happens on plugin activation/deactivations and new plugin updates. Also ensured that this doesn't deteriorate the performance for the users in terms of page load time. Also fixed an issue where the built artifacts were double zipped on Github ### Type of change Please delete options that are not relevant - Fix (non-breaking change which fixes an issue) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Fix - Addressed composer autoload warnings. also fixed a bug regarding fbcollection page registration. Pull Request resolved: facebook#3834 Test Plan: On a website that already has the plugin: * check if this endpoint exists: <SITE-URL>\fbcollection\ ** Whether it shows or shows page not found, when upgrading the plugin to the version with this fix, it should show a list of products * Upgrade to this version, and then install WPML. Create a new translation for a product, that should be sync'd to Meta through Language feeds. Debug logs should now show any new warning/error Reviewed By: rafael-curran Differential Revision: D91899079 Pulled By: vahidkay-meta fbshipit-source-id: 91a4a79dcc82741ced99c43a05130c68fc0dc754
Summary: ## Description This PR aims to fix the bugs that we found during alpha test, as follows: 1. Variable products were not properly handled 2. WPML / PLL translated product ids were not handled properly 3. The only chars that were accounted for were underlines. This caused issues on websites that had other symbols in their SKUs 4. Double urlencoded requests 5. ( flush rules not happening was addressed in another PR: facebook#3834 ) ### Type of change Please delete options that are not relevant - Fix (non-breaking change which fixes an issue) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Fix - Addressed the bugs in fbcollection page Pull Request resolved: facebook#3837 Test Plan: Ensure that when the url is incorrect, WARNING logs are created for the first 20 problematic requests. Test the fbcollection page in the following scenarios: - No clicked_product_id or shown_product_ids values => Incorrect input => Should show all products - Only 1 incorrect clicked_product_id => Incorrect input => Should show all products - Multiple clicked_product_id values => Incorrect input => Should show all products - One correct clicked_product_id and multiple shown_product_ids ( valid + invalid ) => Should show all valid products - Only 1 correct clicked_product_id => Collection page should only show that product - Without clicked_product_id, but with shown_product_id => Shows all shown_product_ids The project should properly handle various product types ( simple, grouped, variable ) Also for the ids: - if they are a numeric value => Will be parsed properly - if they are a combination of any value+symbols, as long as they have _ + woo id, they are parsed correctly. For translations, if the user is on the french page, and there's a french translation of the product, that french product will be shown. Otherwise, the default language product will be shown. Reviewed By: rafael-curran Differential Revision: D91898925 Pulled By: vahidkay-meta fbshipit-source-id: de5c706600c907c612b8956e8242a7786019d9a0
Summary: Fix - Fix/collection page bugs - Batch 1 by vahidkay-meta in facebook#3837 Fix - Fixed composer autoload warnings. also fixed a bug regarding fbcollection page registration. by vahidkay-meta in facebook#3834 Fix - Replace deprecated wc_enqueue_js with wp_add_inline_script by ukilla in facebook#3836 Dev - fix unsafe domain check warning on capture.js by ashiqursuperfly in facebook#3829 Tweak - fix: recursion call bug by rithikb24 in facebook#3824 Dev - retry adding helpers/js/facebook by ashiqursuperfly in facebook#3831 Dev - organize E2E test helpers by ashiqursuperfly in facebook#3821 Update - update parambuiler library to 1.2.0 by chc421 in facebook#3825 Fix - Fix TypeError: array_map(): Argument facebook#2 must be of type array, string given in fbproduct.php:1775 by ashiqursuperfly in facebook#3822 Add - fix for unused variable by rithikb24 in facebook#3776 Tweak - Restrict E2E tests to facebook repo and add daily schedule (facebook#3799) by jarretth in facebook#3800 Tweak - Add param_builder_server_setup test (facebook#3790) by jarretth in facebook#3795 Dev - add additional unit tests for facebook-commerce.php by ashiqursuperfly in facebook#3815 Add - Add unit tests for Admin.php and WCFacebookProductFeedTest.php by immadhavv in facebook#3816 Add - Added unit tests for Feed, Products , WC_Facebookcommerce_EventsTracker by immadhavv in facebook#3813 Dev - make exactSearchSelect2Container E2E test helper more robust by ashiqursuperfly in facebook#3809 Add - Added User consent check for events tracking test by immadhavv in facebook#3789 Dev - remove tests.describe.serial by ashiqursuperfly in facebook#3788 Add - Add test to check plugin compatibility with other major plugins by immadhavv in facebook#3785 Dev - add E2E test for product attribute mapping and syncing by ashiqursuperfly in facebook#3784 Dev - Catalog rotation by ashiqursuperfly in facebook#3781 Add - DevmateWooCommerceGenerateTests: Add tests for facebook-commerce-events-tracker.php by immadhavv in facebook#3783 Fix - Fix bug - Remove "Delete all products" button as it calls an unimplemented method by immadhavv in facebook#3782 Add - Plugin level e2e tests remaining by immadhavv in facebook#3780 Add - Add workflow to auto-label internal PRs by immadhavv in facebook#3769 Add - e2e test for csv import update by rithikb24 in facebook#3762 Dev - fix batch api E2E test category leak bug by ashiqursuperfly in facebook#3763 Add - Adding Profit Margin signal to AddToCart and Purchase events by vahidkay-meta in facebook#3730 Dev - add E2E test for product sync batch api monitoring by ashiqursuperfly in facebook#3760 Add - Catalog api e2e tests plugin level by immadhavv in facebook#3761 Dev - add E2E test to create product from feed file by ashiqursuperfly in facebook#3754 Add - CAPI/Pixel e2e tests added for remaining events, framework updated. by immadhavv in facebook#3755 Tweak - standarize tests by rithikb24 in facebook#3745 Dev - add E2E tests to verify category/product_set update and delete by ashiqursuperfly in facebook#3744 Dev - add E2E test for product set creation by ashiqursuperfly in facebook#3740 Pull Request resolved: facebook#3847 Reviewed By: rafael-curran Differential Revision: D92371690 Pulled By: vahidkay-meta fbshipit-source-id: 0fae681b80c81c757c9bea8c80fb6c001a27de0f
Summary: Pull Request resolved: facebook#3844 Bumps capi-param-builder-php dependency from ^1.2.0 to ^1.2.1. No breaking changes, changelog can be found here: https://github.com/facebook/capi-param-builder/blob/v1.2.1/php/CHANGELOG.md Also, extracts the hardcoded CAPI param builder JavaScript URL into a class constant `CAPI_PARAM_BUILDER_JS_URL`. Reviewed By: hongj-src, vahidkay-meta Differential Revision: D92070091 fbshipit-source-id: a9fe2200acc5b01a3f94b64f651e849fcc079f5b
Summary: Polylang latest version may not be compatible with PHP 7.4, causing CI failures. This change pins the Polylang version to 3.7.7 for PHP 7.4 builds while allowing other PHP versions to use the latest Polylang release. Pull Request resolved: facebook#3851 Reviewed By: vahidkay-meta Differential Revision: D92762189 Pulled By: jarretth fbshipit-source-id: bfda3bd8bec216b93b1bb9b74cab1cb2652e2d82
Summary: Two different retailer IDs can be used based on if the product has a SKU. This uses. the a method that handles both for the expected value instead of assuming FB_RETAILER_ID_PREFIX Pull Request resolved: facebook#3852 Reviewed By: vahidkay-meta, rafael-curran Differential Revision: D92768919 Pulled By: jarretth fbshipit-source-id: 1f3d40b6fd19f6209cda20673f4b741dedcc68c6
facebook#3823) Summary: ## Description This PR fixes a severe performance issue where an expensive SQL query was running on every frontend page load, causing 1.5+ second delays and timeout errors. **The Problem:** The query `SELECT option_value FROM wp_options WHERE option_name LIKE 'wc_facebook_background_product_sync_job_%' AND (option_value LIKE '%"status":"processing"%')` was executing on every request because: 1. Double `LIKE` clauses cannot use indexes efficiently, causing full table scans 2. The query ran on frontend requests where it's not needed 3. Results were never cached **The Solution:** 1. **Frontend Guards** - `is_queue_empty()` and `get_jobs()` now return early on frontend requests (when not in admin, AJAX, or cron context) 2. **Transient Caching** - Query results are cached indefinitely until explicitly invalidated 3. **Smart Cache Invalidation** - Cache is cleared when jobs are created, completed, failed, or deleted **Impact:** This single query accounted for ~25% of total page load time on affected stores. ### Type of change - Fix (non-breaking change which fixes an issue) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [ ] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Fix: Resolved performance issue where background sync job queries caused slow page loads on frontend requests. Pull Request resolved: facebook#3823 Test Plan: ### Automated Tests Run the new unit tests: ./vendor/bin/phpunit --filter BackgroundJobHandlerTest ./vendor/bin/phpunit --filter SyncTest ./vendor/bin/phpunit --filter DebugToolsTest**Results:** 46 tests, 98 assertions - all passing ### Manual Testing 1. **Frontend Performance Test:** - Install Query Monitor plugin - Visit any frontend page (shop, product, cart) - Verify the `wc_facebook_background_product_sync_job_%` query no longer appears 2. **Admin Functionality Test:** - Go to WooCommerce > Facebook - Trigger a product sync - Verify sync status shows correctly (processing → complete) - Verify products sync successfully to Facebook catalog 3. **Cache Invalidation Test:** - Start a product sync - Check transient exists: `get_transient('wc_facebook_background_product_sync_queue_empty')` - Complete or cancel the sync - Verify transient is cleared 4. **Debug Tools Test:** - Go to WooCommerce > Status > Tools - Run "Delete background sync job options" - Verify cache transients are also cleared ## Screenshots ### Before Query Monitor showing the expensive query on every frontend request: - Query: `SELECT option_value FROM wp_options WHERE option_name LIKE 'wc_facebook_background_product_sync_job_%' AND (option_value LIKE '%"status":"processing"%')` - Execution time: ~1.63 seconds per page load ### After - Query no longer runs on frontend requests - Admin/cron contexts use cached results - Cache invalidates automatically when job status changes Reviewed By: sol-loup, vahidkay-meta Differential Revision: D91487986 Pulled By: devbodaghe fbshipit-source-id: 89bb9e09490c117e97e212d5d4e3286461697f20
…acebook#3846) Summary: ## Description Improved composer.json to have the package version number, to prevent incorrect versions from being set in the built artifacts. excluded .github/** files from the built artifacts. Automated the comparison of release artifact and marketplace artifact. Also fixed the folder structure for the built release artifact ### Type of change Please delete options that are not relevant - Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Optimize release process, automate the marketplace artifact verification Pull Request resolved: facebook#3846 Test Plan: This needs to be manually verified before we can release it. These need to be verified: - The built artifact zip file in Prepare release action should have the correct structure: Everything should be under facebook-for-woocommerce folder - The built artifact on the publish branch should not have dev-release/p<VERSION>/publish as the version and pretty_version - in the built artifact, there shouldn't be **/.github/*.yml files included - The zip file built as a part of the Prepare-release action should be compared to the version on the Marketplace( https://downloads.wordpress.org/plugin/facebook-for-woocommerce.zip ). It should fail if they don't match in the files and file contents. Reviewed By: rafael-curran Differential Revision: D92841957 Pulled By: vahidkay-meta fbshipit-source-id: 8bbd56e986b670aac9290ce27e23ef5ad6eb6719
…3850) Summary: Context: This PR builds on [https://github.com/facebook/facebook-for-woocommerce/issues/3616](https://github.com/facebook/facebook-for-woocommerce/pull/3616). While testing the above PR, 2 CAPI Purchase events were firing instead of 1 during the place order flow. The issue was that the `inject_purchase_event` method is hooked to multiple WooCommerce actions (both server-side and browser-side). The logic correctly skips duplicate server events using 2 context-specific flags (`META_PURCHASE_TRACKED_BROWSER` and `META_PURCHASE_TRACKED_SERVER`). But, by the time the browser hook (`woocommerce_thankyou`) fires, it bypasses this guard and sends a second CAPI event. Fix: Only the server context now sends the CAPI event. The browser context (`woocommerce_thankyou`) only injects the pixel for client-side tracking. Expected behavior: 1 CAPI event + 1 pixel event during the place order flow. https://github.com/user-attachments/assets/0f0365df-fddc-4086-9d29-5423a1c048ba ## Checklist - [] I have commented my code, particularly in hard-to-understand areas, if any. - [] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). Pull Request resolved: facebook#3850 Test Plan: Run `./vendor/bin/phpunit --filter FacebookCommerceEventsTrackerTest` and all tests should pass. Expected behavior: 1 CAPI event + 1 pixel event during the place order flow. https://github.com/user-attachments/assets/0f0365df-fddc-4086-9d29-5423a1c048ba Reviewed By: vahidkay-meta Differential Revision: D92972746 Pulled By: cshing-meta fbshipit-source-id: 4ed69c7670953afb0c828ead666aeea3be019439
…acebook#3854) Summary: Added logging to understand if fbcollection can be reliably used. Also fixed some warnings in facebook-commerce-pixel-event.php ## Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. ### Type of change Please delete options that are not relevant - Tweak (non-breaking change which fixes code modularity, linting or phpcs issues) ## Checklist - [x] I have commented my code, particularly in hard-to-understand areas, if any. - [x] I have confirmed that my changes do not introduce any new PHPCS warnings or errors. - [x] I have checked plugin debug logs that my changes do not introduce any new PHP warnings or FATAL errors. - [x] I followed general Pull Request best practices. Meta employees to follow this [wiki]([url](https://fburl.com/wiki/2cgfduwc)). - [x] I have added tests (if necessary) and all the new and existing unit tests pass locally with my changes. - [x] I have completed dogfooding and QA testing, or I have conducted thorough due diligence to ensure that it does not break existing functionality. - [x] I have updated or requested update to plugin documentations (if necessary). Meta employees to follow this [wiki]([url](https://fburl.com/wiki/nhx73tgs)). ## Changelog entry Tweak - Added logging to detect if we can reliably use fbcollection Pull Request resolved: facebook#3854 Test Plan: To read the logs and check if the new flag is added: is_collectionpage_reliably_available Reviewed By: mradmeta Differential Revision: D92954319 Pulled By: vahidkay-meta fbshipit-source-id: b6cd978de9eaf2cadb4f4b555edd0aded691f445
This commit adds comprehensive unit test coverage for the WC_Facebookcommerce_Iframe_Whatsapp_Utility_Event class to verify the fix for issue facebook#3841 and prevent future regressions. The tests cover: - Orders with billing phone only (primary test case for facebook#3841) - Orders with shipping phone only - Orders with both phones - Orders with no phones - Edge cases (whitespace, missing data) - All supported order statuses These tests specifically verify that the $should_use_billing_info variable is properly defined before use, preventing the undefined variable warning reported in issue facebook#3841. Fixes facebook#3841
|
Hi @faisalahammad! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Lines changed: 1036409 additions & 32473 deletions |
Summary
This PR adds comprehensive unit test coverage for the
WC_Facebookcommerce_Iframe_Whatsapp_Utility_Eventclass. The tests verify the fix for issue #3841 (undefined variable warning) and ensure this bug does not happen again in the future.Background
Issue #3841 reported PHP warnings about an undefined variable
$should_use_billing_infoin the WhatsApp utility event handler:The issue was already fixed in PR #3776 (merged Jan 14, 2026), but there were no unit tests to verify the fix or prevent future regressions.
Problem Analysis
Before the Fix (Old Code)
The variable was used without being defined first:
Result: PHP warning about undefined variable, logged multiple times per minute.
After the Fix (Current Code)
PR #3776 added proper variable definition:
Result: No warnings. The code correctly uses billing country when billing phone exists, otherwise uses shipping country.
Why This Fix Works
The logic ensures consistent data sourcing:
This makes sense because whichever address provides the phone number should also provide the matching country code for correct international dialing.
Changes in This PR
New Test File
File:
tests/Unit/WC_Facebookcommerce_Iframe_Whatsapp_Utility_Event_Test.phpTest Coverage (11 test cases):
Key Test Strategy
Each test uses PHP error handling to capture any undefined variable warnings:
Testing
To run these tests locally:
Why These Tests Are Important
Developer Notes
Test Design Choices
Why mock WhatsAppExtension: The
process_whatsapp_utility_message_event()method call might fail in test environment if WhatsApp extension is not available. The tests catch these exceptions and focus on verifying that the variable definition logic works correctly, which is the actual bug we are testing.Why error handlers: Using custom error handlers allows us to detect and verify that NO undefined variable warnings are generated during code execution, which is exactly what issue #3841 was about.
Why comprehensive scenarios: Different phone number combinations could expose different code paths. Testing all combinations ensures the fix works in every situation.
Impact
No breaking changes - This PR only adds tests, no production code is modified.
Zero risk - Tests verify existing behavior that is already working correctly.
Future safety - Prevents accidental reintroduction of the bug.
Checklist
Related
Closes #3841
Original fix: PR #3776 by @rithikb24 (already merged)
For Reviewers
This PR provides the missing test coverage that would have caught issue #3841 before it reached production. The tests are comprehensive, well-documented, and follow the existing test patterns in the codebase.
Recommendation: Approve and merge to improve overall code quality and test coverage.