Add E2E coverage for admin, consent, and event flows - #639
Conversation
Drive the plugins screen as admin and assert both actions complete with their success notice and no visible error notice, which is where a fatal during (de)activation would surface. REST calls pin the plugin to active before and after the test so a failure cannot leave the rest of the suite running without the plugin.
Fill every control on the integration settings form, save through WooCommerce's settings handler, and assert the values are repopulated from the database after the reload, covering the save round-trip the render test deliberately left out.
Assert the EEA default consent entry (regions, denied statuses, and the wait_for_update window) lands in the browser's dataLayer, and that a consent mode appended through the woocommerce_ga_gtag_consent_modes filter is delivered as well, exercising the documented customization contract end to end. Add a query-gated test snippet that appends a consent mode for a given region, running after the existing grant-all snippet.
The select content event was covered for the All Products block and the classic shortcode page, but not for the default shop page nor for opening a related product by its name; both complete the click-through coverage of the manual testing checklist.
Walk a product click-through from the shop, the product page, cart mutations, checkout, and the order confirmation with every event toggle off and assert none of the plugin's events reach GA, extending the disabled coverage beyond shop page interactions to every event surface including the server-side purchase capture.
Assert the gcs parameter on add_to_cart hits reflects wp_set_consent updates in both directions for both ad_storage and analytics_storage, which is the wire-level data Tag Assistant decodes, so the consent state carried by the events is verified without a manual Tag Assistant session. Every stage sets both categories explicitly because the plugin's defaults are region-scoped to the EEA and would leave the digits unset elsewhere; hits sent while a category is denied still arrive as consent-restricted pings.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe e2e test snippets add a later consent-mode filter callback for a sanitized regional URL parameter and switch the script dependency array to PHP short syntax without changing its contents. ChangesConsent-mode testing
Estimated code review effort: 2 (Simple) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/test-snippets/test-snippets.php (1)
50-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSuggestion: use short array syntax.
Replace
array()with[]for both arrays in this PHP file.As per coding guidelines, PHP must use short array syntax
[]instead ofarray().Proposed fix
- $modes[] = array( + $modes[] = [ 'analytics_storage' => 'granted', 'ad_storage' => 'granted', - 'region' => array( $region ), - ); + 'region' => [ $region ], + ];🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/e2e/test-snippets/test-snippets.php` around lines 50 - 54, Update the array declarations in the test snippet around the $modes assignment to use PHP short array syntax [] instead of array() for both the outer and nested arrays, preserving the existing keys and values.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/e2e/test-snippets/test-snippets.php`:
- Around line 50-54: Update the array declarations in the test snippet around
the $modes assignment to use PHP short array syntax [] instead of array() for
both the outer and nested arrays, preserving the existing keys and values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5a769e3a-1569-4a26-88da-1f11f144b2ff
⛔ Files ignored due to path filters (6)
tests/e2e/specs/gtag-events/blocks-pages.test.jsis excluded by none and included by nonetests/e2e/specs/gtag-events/disabled-events.test.jsis excluded by none and included by nonetests/e2e/specs/installation.test.jsis excluded by none and included by nonetests/e2e/specs/integration-settings.test.jsis excluded by none and included by nonetests/e2e/specs/js-scripts/consent-defaults.test.jsis excluded by none and included by nonetests/e2e/specs/js-scripts/wp-consent-api.test.jsis excluded by none and included by none
📒 Files selected for processing (1)
tests/e2e/test-snippets/test-snippets.php
The coding guidelines prefer [] over array(), and PHPCS does not enforce it, so these were not caught by lint. Address: #639 (review)
There was a problem hiding this comment.
Pull request overview
This PR expands the Playwright E2E suite to cover key admin flows (activation + settings persistence), consent-mode delivery/updates, and additional GA4 event surfaces—reducing reliance on manual verification for behaviors that can be observed via browser/network assertions.
Changes:
- Add E2E specs for plugin (de)activation and WooCommerce integration settings save/reload persistence.
- Add consent-mode E2E coverage for dataLayer default delivery, filter-appended modes, and wire-level
gcsconsent state on event hits. - Extend storefront event coverage (e.g.,
select_content) and add an end-to-end “all tracking disabled” purchase journey assertion.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/test-snippets/test-snippets.php | Adds a query-gated consent-mode appender snippet and adjusts script dependency array syntax for E2E flexibility. |
| tests/e2e/specs/js-scripts/wp-consent-api.test.js | Adds assertions that GA collect hits include updated consent state via the gcs parameter. |
| tests/e2e/specs/js-scripts/consent-defaults.test.js | New spec asserting consent defaults (EEA + filter-appended) reach the browser dataLayer. |
| tests/e2e/specs/integration-settings.test.js | Adds a settings save-and-reload persistence test and clears settings after the spec. |
| tests/e2e/specs/installation.test.js | New spec exercising plugin deactivate/reactivate flows via wp-admin with REST state pinning. |
| tests/e2e/specs/gtag-events/disabled-events.test.js | Adds a full shopper-journey assertion that no plugin events fire when all tracking is disabled. |
| tests/e2e/specs/gtag-events/blocks-pages.test.js | Adds select_content coverage from the shop page and related-product title clicks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| test.use( { storageState: process.env.ADMINSTATE } ); | ||
|
|
||
| const PLUGIN_SLUG = 'woocommerce-google-analytics-integration'; | ||
| const PLUGIN_REST_ROUTE = `plugins/${ PLUGIN_SLUG }/${ PLUGIN_SLUG }`; |

Changes proposed in this Pull Request:
This PR adds E2E coverage for admin flows, consent mode delivery, and the remaining event tracking surfaces, so manual testing can focus on what automation cannot observe.
data-pluginattribute because the action links' id attributes depend on data from the wp.org updates API and change when the environment is offline.woocommerce_ga_gtag_consent_modesfilter is delivered as well. A new test additionally asserts thegcsparameter on event hits reflectswp_set_consent()updates in both directions for bothad_storageandanalytics_storage, which is the wire-level data Tag Assistant decodes. One empirical constraint is documented in the test: the plugin's defaults are region-scoped to the EEA, so every stage sets both categories explicitly. Hits sent while a category is denied still arrive as consent-restricted pings.Checks:
Detailed test instructions:
npm run wp-env:upnpm run test:e2ehttps://github.com/woocommerce/woocommerce-google-analytics-integration/actions/runs/30073401752/job/89418847214
Changelog entry
No issues found.