Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the placement of the feature flag check for Ad Blocking Recovery settings #7203

Merged
merged 7 commits into from
Jun 27, 2023

Conversation

tofumatt
Copy link
Collaborator

@tofumatt tofumatt commented Jun 23, 2023

Summary

Addresses issue:

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 5.6.
  • 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.

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

github-actions bot commented Jun 23, 2023

Build files for 8fc8d6e have been deleted.

@github-actions
Copy link

github-actions bot commented Jun 23, 2023

Size Change: -3.84 kB (0%)

Total Size: 1.35 MB

Filename Size Change
./dist/assets/js/googlesitekit-activation-********************.js 24.2 kB +143 B (+1%)
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 52 kB +29 B (0%)
./dist/assets/js/googlesitekit-adminbar-********************.js 32.8 kB -433 B (-1%)
./dist/assets/js/googlesitekit-api-********************.js 9.85 kB -3 B (0%)
./dist/assets/js/googlesitekit-datastore-forms-********************.js 9.27 kB -6 B (0%)
./dist/assets/js/googlesitekit-datastore-site-********************.js 16.5 kB +31 B (0%)
./dist/assets/js/googlesitekit-datastore-ui-********************.js 9.36 kB -5 B (0%)
./dist/assets/js/googlesitekit-datastore-user-********************.js 23.3 kB +121 B (+1%)
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 66.4 kB +15 B (0%)
./dist/assets/js/googlesitekit-main-dashboard-********************.js 80.4 kB -8 B (0%)
./dist/assets/js/googlesitekit-modules-********************.js 21.1 kB -494 B (-2%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 104 kB -26 B (0%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 33.1 kB -437 B (-1%)
./dist/assets/js/googlesitekit-modules-analytics-********************.js 87.9 kB -506 B (-1%)
./dist/assets/js/googlesitekit-modules-optimize-********************.js 20.6 kB -28 B (0%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 21.3 kB -167 B (-1%)
./dist/assets/js/googlesitekit-modules-search-console-********************.js 52.7 kB -452 B (-1%)
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 32.2 kB -331 B (-1%)
./dist/assets/js/googlesitekit-settings-********************.js 48.7 kB -417 B (-1%)
./dist/assets/js/googlesitekit-splash-********************.js 66.7 kB -436 B (-1%)
./dist/assets/js/googlesitekit-user-input-********************.js 41.6 kB -429 B (-1%)
./dist/assets/js/googlesitekit-widgets-********************.js 17.6 kB -8 B (0%)
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 63 kB +7 B (0%)
ℹ️ View Unchanged
Filename Size
./dist/assets/css/googlesitekit-admin-css-********************.min.css 49.9 kB
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.2 kB
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 7.55 kB
./dist/assets/js/30-********************.js 2.8 kB
./dist/assets/js/31-********************.js 2.28 kB
./dist/assets/js/32-********************.js 3.72 kB
./dist/assets/js/33-********************.js 3.12 kB
./dist/assets/js/analytics-advanced-tracking-********************.js 769 B
./dist/assets/js/googlesitekit-components-gm2-********************.js 5.29 kB
./dist/assets/js/googlesitekit-components-gm3-********************.js 9.93 kB
./dist/assets/js/googlesitekit-data-********************.js 2.18 kB
./dist/assets/js/googlesitekit-datastore-location-********************.js 2.09 kB
./dist/assets/js/googlesitekit-i18n-********************.js 3.92 kB
./dist/assets/js/googlesitekit-polyfills-********************.js 379 B
./dist/assets/js/googlesitekit-vendor-********************.js 310 kB
./dist/assets/js/runtime-********************.js 1.26 kB

compressed-size-action

Copy link
Collaborator

@nfmohit nfmohit left a comment

Choose a reason for hiding this comment

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

Thank you for the work here, @tofumatt, absolutely accurate!

I'm being very nitpicky here. I understand updating stories/tests wasn't mentioned in the IB, however, test suites for both the AdBlockingRecoveryCTA and AdBlockingRecoveryToggle components include tests to verify if the adBlockerDetection feature flag is enabled.

AdBlockingRecoveryCTA:

[
'the Ad blocker detection feature flag is not enabled',
ACCOUNT_STATUS_PENDING,
SITE_STATUS_READY,
'',
false,
],

AdBlockingRecoveryToggle:

[ 'the Ad blocker detection feature flag is not enabled', false ],

Also, all the other tests within the above test suites set the adBlockerDetection feature flag to be enabled.

The tests still work flawlessly with them existing there. Now that the feature flag checks have been removed from the components within, do you think these checks are redundant and should be removed from the tests?

Also, the Storybook stories for AdBlockingRecoveryCTA and AdBlockingRecoveryToggle components set the adBlockerDetection feature flag to be enabled. For example:

Ready.parameters = {
features: [ 'adBlockerDetection' ],
};

Do you think these should also be removed?

@tofumatt
Copy link
Collaborator Author

tofumatt commented Jun 26, 2023

Nitpicks are okay, but also these are hardly nitpicks, great catches! 🙏🏻

The tests still work flawlessly with them existing there. Now that the feature flag checks have been removed from the components within, do you think these checks are redundant and should be removed from the tests?

Yes, they should be removed. Thank you for finding/noticing this! These it.each make for very unreadable tests in my view, and this is a prime example of why: it was totally unobvious to me that the uncommented/named variable there was adblocking detection unless I read through dozens of line of code 😆.

For future reference to any devs reading this, arrays of something like:

{
  testName: 'Adsense site status is not ready',
  accountStatus: ACCOUNT_STATUS_READY,
  siteStatus: SITE_STATUS_ADDED,
  recoverySetupStatus: '',
  adBlockerDetectionFeatureFlag: true,
},

over

[
  'Adsense site status is not ready',
  ACCOUNT_STATUS_READY,
  SITE_STATUS_ADDED,
  '',
  true,
],

for it.each would massively improve readability… though really we just shouldn't be using it.each to my mind as it's a tool for writing tests quick, and tests should be slow to write and quick to read 😉.

@nfmohit
Copy link
Collaborator

nfmohit commented Jun 26, 2023

I absolutely agree, thank you for the example!

Copy link
Collaborator

@nfmohit nfmohit left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
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 @tofumatt ! This is almost there, just one more thing which is needed.

<AdBlockingRecoveryToggle />
{ adBlockerDetectionEnabled && (
<Fragment>
<AdBlockingRecoveryCTA />
Copy link
Collaborator

Choose a reason for hiding this comment

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

This component is also rendered in the SettingsView which is still being rendered unconditionally.

) }
<AdBlockingRecoveryCTA />
</div>

Apologies, I missed this in the IB too.

@aaemnnosttv
Copy link
Collaborator

A few more things I noticed when looking at the SettingsView, only one of which is relevant here: the ABR setup status is only conditional based on its value, not the feature flag so this should also be addressed here

{ !! adBlockingRecoverySetupStatus?.length && (

Secondarily, I don't think these messages match the descriptions

{ adBlockingRecoverySetupStatus ===
'setup-confirmed' && (
<p className="googlesitekit-settings-module__meta-item-data">
{ __(
'Ad blocking recovery tag is not placed',
'google-site-kit'
) }
</p>
) }
{ adBlockingRecoverySetupStatus === 'tag-placed' && (
<Fragment>
<p className="googlesitekit-settings-module__meta-item-data">
{ __(
'Ad blocking recovery tag is placed',
'google-site-kit'
) }
</p>

I noticed this when the setup was completed and both toggles were on, but the view was showing Ad blocking recovery tag is not placed.

The tag is placed for both of these statuses – it's the blank string where they're not placed (this would probably be better as a named value as well. We also have an enum value for the statuses now as well but that's a minor detail. This one should be revisited and corrected separately.

I'll push a fix for the additional guards that were missed and send it back to you @tofumatt for MR 👍

cc: @kuasha420 ☝️

Copy link
Collaborator Author

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for catching that one @aaemnnosttv! 👍🏻

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