Skip to content

Raise test coverage from 46% to 97% of lines - #56

Merged
loevgaard merged 1 commit into
masterfrom
fix/32-test-coverage
Sep 14, 2026
Merged

loevgaard merged 1 commit into
masterfrom
fix/32-test-coverage

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Fixes #32

Last in the series, stacked on #55.

Where it started

Classes:  6.90% (2/29)
Methods: 30.00% (21/70)
Lines:   45.91% (129/281)

Only two classes were fully covered, and most subscriber coverage came from getSubscribedEvents() being called during kernel boot rather than from behaviour being exercised. Nearly every bug this series fixed lived in that untested half.

Where it ends

Classes: 80.00% (28/35)
Methods: 90.91% (80/88)
Lines:   97.52% (472/484)

The earlier PRs covered what they changed. This one closes what was left: PopulateRequestPropertiesSubscriber, PopulatePixelsSubscriber, PopulateFbpAndFbcPropertiesSubscriber, ConsentChecker, AddEventToTagBagSubscriber, AddLibraryToTagBagSubscriber and StoreFbcSubscriber.

The end-to-end test

PipelineTest is the one this series needed most. It boots a real kernel with both sides enabled and a recording ClientInterface, pushes a request, registers an application listener at PRIORITY_ENRICH, dispatches a real ConversionsApiEventRaised, and then asserts on both ends:

  • the command was dispatched, routed, handled and reached the client;
  • the payload carries the source url, the user agent, an fbp, and the enriching listener's email as a SHA-256 hash;
  • the tag bag holds the fbq('init') and fbq('track') calls, carrying the same eventID as the server payload, which is what makes Meta deduplicate the pair.

A second test sends a Googlebot user agent and asserts nothing reaches the client, nothing is rendered, and the application's enrichment listener was never invoked.

That test exercises the wiring between listeners, which is where a missing service argument or a bus that no longer exists actually shows up. It would have caught the very first issue in this series.

Keeping it there

codecov.yml turns coverage into a gate: 95% on the project with a 1% threshold, 90% on the patch. The coverage job already uploaded to Codecov but nothing consumed the result.

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.49%. Comparing base (2b99b02) to head (029bb97).

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #56      +/-   ##
============================================
+ Coverage     81.93%   90.49%   +8.56%     
+ Complexity      148      147       -1     
============================================
  Files            31       31              
  Lines           487      484       -3     
============================================
+ Hits            399      438      +39     
+ Misses           88       46      -42     

see 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@loevgaard
loevgaard force-pushed the fix/32-test-coverage branch from cb71f21 to ee5d996 Compare September 7, 2026 12:18
@loevgaard
loevgaard force-pushed the fix/32-test-coverage branch from ee5d996 to 61c8a7d Compare September 7, 2026 12:47
@loevgaard
loevgaard force-pushed the fix/32-test-coverage branch from 61c8a7d to 8353c59 Compare September 7, 2026 12:51
@loevgaard
loevgaard force-pushed the fix/32-test-coverage branch from 8353c59 to 68485b3 Compare September 7, 2026 12:57
Most of the bugs this series fixed lived in code no test touched. Cover
what was left: the request populators, the consent checker, both tag bag
subscribers, StoreFbcSubscriber and CookieBasedFbpContext.

Add an end to end test that dispatches a real event through a booted
kernel and asserts what reaches the client and the tag bag, including
that nothing is sent or enriched for a bot, and gate coverage in Codecov
so it cannot regress silently.

Fixes #32
@loevgaard
loevgaard changed the base branch from fix/31-readme to master September 14, 2026 08:26
@loevgaard
loevgaard merged commit cf8fb52 into master Sep 14, 2026
47 checks passed
@loevgaard
loevgaard deleted the fix/32-test-coverage branch September 14, 2026 08:31
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.

Test coverage: 46% of lines, 2 of 29 classes fully covered, no end-to-end test

1 participant