Skip to content

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

Open
loevgaard wants to merge 1 commit into
fix/31-readmefrom
fix/32-test-coverage
Open

Raise test coverage from 46% to 97% of lines#56
loevgaard wants to merge 1 commit into
fix/31-readmefrom
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.
⚠️ Please upload report for BASE (fix/31-readme@c8953ac). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             fix/31-readme      #56   +/-   ##
================================================
  Coverage                 ?   96.82%           
  Complexity               ?      170           
================================================
  Files                    ?       35           
  Lines                    ?      535           
  Branches                 ?        0           
================================================
  Hits                     ?      518           
  Misses                   ?       17           
  Partials                 ?        0           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

1 participant