Skip to content

test: cover the heartbeat-events utility functions - #827

Merged
josephfusco merged 2 commits into
WordPress:mainfrom
kamrulhasanj:test/heartbeat-events-unit-tests
Oct 14, 2026
Merged

josephfusco merged 2 commits into
WordPress:mainfrom
kamrulhasanj:test/heartbeat-events-unit-tests

Conversation

@kamrulhasanj

Copy link
Copy Markdown

Adds unit tests covering the jQuery, native CustomEvent fallback, and Heartbeat availability paths in heartbeat-events.

Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: Test structure and coverage verification; reviewed and validated locally against coding standards and test suites.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🛝 WordPress Playgrounds

Built from d7f5392

Post locks RTC Synced patterns Settings
Single site Launch post locks, single site Launch RTC, single site Launch synced patterns, single site Launch settings, single site
Multisite Launch post locks, multisite Launch RTC, multisite Launch synced patterns, multisite Launch network settings, multisite

@kamrulhasanj
kamrulhasanj marked this pull request as ready for review October 13, 2026 08:53
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props bosskhj, rejaulalomkhan, joefusco.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@rejaulalomkhan rejaulalomkhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working on this, @kamrulhasanj! Covering both the jQuery path and the native CustomEvent fallback of heartbeat-events is useful, since so far these helpers were only mocked in other tests.

I ran the new file and the full Vitest suite locally (47 tests pass, lint clean), and tried a few deliberate mutations of heartbeat-events.js to see what the tests catch. Six of seven were caught; I left one small note inline about the native cleanup assertion.

AI Review: Claude Opus 5.5

Comment thread plugins/presence-api/src/utils/test/heartbeat-events.test.js
@josephfusco josephfusco added [Type] Enhancement A suggestion for improvement of an existing feature [Area] Heartbeat 💓 Issues for the heartbeat subsystem javascript Pull requests that update javascript code labels Oct 13, 2026
josephfusco
josephfusco previously approved these changes Oct 13, 2026

@josephfusco josephfusco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Welcome, and thanks for these! Once Rejaul's suggestion is in, this is ready to merge.

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.55%. Comparing base (b5a5951) to head (d7f5392).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #827      +/-   ##
============================================
+ Coverage     97.11%   97.55%   +0.43%     
- Complexity      269      272       +3     
============================================
  Files            30       30              
  Lines          4372     4378       +6     
============================================
+ Hits           4246     4271      +25     
+ Misses          126      107      -19     
Flag Coverage Δ
multisite 97.55% <ø> (+0.43%) ⬆️
phpunit 77.61% <ø> (+0.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@josephfusco josephfusco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, Kamrul, and thanks for the review, Rejaul!

@josephfusco
josephfusco merged commit 575df24 into WordPress:main Oct 14, 2026
28 checks passed
@github-actions github-actions Bot added this to the 0.18.2 milestone Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Heartbeat 💓 Issues for the heartbeat subsystem javascript Pull requests that update javascript code [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants