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

Fix 4472 - Display notice when DelayJS is activated with Autoptimize Aggregate JS already in effect #4501

Conversation

iCaspar
Copy link
Contributor

@iCaspar iCaspar commented Nov 12, 2021

Description

Please include a summary of the change and which issue is fixed/closed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #4472
Fixes #3707

Type of change

  • Enhancement (non-breaking change which improves an existing functionality)

Is the solution different from the one proposed during the grooming?

Yes
In the grooming I had thought we would be adding a helper notice into the DelayJS selection field. In fact, we are adding a notice to the notices area at the top of the page.
Also, to do this, we had been adding the notice via the 'settings_errors transient, but that was failing to display messages properly. Instead, this adds a method in the DelayJS Admin/Subscriber to check if Autoptimize Aggregate JS is active, and if so, uses add_settings_errors() for display.

How Has This Been Tested?

  • New Integration tests to confirm that the notice is added under expected conditions.
  • Check that notice is displayed properly on local environment.

Screen Shot 2021-11-17 at 9 32 55 AM

Checklist:

Please delete the options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@iCaspar iCaspar self-assigned this Nov 12, 2021
@iCaspar iCaspar added 3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting module: delay JS labels Nov 12, 2021
@iCaspar
Copy link
Contributor Author

iCaspar commented Nov 12, 2021

This approach should work, as the integration tests prove that notice data is added to the settings_errors transient array. But the notice is not appearing, due to the same bug that is causing #4314, namely there is something preventing any notice being displayed from the settings_errors transient when settings are updated.

Marking this as blocked by #4314.

@iCaspar iCaspar added status: blocked Issue or PR is blocked by external factor. Module: dashboard labels Nov 12, 2021
@iCaspar iCaspar changed the title Add tests and method for AO agg-js and wpr delayjs Fix 4472 - Display notice when DelayJS is activated with Autoptimize Aggregate JS already in effect Nov 12, 2021
@iCaspar iCaspar requested a review from a team November 17, 2021 14:37
@iCaspar iCaspar requested a review from a team November 17, 2021 15:03
@Mai-Saad Mai-Saad self-requested a review November 18, 2021 09:34
@Mai-Saad
Copy link
Contributor

Mai-Saad commented Nov 18, 2021

@iCaspar Please find notes below based on test analysis and exploratory test:

1- If Delay JS was enabled, then we enable auto-optimize with the aggregate JS features => no warning will be displayed (we will need to re-enable delay js to see the warning), can we display the warning without needing to re-enable Delay JS (maybe with cache clear, refresh settings)?

2- When Autooptimize aggregate js files and inline js is enabled along with WPR LL video and preview image, result in removing LL videos script from HTML => Do we need a separate GH issue for that? or is it something we can handle on this PR? (same already on trunk)

3- @piotrbak Q: Why not handle the current conflict, the same way as we do with minify/combine CSS/JS (disable the option and display red msg)?
Screenshot from 2021-11-18 12-27-13

4- Just for UI confirmation => Current msg which is displayed only when enable delay js while aggregate options are enabled in auto-optimize is as attached, is this what we need?
Screenshot from 2021-11-18 12-28-03

@piotrbak
Copy link
Contributor

piotrbak commented Nov 18, 2021

@Mai-Saad When it comes to the 3:
Minify and Combine CSS/JS are exactly the same features. It's not the case with DelayJS, as it's not causing errors, rather not working as good as it should, we decided to go with a educative warning approach.

@iCaspar Can we make the warning border yellow instead of blue?

@piotrbak
Copy link
Contributor

piotrbak commented Nov 18, 2021

@Mai-Saad

For 2:
Does it cause any issues with the video or lazyload?

For 4:
We're going to display the message when:

  1. Delay JS is enabled
  2. Autoptimize JS Aggregation is enabled

CSS files are disabled because the CSS optimisations are enabled in the Autoptimize, below we have an explanation

@iCaspar
Copy link
Contributor Author

iCaspar commented Nov 18, 2021

@piotrbak @Mai-Saad
On 1, please confirm that the User Story above is accurate. Per the current version of the story:
We will show the message when Autoptimize>JS Aggregation is already active and then DelayJS is activated (the behavior Mai observed). If we also want it to appear when the events happen in the reverse order (DelayJS is already active and then JSAggregation is activated) we should specify that behavior in the story. Otherwise, I think it is working as intended here.

On 2, interaction with Lazyload -- this PR is ONLY about messaging -- see the User Story. It will not include any fixes for conflicts with LazyLoad (or anything else).

On 3, see 2.

On 4, the message is (again) specified in the User Story.

@piotrbak
Copy link
Contributor

@iCaspar Will it be possible to cover both scenarios? We want to display the warning in all possible use cases. The same should be applied to other Autoptimize compatibilities. Sorry for the misunderstanding.

@iCaspar
Copy link
Contributor Author

iCaspar commented Nov 18, 2021

@piotrbak No problem. Let's update the User Story and I can make that change this morning.

This will display the notice as expected, but the integration test will not run in isolation. Other functions from preload still run on admin_notice.
@iCaspar iCaspar requested a review from a team November 22, 2021 18:57
Copy link
Contributor

@engahmeds3ed engahmeds3ed left a comment

Choose a reason for hiding this comment

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

Small minor comments

Copy link
Contributor

@Mai-Saad Mai-Saad left a comment

Choose a reason for hiding this comment

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

Working as expected.

As per discussion, we agreed on the following notes:

  • Notice won't be displayed after dismissing with plugin(s) reactivation (with same settings), import same settings
  • Notice will be normally displayed when delay js is enabled independent of exclusions (i.e with default exclusions, notice is displayed)
  • When enabling autoptimize while LL video is enabled, LL video will be automatically unchecked (this is already on the trunk and added ticket for this)
    testrail-report-311.pdf

@iCaspar iCaspar merged commit d45314e into develop Nov 23, 2021
@iCaspar iCaspar deleted the enhancement/4472-add-notice-for-compat-autoptimize-aggregatejs-rocket-delayjs branch November 23, 2021 16:50
@engahmeds3ed engahmeds3ed removed waiting for feedback status: blocked Issue or PR is blocked by external factor. labels Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting Module: dashboard module: delay JS
Projects
None yet
6 participants