Skip to content

Infrastructure/11740 playwright email reporting#12330

Open
eugene-manuilov wants to merge 41 commits intodevelopfrom
infrastructure/11740-playwright-email-reporting
Open

Infrastructure/11740 playwright email reporting#12330
eugene-manuilov wants to merge 41 commits intodevelopfrom
infrastructure/11740-playwright-email-reporting

Conversation

@eugene-manuilov
Copy link
Copy Markdown
Collaborator

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

🤖 This comment is automatically updated by CI workflows. Each section is managed independently.

📚 Storybook for 446fc7b:

📦 Build files for 446fc7b:

🎭 Playwright reports for 446fc7b:

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

Size Change: 0 B

Total Size: 2.31 MB

ℹ️ View Unchanged
Filename Size Change
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.css 124 B 0 B
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/reader-revenue-manager/block-editor-plugin/index.js 42.7 kB 0 B
dist/assets/blocks/reader-revenue-manager/common/editor-styles.css 307 B 0 B
dist/assets/blocks/reader-revenue-manager/common/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/reader-revenue-manager/contribute-with-google/index.js 5.88 kB 0 B
dist/assets/blocks/reader-revenue-manager/contribute-with-google/non-site-kit-user.js 5.07 kB 0 B
dist/assets/blocks/reader-revenue-manager/subscribe-with-google/index.js 5.88 kB 0 B
dist/assets/blocks/reader-revenue-manager/subscribe-with-google/non-site-kit-user.js 5.07 kB 0 B
dist/assets/blocks/sign-in-with-google/editor-styles.css 84 B 0 B
dist/assets/blocks/sign-in-with-google/editor-styles.js 0 B 0 B 🆕
dist/assets/blocks/sign-in-with-google/index.js 18.6 kB 0 B
dist/assets/css/googlesitekit-admin-css-********************.min.css 67.1 kB 0 B
dist/assets/css/googlesitekit-adminbar-css-********************.min.css 12.3 kB 0 B
dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 846 B 0 B
dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 8.89 kB 0 B
dist/assets/js/146-********************.js 963 B 0 B
dist/assets/js/201-********************.js 2.85 kB 0 B
dist/assets/js/314-********************.js 100 kB 0 B
dist/assets/js/315-********************.js 3.08 kB 0 B
dist/assets/js/379-********************.js 3.7 kB 0 B
dist/assets/js/590-********************.js 1.89 kB 0 B
dist/assets/js/640-********************.js 2.36 kB 0 B
dist/assets/js/909-********************.js 1.01 kB 0 B
dist/assets/js/analytics-advanced-tracking-********************.js 475 B 0 B
dist/assets/js/googlesitekit-activation-********************.js 25.1 kB +8 B (+0.03%)
dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 59.6 kB +7 B (+0.01%)
dist/assets/js/googlesitekit-admin-pointers-tracking-********************.js 5.35 kB 0 B
dist/assets/js/googlesitekit-adminbar-********************.js 36.1 kB +9 B (+0.02%)
dist/assets/js/googlesitekit-api-********************.js 7.99 kB 0 B
dist/assets/js/googlesitekit-block-tracking-********************.js 5.55 kB 0 B
dist/assets/js/googlesitekit-components-********************.js 5.82 kB 0 B
dist/assets/js/googlesitekit-consent-mode-********************.js 25.5 kB 0 B
dist/assets/js/googlesitekit-data-********************.js 1.73 kB 0 B
dist/assets/js/googlesitekit-datastore-forms-********************.js 7.01 kB 0 B
dist/assets/js/googlesitekit-datastore-location-********************.js 1.51 kB 0 B
dist/assets/js/googlesitekit-datastore-site-********************.js 18.5 kB 0 B
dist/assets/js/googlesitekit-datastore-ui-********************.js 7.16 kB 0 B
dist/assets/js/googlesitekit-datastore-user-********************.js 23 kB 0 B
dist/assets/js/googlesitekit-entity-dashboard-********************.js 72.8 kB +16 B (+0.02%)
dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 1.27 kB 0 B
dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 655 B 0 B
dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 1.27 kB 0 B
dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 1.26 kB 0 B
dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 1.29 kB 0 B
dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 1.34 kB 0 B
dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 990 B 0 B
dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 1.29 kB 0 B
dist/assets/js/googlesitekit-i18n-********************.js 6.16 kB 0 B
dist/assets/js/googlesitekit-key-metrics-setup-********************.js 53.4 kB +10 B (+0.02%)
dist/assets/js/googlesitekit-main-dashboard-********************.js 149 kB +20 B (+0.01%)
dist/assets/js/googlesitekit-metric-selection-********************.js 57.9 kB +7 B (+0.01%)
dist/assets/js/googlesitekit-modules-********************.js 26.3 kB +5 B (+0.02%)
dist/assets/js/googlesitekit-modules-ads-********************.js 48.9 kB +10 B (+0.02%)
dist/assets/js/googlesitekit-modules-adsense-********************.js 138 kB +14 B (+0.01%)
dist/assets/js/googlesitekit-modules-analytics-4-********************.js 191 kB +6 B (0%)
dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 23.6 kB +10 B (+0.04%)
dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 52.7 kB +9 B (+0.02%)
dist/assets/js/googlesitekit-modules-search-console-********************.js 67.2 kB +7 B (+0.01%)
dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 34.7 kB +9 B (+0.03%)
dist/assets/js/googlesitekit-modules-tagmanager-********************.js 30.4 kB +8 B (+0.03%)
dist/assets/js/googlesitekit-notifications-********************.js 68.5 kB +7 B (+0.01%)
dist/assets/js/googlesitekit-polyfills-********************.js 230 B 0 B
dist/assets/js/googlesitekit-settings-********************.js 135 kB +15 B (+0.01%)
dist/assets/js/googlesitekit-splash-********************.js 78.5 kB +13 B (+0.02%)
dist/assets/js/googlesitekit-user-input-********************.js 51.4 kB +9 B (+0.02%)
dist/assets/js/googlesitekit-vendor-********************.js 328 kB 0 B
dist/assets/js/googlesitekit-widgets-********************.js 104 kB +9 B (+0.01%)
dist/assets/js/googlesitekit-wp-dashboard-********************.js 62.1 kB +8 B (+0.01%)
dist/assets/js/runtime-********************.js 1.92 kB 0 B

