wp-rocket
wp-rocket copied to clipboard
Closes #6604 Add fetch priority to LCP when url is relative
Description
Fixes #6604
Documentation
Modify the regex pattern, to capture all possible cases, absolute, relative and other valid urls
User documentation
Explain how this code impacts users.
Technical documentation
Explain how this code works. Diagram & drawings are welcomed.
Type of change
- [x] Bug fix (non-breaking change which fixes an issue).
New dependencies
N/A
Risks
List possible performance & security issues or risks, and explain how they have been mitigated.
Checklists
Feature validation
- [ ] I validated all the Acceptance Criteria. If possible, provide sreenshots or videos.
- [x] I triggered all changed lines of code at least once without new errors/warnings/notices.
- [x] I implemented built-in tests to cover the new/changed code.
Code style
- [x] I wrote self-explanatory code about what it does.
- [x] I wrote comments to explain why it does it.
- [x] I named variables and functions explicitely.
- [x] I protected entry points against unexpected inputs.
- [x] I did not introduce unecessary complexity.
- [x] I listed the introduced external dependencies explicitely on the PR.
- [x] I validated the repo-specific guidelines from CONTRIBUTING.md.
Observability
- [x] I handled errors when needed.
Coverage summary from Codacy
See diff coverage on Codacy
Coverage variation | Diff coverage |
---|---|
Report missing for 2b088a335a85cb013d8186d2fc7e36f28d152c29[^1] | :white_check_mark: 100.00% (target: 50.00%) |
Coverage variation details
Coverable lines | Covered lines | Coverage | |
---|---|---|---|
Common ancestor commit (2b088a335a85cb013d8186d2fc7e36f28d152c29) | Report Missing | Report Missing | Report Missing |
Head commit (975369e1b9f790aa7e933814b3654f70eb8f77b2) | 37190 | 14427 | 38.79% |
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines | Covered lines | Diff coverage | |
---|---|---|---|
Pull request (#6626) | 10 | 10 | 100.00% |
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%
See your quality gate settings Change summary preferences
Codacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more [^1]: Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
@Khadreal thanks for the PR. Working for the main shared template, and not adding fetchpriority in some edge cases as per exploratory testing below (not working with absolute URL too and same on trunk):
- If the relative URL has fetchpriority='high' in the URL
<img src="/wp-content/rocket-test-data/images/fetchpriority='high'.jpg">
- If src was capital or has 1st letter capital or has space after it (If instead of
src="imageURL"
,SRC
orSrc
orsrc = "imageURL"
) - If a commented exact markup was 1st on page, fetchpriority will be added to the commented markup instead of active one
<!-- <img src="/wp-content/rocket-test-data/images/lcp/testavif.avif"> -->
<img src="/wp-content/rocket-test-data/images/lcp/testavif.avif">
- LCP Image with Fetchpriority in markup, will have fetchpriority='high' and that will cause markup error. Example
<img src="https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testavif.avif" fetchpriority>
=> seems regression and not on trunk @Khadreal can you please check?
@piotrbak Do you think we need GH for any of those cases 1-3?
@Mai-Saad I think those are edge cases, we should be good here
Related test plan https://wpmediaqa.testrail.io/index.php?/runs/view/854&group_by=cases:section_id&group_order=asc
@Mai-Saad handle the regression and 1 and 2 edge cases. We keep looking on how to resolve the 3rd one. You can do another test when you have some time.
@Mai-Saad I have added a fix for scenario 3 when there's a commented exact markup.
Coverage summary from Codacy
See diff coverage on Codacy
Coverage variation | Diff coverage |
---|---|
Report missing for 2b088a335a85cb013d8186d2fc7e36f28d152c29[^1] | :white_check_mark: 100.00% (target: 50.00%) |
Coverage variation details
Coverable lines | Covered lines | Coverage | |
---|---|---|---|
Common ancestor commit (2b088a335a85cb013d8186d2fc7e36f28d152c29) | Report Missing | Report Missing | Report Missing |
Head commit (a55ac728f4a1af282fcdfa72e6e294c5bffc85ad) | 37182 | 14376 | 38.66% |
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines | Covered lines | Diff coverage | |
---|---|---|---|
Pull request (#6626) | 12 | 12 | 100.00% |
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%
See your quality gate settings Change summary preferences
Codacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more [^1]: Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.