Skip to content

refactor system fonts to be generic exclusions list#48

Merged
jeawhanlee merged 4 commits into
feature/3.19-beaconsfrom
enhancement/47-exclusions-part
May 15, 2025
Merged

refactor system fonts to be generic exclusions list#48
jeawhanlee merged 4 commits into
feature/3.19-beaconsfrom
enhancement/47-exclusions-part

Conversation

@wordpressfan
Copy link
Copy Markdown
Collaborator

@wordpressfan wordpressfan commented May 7, 2025

Description

Fixes #47
Refactor the system fonts exclusion method to be compatible with generic exclusions

Type of change

  • New feature (non-breaking change which adds functionality).
  • Enhancement (non-breaking change which improves an existing functionality).

Detailed scenario

What was tested

With Debug mode enabled on WPR, check that fonts excluded with the filter are not returned in the console.

How to test

Same as above.

Technical description

Documentation

Change the isSystemFont method to isExcluded and refactor the logic for precise match or substring match with either the font family or urls.

New dependencies

N/A

Risks

N/A

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

Unticked items justification

Not applicable to the changes in this PR

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 8, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for bc8cd031 80.70% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (bc8cd03) Report Missing Report Missing Report Missing
Head commit (e078d65) 1409 1128 80.06%

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 (#48) 57 46 80.70%

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

Footnotes

  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.

@jeawhanlee jeawhanlee marked this pull request as ready for review May 8, 2025 12:22
@jeawhanlee jeawhanlee linked an issue May 8, 2025 that may be closed by this pull request
@jeawhanlee jeawhanlee requested a review from a team May 8, 2025 12:24
jeawhanlee added a commit to wp-media/wp-rocket that referenced this pull request May 12, 2025
@jeawhanlee jeawhanlee merged commit 83abe18 into feature/3.19-beacons May 15, 2025
4 of 5 checks passed
@jeawhanlee jeawhanlee deleted the enhancement/47-exclusions-part branch May 15, 2025 08:05
jeawhanlee added a commit that referenced this pull request Jun 2, 2025
* Added preload fonts beacon

* Updated beacon manager and entry point

* Updated test

* Added test

* Remove comment

* Updated docblock

* Updated doc block

* Updated property

* Updated logger method

* Use updated method

* Added more tests

* Added more tests

* Updated entry point

* Added yet more test

* Fixed codacy critical issues

* Fixed codacy critical issues

* Try to fix medium codacy issue

* Added logic to return font urls

* Updated test

* Added preconnect beacon

* Added test

* Added doc block

* Updated test

* Update to use set to remove duplicate entries

* Added test

* Wait for fonts to be loaded

* Updated test

* Updated conditional to check if stylesheet is internal

* Added test

* Make font extensions exclusions dynamic

* Merge pull request #48 from wp-media/enhancement/47-exclusions-part

refactor system fonts to be generic exclusions list

* Closes #7289: 3.19 Preconnect to external domains - exclusions filter (#52)

* Updated exclusions logic to be compatible with array of strings pattern

* Updated tests

* Updated test data

* Store the url origin in the final result instead of hostname (PR #55)

* Fix: Failed to read the 'cssRules' (#51)

* Implement inlineGoogleFonts method to fetch and inline Google Fonts CSS, avoiding CORS issues

* Add tests for inlineGoogleFonts method to validate fetching and inlining of Google Fonts

* Refactor font handling: Implement externalStylesheetsDoc method to fetch and parse external font stylesheets, and update _initializeExternalFontSheets to manage parsed results.

* remove external urls from stylesheets

* fix test

* add Adame's suggestion and it is working

---------

Co-authored-by: WordPressFan <ahmed@wp-media.me>
Co-authored-by: Michael Lee <michaelleemichaellee408@gmail.com>

* Add font family to allFonts object and push new variation only if matching url is valid (#56)

---------

Co-authored-by: Michael Lee <michaelleemichaellee408@gmail.com>
Co-authored-by: Michael Lee <38788055+jeawhanlee@users.noreply.github.com>
Co-authored-by: Gaël Robin <robin.gael@gmail.com>
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.19 - Preconnect to external domains - Beacon processing part

4 participants