compressed-size-action


// Ensure every notice after the first notice has a margin
// so the notices don't render with no gap.
//
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Stylelint blamed this and insisted it be removed. 🤷‍♂️

@zutigrm zutigrm mentioned this pull request Mar 19, 2026
19 tasks
Copy link
Copy Markdown
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Thanks @eugene-manuilov, this looks great overall, just a few things to address. Also note there are a few other comments from GitHub + annotations from JS Lint to review.

Comment on lines +97 to +106
- analyticsadmin.googleapis.com
- analyticsdata.googleapis.com
- searchconsole.googleapis.com
- oauth2.googleapis.com
- tagmanager.googleapis.com
- adsense.googleapis.com
- pagespeedonline.googleapis.com
- subscribewithgoogle.googleapis.com
- www.googleapis.com
- storage.googleapis.com
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should include googleads here too since it's used by PAX, if only to prevent requests to the real services. Also, people and siteverification are missing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Site verification uses www.googleapis.com, which is already added. See here: https://developers.google.com/site-verification/v1/webResource/get

Which one Google Ads API uses?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh interesting, ok, thanks 👍

Ads uses googleads.googleapis.com
See https://developers.google.com/google-ads/api/rest/design/overview#resource-oriented-design

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added

Comment on lines +38 to +46
update_user_option(
get_current_user_id(),
'googlesitekit_site_verified_meta',
'verified'
);

$settings = get_option( Search_Console_Settings::OPTION );
$settings['propertyID'] = 'http://localhost:9002';
update_option( Search_Console_Settings::OPTION, $settings );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we not use filters for these instead? Otherwise we're running these updates on every request. I think this is how we did it before, no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Slightly updated it to update the search console settings only once. Re site verification, not sure why but it works only when i do it like that. If I switch to the filter hook, it stops working.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah ok. I see we do it like that in our current E2E utility but it happens in a REST endpoint we call rather than on every request.

'should deliver a weekly email report',
{
annotation: [
withPlugins( 'mailpit.php', 'email-reporting.php' ),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think mailpit should be part of the always-on infra as an mu-plugin. No reason for it not to be, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so. If we don't use it, it shouldn't be activated in my opinion.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If we don't use it and an email is sent for whatever reason I believe it can result in a fatal error (at least in some situations, it has in the past). The service will be running anyways, so I don't see why we wouldn't have it as part of the infrastructure. We shouldn't need to remember to turn it on; we should only be concerned with assertions as to whether an email was sent or not.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ok, made it to be mu-plugin

*
* @param array $http_client_config Guzzle HTTP client configuration array.
*/
$http_client_config = apply_filters( 'googlesitekit_http_client_config', $http_client_config );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd rather not add a filter just for use in E2E, but I'm not sure there is another way. Alternatively, we could conditionally only apply it in tests/e2e – WDYT?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately, i can't find another way how to do it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

After thinking about this some more, I think we can overload the access token value which we're already controlling with a filter in tests to use a plain test-access-token. We can essentially append/embed additional metadata (or just pass json in this field, encoded if necessary) and then we can pass whatever we want through to the service and it will be contained in tests. This would be extensible to other values or configuration we want to send through as well. Yes, it gets encrypted (this is necessary) but it will be decrypted before being set in the authorization header. I think this should work since we should also never need to use a fixture for an unauthenticated response. Let me know what you think 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nice idea, updated.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually, it turned out if we do it this way, auto-authorization stops working. I had to revert it to the previous approach with the filter. I think we can create a ticket to address this challenge separately.

Comment on lines +258 to +266
try {
startServers();
} catch ( err ) {
global.console.error(
'Failed to start HTTPS server:',
err instanceof Error ? err.message : String( err )
);
global.console.log( 'Continuing with HTTP only.' );
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

startServers starts both http and https but there's no guarantee that http started successfully in the catch here, no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but that is correct. I don't really think we will actually need the http version though, because all APIs have https URLs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My point is that the messages here imply that http will always start but we can't say for sure. It would be better to just say that there was an error starting the servers and not claim that http will still work or that the error was from starting https specifically.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed extra logging

Copy link
Copy Markdown
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Thanks @eugene-manuilov this one is almost there, back to you for a few final things. See also my comment/replies on previous threads which aren't listed below.

Comment on lines +34 to +37
add_filter( 'googlesitekit_email_reporting_batch_id', fn() => 'test-batch-id' );

do_action_ref_array( Email_Reporting_Scheduler::ACTION_INITIATOR, array( $frequency ) );
do_action_ref_array( Email_Reporting_Scheduler::ACTION_WORKER, array( 'test-batch-id', $frequency, time() ) );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can do without the filter on the batch ID too, we just need to query/capture the batch it creates when the initiator runs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Updated.

Comment on lines +21 to +26
add_filter(
'wp_mail_from_name',
function () {
return 'Site Kit E2E Tests';
}
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's not override the from name – it shouldn't be necessary and it could be worth allowing for an assertion on the name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed

*
* @param string $batch_id The batch ID.
*/
$batch_id = apply_filters( 'googlesitekit_email_reporting_batch_id', wp_generate_uuid4() );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See my other comment on this one, as I think we can do without it as well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated

},
{
"keys": [
"+44 (20) 738 4500"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like a real number?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated

)
.join( '\n' );
const uniqueErrors: string[] = [];
errors.forEach( ( e ) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A number of lint warnings related to this as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants